mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-12-01 00:38:13 +08:00
fix some bugs
This commit is contained in:
@@ -13,6 +13,7 @@ class SetRule:
|
||||
self.host_ip = config["host_ip"]
|
||||
self.user_name = config["user_name"]
|
||||
self.password = config["password"]
|
||||
self.download_path = config["download_path"]
|
||||
self.qb = qbittorrentapi.Client(host=self.host_ip, username=self.user_name, password=self.password)
|
||||
try:
|
||||
self.qb.auth_log_in()
|
||||
@@ -33,15 +34,15 @@ class SetRule:
|
||||
'lastMatch': '',
|
||||
'addPaused': False,
|
||||
'assignedCategory': 'Bangumi',
|
||||
'savePath': os.path.join('/downloads', bangumi_name, season)
|
||||
'savePath': str(os.path.join(self.download_path, bangumi_name, season))
|
||||
}
|
||||
self.qb.rss_set_rule(rule_name=bangumi_name, rule_def=rule)
|
||||
|
||||
def run(self):
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] Start adding rules.")
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] Start adding rules." + "\n")
|
||||
sys.stdout.flush()
|
||||
for info in self.bangumi_info:
|
||||
self.set_rule(info["title"], info["season"])
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] Finished.")
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] Finished." + "\n")
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
@@ -27,11 +27,9 @@ class CollectRSS:
|
||||
rss = requests.get(url, 'utf-8')
|
||||
soup = BeautifulSoup(rss.text, 'xml')
|
||||
item = soup.find_all('item')
|
||||
bangumi_title = []
|
||||
for a in item:
|
||||
name = str(a.find('title'))
|
||||
name = re.sub('<title>|</title>', '', name)
|
||||
print(name)
|
||||
parrten = r'\[|\]|\u3010|\u3011|\★|\*|\(|\)|\(|\)'
|
||||
for i in range(2):
|
||||
n = re.split(parrten, name)
|
||||
@@ -44,7 +42,6 @@ class CollectRSS:
|
||||
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)
|
||||
if new_name not in self.bangumi_title:
|
||||
self.bangumi_title.append(new_name)
|
||||
|
||||
@@ -65,16 +62,16 @@ class CollectRSS:
|
||||
"title": title,
|
||||
"season": season
|
||||
})
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] add {title} {season}")
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] add {title} {season}" + "\n")
|
||||
sys.stdout.flush()
|
||||
# 写入数据
|
||||
with open("/config/bangumi.json", 'w', encoding='utf8') as f:
|
||||
json.dump(bangumi_info, f, indent=4, separators=(',', ': '), ensure_ascii=False)
|
||||
|
||||
def run(self):
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] Start scanning RSS Feed.")
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] Start scanning RSS Feed." + "\n")
|
||||
sys.stdout.flush()
|
||||
self.collect_info()
|
||||
self.write_info()
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] Finished.")
|
||||
sys.stdout.write(f"[{time.strftime('%X')}] Finished." + "\n")
|
||||
sys.stdout.flush()
|
||||
@@ -4,10 +4,17 @@ from collect_bangumi_info import CollectRSS
|
||||
from auto_set_rule import SetRule
|
||||
from rename_qb import QbittorrentRename
|
||||
import json
|
||||
import qbittorrentapi
|
||||
|
||||
sleep_time = os.environ["TIME"]
|
||||
|
||||
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="")"""
|
||||
while True:
|
||||
with open("/config/config.json") as f:
|
||||
config = json.load(f)
|
||||
|
||||
Reference in New Issue
Block a user