4
4
from apprise import Apprise
5
5
from loguru import logger
6
6
7
- from program .media .item import MediaItem
7
+ from program .media .item import MediaItem , Stream
8
8
from program .settings .manager import settings_manager
9
9
from program .settings .models import NotificationsModel
10
10
from program .utils import root_dir
@@ -39,36 +39,16 @@ def notification(title: str, body: str) -> None:
39
39
40
40
def _build_discord_notification (item : MediaItem ) -> str :
41
41
"""Build a discord notification for the given item using markdown that lists the files completed."""
42
- notification_message = f"[{ item .type .title ()} ] **{ item .log_string } **\n "
43
-
44
- if item .type == "movie" :
45
- notification_message += f" - File: { item .file } \n "
46
-
47
- elif item .type == "show" :
48
- for season in item .seasons :
49
- notification_message += f"- [Season { season .number } ] **Season { season .number } **\n "
50
- for episode in season .episodes :
51
- notification_message += f" - [Episode { episode .number } ] **{ episode .log_string } **\n "
52
- notification_message += f" - File: { episode .file } \n "
53
-
54
- elif item .type == "season" :
55
- notification_message += f"- [Season { item .number } ] **Season { item .number } **\n "
56
- for episode in item .episodes :
57
- notification_message += f" - [Episode { episode .number } ] **{ episode .log_string } **\n "
58
- notification_message += f" - File: { episode .file } \n "
59
-
60
- elif item .type == "episode" :
61
- notification_message += f" - [Episode { item .number } ] **{ item .log_string } **\n "
62
- notification_message += f" - File: { item .file } \n "
63
-
42
+ notification_message = f"### [{ item .type .title ()} ] **{ item .log_string } ** ({ item .aired_at .year } )\n "
43
+ stream : Stream = next ((stream for stream in item .streams if stream .infohash == item .active_stream .get ("infohash" )), None )
44
+ notification_message += f"- { stream .raw_title } \n "
64
45
return notification_message
65
46
66
-
67
47
def notify_on_complete (item : MediaItem ) -> None :
68
48
"""Send notifications to all services in settings."""
69
49
if item .type not in on_item_type :
70
50
return
71
-
51
+
72
52
title = "Riven completed something!" if not settings .title else settings .title
73
53
body = _build_discord_notification (item )
74
- notification (title , body )
54
+ notification (title , body )
0 commit comments