From 30b8e483f7725c4b8e477ac8951595d2fc6162b8 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Sat, 28 May 2022 23:24:42 +0800 Subject: [PATCH] =?UTF-8?q?v2.3.5=20=E4=BF=AE=E5=A4=8D=E6=9B=B4=E5=90=8D?= =?UTF-8?q?=E4=B8=8D=E6=8D=A2=E8=A1=8C=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoBangumi/app/auto_set_rule.py | 14 +++++----- AutoBangumi/app/collect_bangumi_info.py | 34 ++++++++++++++----------- AutoBangumi/app/rename_qb.py | 2 +- README.md | 11 ++++++++ 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/AutoBangumi/app/auto_set_rule.py b/AutoBangumi/app/auto_set_rule.py index 4bce4d50..dfd94b5c 100644 --- a/AutoBangumi/app/auto_set_rule.py +++ b/AutoBangumi/app/auto_set_rule.py @@ -48,26 +48,24 @@ class SetRule: try: self.qb.rss_remove_item(item_path="Mikan_RSS") except qbittorrentapi.exceptions.Conflict409Error: - sys.stdout.write(f"[{EnvInfo.time_show_obj}] No feed exists, starting adding feed." + "\n") + print(f"[{EnvInfo.time_show_obj}] No feed exists, starting adding feed.") try: 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") + print(f"[{EnvInfo.time_show_obj}] Successes adding RSS Feed.") except ConnectionError: - sys.stdout.write(f"[{EnvInfo.time_show_obj}] Error with adding RSS Feed." + "\n") + print(f"[{EnvInfo.time_show_obj}] Error with adding RSS Feed.") except qbittorrentapi.exceptions.Conflict409Error: - sys.stdout.write(f"[{EnvInfo.time_show_obj}] RSS Already exists." + "\n") + print(f"[{EnvInfo.time_show_obj}] RSS Already exists.") def run(self): - sys.stdout.write(f"[{EnvInfo.time_show_obj}] Start adding rules." + "\n") - sys.stdout.flush() + print(f"[{EnvInfo.time_show_obj}] Start adding rules.") for info in self.bangumi_info: if not info["added"]: 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() + print(f"[{EnvInfo.time_show_obj}] Finished.") if __name__ == "__main__": diff --git a/AutoBangumi/app/collect_bangumi_info.py b/AutoBangumi/app/collect_bangumi_info.py index 5f13f1e4..8794a36e 100644 --- a/AutoBangumi/app/collect_bangumi_info.py +++ b/AutoBangumi/app/collect_bangumi_info.py @@ -1,4 +1,5 @@ # -*- coding: UTF-8 -*- +import os import sys import requests from bs4 import BeautifulSoup @@ -27,7 +28,11 @@ class CollectRSS: except: with open(EnvInfo.rule_path) as r: self.rules = json.load(r) - rss = requests.get(EnvInfo.rss_link, 'utf-8') + try: + rss = requests.get(EnvInfo.rss_link, 'utf-8') + except: + print(f"[{EnvInfo.time_show_obj}] ERROR with DNS/Connection.") + quit() soup = BeautifulSoup(rss.text, 'xml') self.items = soup.find_all('item') with open(EnvInfo.info_path) as i: @@ -79,7 +84,7 @@ class CollectRSS: if exit_flag: break if not exit_flag: - sys.stdout.write(f"[{EnvInfo.time_show_obj}] ERROR Not match with {name}") + print(f"[{EnvInfo.time_show_obj}] ERROR Not match with {name}") def put_info_json(self): had_data = [] @@ -107,8 +112,7 @@ class CollectRSS: "added": False }) had_data.append(json_title) - sys.stdout.write(f"[{EnvInfo.time_show_obj}] add {json_title} {json_season}" + "\n") - sys.stdout.flush() + print(f"[{EnvInfo.time_show_obj}] add {json_title} {json_season}") with open(EnvInfo.info_path, 'w', encoding='utf8') as f: json.dump(self.info, f, indent=4, separators=(',', ': '), ensure_ascii=False) @@ -118,14 +122,14 @@ class CollectRSS: if __name__ == "__main__": - rss = requests.get(EnvInfo.rss_link, 'utf-8') - soup = BeautifulSoup(rss.text, 'xml') - items = soup.find_all('item') - for item in items: - name = item.title.string - print(BColors.HEADER + name + BColors.OKGREEN) - pn = Filter(name).Name - print(pn.clean) - - # print(BColors.HEADER + name) - # print(BColors.OKGREEN + str(pn.Name.en)) \ No newline at end of file + # rss = requests.get(EnvInfo.rss_link, 'utf-8') + # soup = BeautifulSoup(rss.text, 'xml') + # items = soup.find_all('item') + # for item in items: + # name = item.title.string + # pn = Filter(name).Name + # print(BColors.HEADER + name) + # print(BColors.OKGREEN + str(pn.zh)) + # print(str(pn.en)) + print(__file__) + print(os.path.dirname(__file__)) diff --git a/AutoBangumi/app/rename_qb.py b/AutoBangumi/app/rename_qb.py index 37049a95..7ce1cfe8 100644 --- a/AutoBangumi/app/rename_qb.py +++ b/AutoBangumi/app/rename_qb.py @@ -54,7 +54,7 @@ class qBittorrentRename: def rename(self): if self.path_name != self.new_name: self.qbt_client.torrents_rename_file(torrent_hash=self.hash, old_path=self.path_name, new_path=self.new_name) - sys.stdout.write(f"[{time.strftime('%Y-%m-%d %X')}] {self.path_name} >> {self.new_name}" + "\n") + print(f"[{time.strftime('%Y-%m-%d %X')}] {self.path_name} >> {self.new_name}") self.count += 1 else: return diff --git a/README.md b/README.md index cda805c1..0285e537 100644 --- a/README.md +++ b/README.md @@ -125,5 +125,16 @@ docker run -d \ 4. 安装媒体库软件 +## Roadmap + +***开发中的功能:*** +- RSS 解析器:AutoBangumi 可以自行解析分析种子无需依赖下载器。 +- Transmission & Aria2 的支持。 +- 遗漏番剧下载:中间开始追番可以补全之前的剧集。 + +***计划开发的功能:*** +- Web UI +- 更为智能细致的分类预设。 + # 声明 本项目的自动改名规则根据 [miracleyoo/anime_renamer](https://github.com/miracleyoo/anime_renamer) 项目