diff --git a/AutoBangumi/Dockerfile b/AutoBangumi/Dockerfile index fef4390a..300cbfa8 100644 --- a/AutoBangumi/Dockerfile +++ b/AutoBangumi/Dockerfile @@ -7,10 +7,11 @@ RUN pip install -r requirements.txt ENV TZ=Asia/Shanghai ENV TIME=1800 -ENV HOST=127.0.0.1:8080 +ENV HOST=localhost:8080 ENV USER=admin ENV PASSWORD=adminadmin ENV METHOD=pn +ENV GROUP_TAG=False COPY ./app /app COPY ./config /config diff --git a/AutoBangumi/app/auto_set_rule.py b/AutoBangumi/app/auto_set_rule.py index 3b7598e5..a6bf5aff 100644 --- a/AutoBangumi/app/auto_set_rule.py +++ b/AutoBangumi/app/auto_set_rule.py @@ -22,7 +22,7 @@ def __init__(self): except qbittorrentapi.LoginFailed as e: print(e) - def set_rule(self, bangumi_name, season): + def set_rule(self, bangumi_name, group, season): rule = { 'enable': True, 'mustContain': bangumi_name, @@ -38,7 +38,11 @@ def set_rule(self, bangumi_name, season): 'assignedCategory': 'Bangumi', 'savePath': str(os.path.join(self.download_path, re.sub(EnvInfo.rule_name_re," ", bangumi_name), season)) } - self.qb.rss_set_rule(rule_name=bangumi_name, rule_def=rule) + if EnvInfo.enable_group_tag: + rule_name = f"[{group}] {bangumi_name}" + else: + rule_name = bangumi_name + self.qb.rss_set_rule(rule_name=rule_name, rule_def=rule) def rss_feed(self): try: @@ -58,10 +62,15 @@ def run(self): sys.stdout.flush() for info in self.bangumi_info: if not info["added"]: - self.set_rule(info["title"], info["season"]) + self.set_rule(info["title"], info["group"], info["season"]) info["added"] = True with open(EnvInfo.info_path, 'w', encoding='utf8') as f: json.dump(self.info, f, indent=4, separators=(',', ': '), ensure_ascii=False) sys.stdout.write(f"[{EnvInfo.time_show_obj}] Finished." + "\n") sys.stdout.flush() + +if __name__ == "__main__": + put = SetRule() + put.run() + diff --git a/AutoBangumi/app/collect_bangumi_info.py b/AutoBangumi/app/collect_bangumi_info.py index 02171420..9f55c2cd 100644 --- a/AutoBangumi/app/collect_bangumi_info.py +++ b/AutoBangumi/app/collect_bangumi_info.py @@ -65,9 +65,13 @@ def get_info_list(self): if match_obj is not None: bangumi_title = match_obj.group(2).strip() if bangumi_title not in self.bangumi_list: - self.bangumi_list.append(bangumi_title) + self.bangumi_list.append({ + "title": bangumi_title, + "group": group + }) # debug # print(bangumi_title) + # print(group) break if exit_flag: break @@ -84,19 +88,19 @@ def put_info_json(self): "rss_link": EnvInfo.rss_link, "bangumi_info": [] } - for title in self.bangumi_list: - match_title_season = re.match(MatchRule.season_match, title, re.I) + for item in self.bangumi_list: + match_title_season = re.match(MatchRule.season_match, item["title"], re.I) if match_title_season is not None: json_title = match_title_season.group(1).strip() json_season = match_title_season.group(2) else: json_season = 'S01' - json_title = title + json_title = item["title"] if json_title not in had_data: self.info["bangumi_info"].append({ "title": json_title, "season": json_season, - "group": '', + "group": item["group"], "added": False }) sys.stdout.write(f"[{EnvInfo.time_show_obj}] add {json_title} {json_season}" + "\n") @@ -111,4 +115,5 @@ def run(self): if __name__ == "__main__": cr = CollectRSS() - cr.get_info_list() \ No newline at end of file + cr.get_info_list() + cr.put_info_json() \ No newline at end of file diff --git a/AutoBangumi/app/env.py b/AutoBangumi/app/env.py index fde5003b..8080be60 100644 --- a/AutoBangumi/app/env.py +++ b/AutoBangumi/app/env.py @@ -13,6 +13,7 @@ class EnvInfo: rss_link = os.environ["RSS"] download_path = os.environ["DOWNLOAD_PATH"] method = os.environ["METHOD"] + enable_group_tag = os.getenv("GROUP_TAG", 'False').lower() in ('true', '1', 't') info_path = "/config/bangumi.json" rule_path = "/config/rule.json" else: @@ -21,9 +22,10 @@ class EnvInfo: sleep_time = 10 user_name = "admin" password = "adminadmin" - rss_link = "" + rss_link = "https://mikanani.me/RSS/MyBangumi?token=Td8ceWZZv3s2OZm5ji9RoMer8vk5VS3xzC1Hmg8A26E%3d" download_path = "/downloads/Bangumi" method = "pn" + enable_group_tag = True info_path = "../config/bangumi.json" rule_path = "../config/rule.json" # Static ENV diff --git a/AutoBangumi/config/bangumi.json b/AutoBangumi/config/bangumi.json new file mode 100644 index 00000000..53ba9760 --- /dev/null +++ b/AutoBangumi/config/bangumi.json @@ -0,0 +1,113 @@ +{ + "rss_link": "https://mikanani.me/RSS/MyBangumi?token=Td8ceWZZv3s2OZm5ji9RoMer8vk5VS3xzC1Hmg8A26E%3d", + "bangumi_info": [ + { + "title": "Kakkou no Iinazuke", + "season": "S01", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "SPYxFAMILY", + "season": "S01", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "Love Live", + "season": "S02", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "CUE!", + "season": "S01", + "group": "喵萌Production", + "added": true + }, + { + "title": "CUE!", + "season": "S01", + "group": "喵萌Production", + "added": true + }, + { + "title": "Kaguya-sama wa Kokurasetai", + "season": "S03", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "Shokei Shoujo no Virgin Road", + "season": "S01", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "Kakkou no Iikagen", + "season": "S01", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "Tomodachi Game", + "season": "S01", + "group": "离谱Sub", + "added": true + }, + { + "title": "Summer Time Rendering", + "season": "S01", + "group": "喵萌奶茶屋", + "added": true + }, + { + "title": "Summer Time Rendering", + "season": "S01", + "group": "喵萌奶茶屋", + "added": true + }, + { + "title": "Paripi Koumei", + "season": "S01", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "Tomodachi Game", + "season": "S01", + "group": "离谱Sub", + "added": true + }, + { + "title": "Tate no Yuusha no Nariagari", + "season": "S02", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "Shijou Saikyou no Daimaou", + "season": "S01", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "Yuusha, Yamemasu", + "season": "S01", + "group": "Lilith-Raws", + "added": true + }, + { + "title": "Aharen-san wa Hakarenai", + "season": "S01", + "group": "LoliHouse", + "added": true + }, + { + "title": "Aharen-san wa Hakarenai", + "season": "S01", + "group": "LoliHouse", + "added": true + } + ] +} \ No newline at end of file diff --git a/test/test.py b/test/test.py index eb914c31..e881e859 100644 --- a/test/test.py +++ b/test/test.py @@ -1,6 +1,4 @@ -import os -import qbittorrentapi -abs_path = os.path.dirname(os.path.abspath(__file__)) -print(abs_path) \ No newline at end of file +a = "false" +print(bool(a)) \ No newline at end of file