diff --git a/src/module/manager/repath.py b/src/module/manager/repath.py index b53fd4fd..c2ee5718 100644 --- a/src/module/manager/repath.py +++ b/src/module/manager/repath.py @@ -38,7 +38,7 @@ class RepathTorrents: season = int(re.search(r"\d{1,2}", season_folder).group()) return season, folder_name - def get_rule(self) -> [RuleInfo]: + def get_rule(self) -> list[RuleInfo]: rules = self._client.get_download_rules() all_rule = [] for rule in rules: @@ -50,7 +50,7 @@ class RepathTorrents: return all_rule @staticmethod - def get_difference(bangumi_data: list, rules: [RuleInfo]) -> [RuleInfo]: + def get_difference(bangumi_data: list, rules: list[RuleInfo]) -> list[RuleInfo]: different_data = [] for data in bangumi_data: for rule in rules: @@ -62,7 +62,7 @@ class RepathTorrents: break return different_data - def get_matched_torrents_list(self, repath_rules: [RuleInfo]) -> [RePathInfo]: + def get_matched_torrents_list(self, repath_rules: list[RuleInfo]) -> list[RepathInfo]: infos = self._client.get_torrent_info() repath_list = [] for rule in repath_rules: diff --git a/src/module/network/notification.py b/src/module/network/notification.py index 993c231b..e1fba4dd 100644 --- a/src/module/network/notification.py +++ b/src/module/network/notification.py @@ -17,6 +17,8 @@ class PostNotification: return TelegramNotification() elif settings.notification.type.lower() == "server-chan": return ServerChanNotification() + elif settings.notification.type.lower() == "bark": + return BarkNotification() else: return None @@ -61,3 +63,20 @@ class ServerChanNotification: resp = req.post_data(self.notification_url, data) logger.debug(f"ServerChan notification: {resp.status_code}") return resp.status_code == 200 + + +class BarkNotification: + def __init__(self): + self.token = settings.notification.token + self.notification_url = "https://api.day.app/push" + + def send_msg(self, title: str, desp: str): + data = { + "title": title, + "body": desp, + "device_key": self.token + } + with RequestContent() as req: + resp = req.post_data(self.notification_url, data) + logger.debug(f"Bark notification: {resp.status_code}") + return resp.status_code == 200