diff --git a/.env b/.env new file mode 100644 index 00000000..0eb21c18 --- /dev/null +++ b/.env @@ -0,0 +1,8 @@ + +HOST=192.168.31.10:8181 +TIME=1800 +USER=admin +PASSWORD=adminadmin +RSS=https://mikanani.me/RSS/Classic +DOWNLOAD_PATH=/downloads/Bangumi +METHOD=pn \ No newline at end of file diff --git a/AutoBangumi/Dockerfile b/AutoBangumi/Dockerfile index 83f991b8..fef4390a 100644 --- a/AutoBangumi/Dockerfile +++ b/AutoBangumi/Dockerfile @@ -13,5 +13,6 @@ ENV PASSWORD=adminadmin ENV METHOD=pn COPY ./app /app +COPY ./config /config CMD [ "python3", "/app/docker_main.py"] \ No newline at end of file diff --git a/AutoBangumi/app/auto_set_rule.py b/AutoBangumi/app/auto_set_rule.py index 59d4e326..fa655e11 100644 --- a/AutoBangumi/app/auto_set_rule.py +++ b/AutoBangumi/app/auto_set_rule.py @@ -8,7 +8,7 @@ import os class SetRule: def __init__(self): with open(EnvInfo.info_path) as f: - self.bangumi_info = json.load(f) + self.bangumi_info = json.load(f)["bangumi_info"] self.rss_link = EnvInfo.rss_link self.host_ip = EnvInfo.host_ip self.user_name = EnvInfo.user_name @@ -38,12 +38,14 @@ class SetRule: } self.qb.rss_set_rule(rule_name=bangumi_name, rule_def=rule) - def add_rss_feed(self): + def rss_feed(self): try: - self.qb.rss_add_feed(self.rss_link) + self.qb.rss_add_feed(url=self.rss_link, item_path="Mikan_RSS") sys.stdout.write(f"[{EnvInfo.time_show_obj}] Successes adding RSS Feed." + "\n") except ConnectionError: sys.stdout.write(f"[{EnvInfo.time_show_obj}] Error with adding RSS Feed." + "\n") + except qbittorrentapi.exceptions.Conflict409Error: + sys.stdout.write(f"[{EnvInfo.time_show_obj}] RSS Already exists." + "\n") def run(self): sys.stdout.write(f"[{EnvInfo.time_show_obj}] Start adding rules." + "\n") diff --git a/AutoBangumi/app/collect_bangumi_info.py b/AutoBangumi/app/collect_bangumi_info.py index 4477924e..24f25cfd 100644 --- a/AutoBangumi/app/collect_bangumi_info.py +++ b/AutoBangumi/app/collect_bangumi_info.py @@ -76,8 +76,14 @@ class CollectRSS: def put_info_json(self): had_data = [] - for data in self.info: - had_data.append(data["title"]) + if self.info["rss_link"] == EnvInfo.rss_link: + for data in self.info["bangumi_info"]: + had_data.append(data["title"]) + else: + self.info = { + "rss_link": EnvInfo.rss_link, + "bangumi_info": [] + } for title in self.bangumi_list: match_title_season = re.match(MatchRule.season_match, title, re.I) if match_title_season is not None: @@ -87,7 +93,7 @@ class CollectRSS: json_season = '' json_title = title if json_title not in had_data: - self.info.append({ + self.info["bangumi_info"].append({ "title": json_title, "season": json_season }) diff --git a/AutoBangumi/app/docker_main.py b/AutoBangumi/app/docker_main.py index 07497f25..e4be98d1 100644 --- a/AutoBangumi/app/docker_main.py +++ b/AutoBangumi/app/docker_main.py @@ -9,13 +9,16 @@ from env import EnvInfo def create_data_file(): if not os.path.exists(EnvInfo.info_path): - bangumi_info = [] + bangumi_info = {"rss_link": EnvInfo.rss_link, + "bangumi_info": [] + } with open(EnvInfo.info_path, "w") as i: json.dump(bangumi_info, i, indent=4, separators=(',', ': '), ensure_ascii=False) if __name__ == "__main__": create_data_file() + SetRule().rss_feed() while True: CollectRSS().run() SetRule().run() diff --git a/AutoBangumi/app/env.py b/AutoBangumi/app/env.py index 3c9df243..9c235481 100644 --- a/AutoBangumi/app/env.py +++ b/AutoBangumi/app/env.py @@ -13,5 +13,5 @@ class EnvInfo: method = os.environ["METHOD"] # rss_link = "https://mikanani.me/RSS/Classic" rule_url = "https://raw.githubusercontent.com/EstrellaXD/Bangumi_Auto_Collector/main/AutoBangumi/app/rule.json" - rule_path = "/app/rule.json" + rule_path = "/config/rule.json" time_show_obj = time.strftime('%Y-%m-%d %X') \ No newline at end of file diff --git a/AutoBangumi/config/bangumi.json b/AutoBangumi/config/bangumi.json deleted file mode 100644 index 4c9b023c..00000000 --- a/AutoBangumi/config/bangumi.json +++ /dev/null @@ -1,58 +0,0 @@ -[ - { - "title": "simple", - "season": "" - }, - { - "title": "Kawaii dake ja Nai Shikimori-san", - "season": "" - }, - { - "title": "Kakkou no Iinazuke", - "season": "" - }, - { - "title": "SPYxFAMILY", - "season": "" - }, - { - "title": "Love Live!虹咲学园 学园偶像同好会", - "season": "S02" - }, - { - "title": "CUE!", - "season": "" - }, - { - "title": "Kaguya-sama wa Kokurasetai", - "season": "S03" - }, - { - "title": "Shokei Shoujo no Virgin Road", - "season": "" - }, - { - "title": "Kakkou no Iikagen", - "season": "" - }, - { - "title": "Summer Time Rendering", - "season": "" - }, - { - "title": "Paripi Koumei", - "season": "" - }, - { - "title": "Tate no Yuusha no Nariagari", - "season": "S02" - }, - { - "title": "Shijou Saikyou no Daimaou", - "season": "" - }, - { - "title": "Yuusha, Yamemasu", - "season": "" - } -] \ No newline at end of file diff --git a/AutoBangumi/config/config.json b/AutoBangumi/config/config.json deleted file mode 100644 index 73fb7cfb..00000000 --- a/AutoBangumi/config/config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "host_ip": "192.168.31.10:8181", - "user_name": "admin", - "password": "adminadmin", - "method": "pn", - "rss_link": "https://mikanani.me/RSS/MyBangumi?token=qTxKo48gH1SrFNy8X%2fCfQUoeElNsgKNWFNzNieKwBH8%3d", - "download_path": "/downloads/Bangumi" -} \ No newline at end of file diff --git a/AutoBangumi/config/rename_rule.txt b/AutoBangumi/config/rename_rule.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/AutoBangumi/app/rule.json b/AutoBangumi/config/rule.json similarity index 95% rename from AutoBangumi/app/rule.json rename to AutoBangumi/config/rule.json index 222e9271..31d412e2 100644 --- a/AutoBangumi/app/rule.json +++ b/AutoBangumi/config/rule.json @@ -44,7 +44,8 @@ "动漫国字幕组", "SweetSub&圆环记录攻略组", "动漫萌", - "极影字幕社" + "极影字幕社", + "喵萌Production" ], "name_position": 2 }, diff --git a/test/test.py b/test/test.py index 6ff7279f..d7f9b9ab 100644 --- a/test/test.py +++ b/test/test.py @@ -1,3 +1,6 @@ +import qbittorrentapi -str = "ab" -print(len(str.encode())) \ No newline at end of file +qb = qbittorrentapi.Client(host="localhost:8080",username="admin",password="adminadmin") + +qb.auth_log_in() +qb.rss_add_feed(url="https://mikanani.me",item_path="自动下载") \ No newline at end of file