mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-06-14 22:18:02 +08:00
fix some bugs
This commit is contained in:
@@ -5,6 +5,9 @@ COPY requirements.txt .
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
ENV TIME=1800
|
||||
|
||||
COPY ./app /app
|
||||
|
||||
CMD [ "python3", "/app/docker_main.py"]
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
@@ -4,21 +4,39 @@ from collect_bangumi_info import CollectRSS
|
||||
from auto_set_rule import SetRule
|
||||
from rename_qb import QbittorrentRename
|
||||
import json
|
||||
import qbittorrentapi
|
||||
|
||||
|
||||
config_path = "/config/config.json"
|
||||
info_path = "/config/bangumi.json"
|
||||
sleep_time = os.environ["TIME"]
|
||||
|
||||
|
||||
def create_config():
|
||||
if not os.path.exists(config_path):
|
||||
config = {
|
||||
"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"
|
||||
}
|
||||
with open(config_path,"w") as c:
|
||||
json.dump(config, c, indent=4, separators=(',', ': '), ensure_ascii=False)
|
||||
if not os.path.exists(info_path):
|
||||
bangumi_info = [{"title":"simple","season":""}]
|
||||
with open(info_path) as i:
|
||||
json.dump(bangumi_info, i, indent=4, separators=(',', ': '), ensure_ascii=False)
|
||||
print(f"[{time.strftime('%X')}] 请填入配置参数")
|
||||
quit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""qb = qbittorrentapi.Client(username='admin', password='adminadmin', host='192.168.31.10', port=8181)
|
||||
try:
|
||||
qb.auth_log_in()
|
||||
except qbittorrentapi.LoginFailed as e:
|
||||
print(e)
|
||||
qb.rss_add_feed(url="")"""
|
||||
create_config()
|
||||
with open(config_path) as f:
|
||||
config = json.load(f)
|
||||
while True:
|
||||
with open("/config/config.json") as f:
|
||||
config = json.load(f)
|
||||
with open("/config/bangumi.json") as f:
|
||||
with open(info_path) as f:
|
||||
info = json.load(f)
|
||||
CollectRSS(config, info).run()
|
||||
SetRule(config, info).run()
|
||||
|
||||
@@ -53,8 +53,8 @@ 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.name, new_path=self.new_name)
|
||||
print(f'{self.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('%X')}] {self.path_name} >> {self.new_name}")
|
||||
self.count += 1
|
||||
else:
|
||||
return
|
||||
@@ -63,6 +63,7 @@ class QbittorrentRename:
|
||||
self.name = None
|
||||
self.hash = None
|
||||
self.new_name = None
|
||||
self.path_name = None
|
||||
|
||||
def print_result(self):
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] 已完成对{self.torrent_count}个文件的检查" + '\n')
|
||||
|
||||
6
test/bangumi.json
Normal file
6
test/bangumi.json
Normal file
@@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"title": "simple",
|
||||
"season": ""
|
||||
}
|
||||
]
|
||||
8
test/config.json
Normal file
8
test/config.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"host_ip": "127.0.0.1:8080",
|
||||
"user_name": "admin",
|
||||
"password": "adminadmin",
|
||||
"method": "pn",
|
||||
"rss_link": "https://mikanani.me/RSS/MyBangumi?token=qTxKo48gH1SrFNy8X%2fCfQUoeElNsgKNWFNzNieKwBH8%3d",
|
||||
"download_path": "/downloads/Bangumi"
|
||||
}
|
||||
49
test/test.py
49
test/test.py
@@ -1,30 +1,27 @@
|
||||
import re
|
||||
import json
|
||||
import os
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
config_path = "config.json"
|
||||
info_path = "bangumi.json"
|
||||
|
||||
|
||||
def create_config():
|
||||
if not os.path.exists(config_path):
|
||||
config = {
|
||||
"host_ip": "127.0.0.1:8080",
|
||||
"user_name": "admin",
|
||||
"password": "adminadmin",
|
||||
"method": "pn",
|
||||
"rss_link": "https://mikanani.me/RSS/MyBangumi?token=qTxKo48gH1SrFNy8X%2fCfQUoeElNsgKNWFNzNieKwBH8%3d",
|
||||
"download_path": "/downloads/Bangumi"
|
||||
}
|
||||
with open(config_path,"w") as c:
|
||||
json.dump(config, c, indent=4, separators=(',', ': '), ensure_ascii=False)
|
||||
if not os.path.exists(info_path):
|
||||
bangumi_info = [{"title": "simple","season": ""}]
|
||||
with open(info_path, "w") as i:
|
||||
json.dump(bangumi_info, i, indent=4, separators=(',', ': '), ensure_ascii=False)
|
||||
print("请填入配置参数")
|
||||
quit()
|
||||
|
||||
episode_rules = [r'(.*)\[(\d{1,3}|\d{1,3}\.\d{1,2})(?:v\d{1,2})?(?:END)?\](.*)',
|
||||
r'(.*)\[E(\d{1,3}|\d{1,3}\.\d{1,2})(?:v\d{1,2})?(?:END)?\](.*)',
|
||||
r'(.*)\[第(\d*\.*\d*)话(?:END)?\](.*)',
|
||||
r'(.*)\[第(\d*\.*\d*)話(?:END)?\](.*)',
|
||||
r'(.*)第(\d*\.*\d*)话(?:END)?(.*)',
|
||||
r'(.*)第(\d*\.*\d*)話(?:END)?(.*)',
|
||||
r'(.*)- (\d{1,3}|\d{1,3}\.\d{1,2})(?:v\d{1,2})?(?:END)? (.*)']
|
||||
|
||||
|
||||
name = "[NC-Raws] 小书痴的下克上:为了成为图书管理员不择手段!第三季 / Honzuki no Gekokujou S3 - 32 (Baha 1920x1080 AVC AAC MP4)"
|
||||
parrten = r'\[|\]|\u3010|\u3011|\★|\*|\(|\)|\(|\)'
|
||||
for i in range(2):
|
||||
n = re.split(parrten, name)
|
||||
try:
|
||||
name = re.sub(f'\[{n[1]}\]|【{n[1]}】|★{n[1]}★', '', name)
|
||||
except:
|
||||
name = name
|
||||
for rule in episode_rules:
|
||||
matchObj = re.match(rule, name, re.I)
|
||||
if matchObj is not None:
|
||||
new_name = re.sub(r'\[|\]', '', f'{matchObj.group(1)}')
|
||||
new_name = re.split(r'/', new_name)[-1].strip()
|
||||
print(new_name)
|
||||
create_config()
|
||||
Reference in New Issue
Block a user