From 584a419712911f5b9172a89329255c4bf70619db Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Mon, 16 May 2022 00:48:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BF=AE=E6=AD=A3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- config.json | 2 +- rename_qb.py | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e5702f36..bd119eb9 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ pip install qbittorrent-api "username": "admin", "password": "adminadmin", "savepath": "/downloads/Bangumi", - "method": "pr" + "method": "pn" } ``` ## 自动下载规则建立 @@ -31,7 +31,7 @@ python3 rename_qb.py --help ``` 目前有三种重命名模式 - `normal`: 普通模式,直接重命名,保留番剧字幕组信息。 -- `pr`: 纯净模式,保留番剧名称和剧集信息,去掉多余信息。 +- `pn`: 纯净模式,保留番剧名称和剧集信息,去掉多余信息。 - `hash`: 哈希模式,用于 Torrent 软件完成之后执行命令。 然后运行 `rename_qb.py` 即可, 如果只想对新番进行重命名,可以在程序中添加添加 `categories="Bangumi"` 语句 diff --git a/config.json b/config.json index 6991a05b..c74b7c2c 100644 --- a/config.json +++ b/config.json @@ -3,5 +3,5 @@ "username": "admin", "password": "adminadmin", "savepath": "/downloads/Bangumi", - "method": "pr" + "method": "pn" } \ No newline at end of file diff --git a/rename_qb.py b/rename_qb.py index 95abf8ea..b5482ff4 100644 --- a/rename_qb.py +++ b/rename_qb.py @@ -58,8 +58,10 @@ class Qbtorrent_Rename: if matchObj is not None: if self.method == 'normal': self.new_name = f'{matchObj.group(1)} E{matchObj.group(2)} {matchObj.group(3)}' - elif self.method == 'pr': - self.new_name = f'{matchObj.group(1)} E{matchObj.group(2)}' + elif self.method == 'pn': + new_name = f'{matchObj.group(1)} E{matchObj.group(2)}.mp4' + new_name = new_name.replace('[', '') + self.new_name = new_name.replace(']', '') def qb_rename(self, idx, torrent_hash=''): self.rename(idx) @@ -70,7 +72,7 @@ class Qbtorrent_Rename: try: self.qbt_client.torrents_rename_file(torrent_hash=self.hash, old_path=self.name, new_path=self.new_name) self.count += 1 - print('{} >> {}'.format(self.name, self.new_name)) + print(f'{self.name} >> {self.new_name}') except: return self.new_name = None @@ -78,7 +80,7 @@ class Qbtorrent_Rename: def app(): args = parser.parse_args() - if method not in ['hash', 'pr', 'normal']: + if method not in ['hash', 'pn', 'normal']: print("Not a correct method") quit() qb = Qbtorrent_Rename(method=method) @@ -89,7 +91,7 @@ def app(): except: print('error') quit() - elif method == 'pr': + elif method == 'pn': for i in range(0, qb.torrent_count + 1): try: qb.qb_rename(i)