mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-05-03 23:42:30 +08:00
2.4.9
This commit is contained in:
2
.idea/Bangumi_Auto_Rename.iml
generated
2
.idea/Bangumi_Auto_Rename.iml
generated
@@ -4,7 +4,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/auto_bangumi" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.10 (auto_bangumi)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (auto_bangumi)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
@@ -22,12 +22,14 @@ def load_data_file():
|
||||
bangumi_data = {
|
||||
"rss_link": settings.rss_link,
|
||||
"data_version": settings.data_version,
|
||||
"first_run": True,
|
||||
"bangumi_info": []
|
||||
}
|
||||
else:
|
||||
bangumi_data = json_config.load(info_path)
|
||||
if bangumi_data["data_version"] != settings.data_version or bangumi_data["rss_link"] != settings.rss_link:
|
||||
bangumi_data["bangumi_info"] = []
|
||||
bangumi_data["first_run"] = True
|
||||
bangumi_data["rss_link"] = settings.rss_link
|
||||
return bangumi_data
|
||||
|
||||
@@ -37,6 +39,20 @@ def save_data_file(bangumi_data):
|
||||
json_config.save(info_path, bangumi_data)
|
||||
|
||||
|
||||
def show_info():
|
||||
logger.info(" _ ____ _ ")
|
||||
logger.info(" /\ | | | _ \ (_)")
|
||||
logger.info(" / \ _ _| |_ ___ | |_) | __ _ _ __ __ _ _ _ _ __ ___ _ ")
|
||||
logger.info(" / /\ \| | | | __/ _ \| _ < / _` | '_ \ / _` | | | | '_ ` _ \| |")
|
||||
logger.info(" / ____ \ |_| | || (_) | |_) | (_| | | | | (_| | |_| | | | | | | |")
|
||||
logger.info(" /_/ \_\__,_|\__\___/|____/ \__,_|_| |_|\__, |\__,_|_| |_| |_|_|")
|
||||
logger.info(" __/ | ")
|
||||
logger.info(" |___/ ")
|
||||
logger.info("Version 2.4.9 Author: EstrellaXD Twitter: https://twitter.com/Estrella_Pan")
|
||||
logger.info("GitHub: https://github.com/EstrellaXD/Auto_Bangumi/")
|
||||
logger.info("Starting AutoBangumi...")
|
||||
|
||||
|
||||
def run():
|
||||
args = parse()
|
||||
if args.debug:
|
||||
@@ -48,6 +64,7 @@ def run():
|
||||
else:
|
||||
settings.init()
|
||||
setup_logger()
|
||||
show_info()
|
||||
time.sleep(3)
|
||||
download_client = DownloadClient()
|
||||
download_client.init_downloader()
|
||||
@@ -57,7 +74,6 @@ def run():
|
||||
download_client.rss_feed()
|
||||
rss_collector = RSSCollector()
|
||||
renamer = Renamer(download_client)
|
||||
loop_zero = True
|
||||
while True:
|
||||
bangumi_data = load_data_file()
|
||||
try:
|
||||
@@ -65,17 +81,17 @@ def run():
|
||||
if settings.enable_eps_complete:
|
||||
download_client.eps_collect(bangumi_data["bangumi_info"])
|
||||
download_client.add_rules(bangumi_data["bangumi_info"])
|
||||
save_data_file(bangumi_data)
|
||||
if loop_zero:
|
||||
if bangumi_data["first_run"]:
|
||||
logger.info(f"Waiting for downloading torrents...")
|
||||
time.sleep(0)
|
||||
time.sleep(600)
|
||||
bangumi_data["first_run"] = False
|
||||
save_data_file(bangumi_data)
|
||||
renamer.run()
|
||||
time.sleep(settings.sleep_time)
|
||||
except Exception as e:
|
||||
if args.debug:
|
||||
raise e
|
||||
logger.exception(e)
|
||||
loop_zero = False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#from thefuzz import fuzz
|
||||
from thefuzz import fuzz
|
||||
|
||||
|
||||
# TODO 模糊匹配模块
|
||||
|
||||
@@ -10,14 +10,13 @@ DEFAULT_SETTINGS = {
|
||||
"enable_group_tag": False,
|
||||
"info_path": "/config/bangumi.json",
|
||||
"not_contain": "720",
|
||||
"rule_url": "https://raw.githubusercontent.com/EstrellaXD/Bangumi_Auto_Collector/main/AutoBangumi/config/rule.json",
|
||||
"rule_name_re": r"\:|\/|\.",
|
||||
"connect_retry_interval": 5,
|
||||
"debug_mode": False,
|
||||
"season_one_tag": True,
|
||||
"remove_bad_torrent": False,
|
||||
"dev_debug": False,
|
||||
"data_version": 3.0,
|
||||
"data_version": 3.1,
|
||||
"enable_eps_complete": False
|
||||
}
|
||||
|
||||
|
||||
@@ -115,4 +115,4 @@ class DownloadClient:
|
||||
|
||||
if __name__ == "__main__":
|
||||
put = DownloadClient()
|
||||
put.add_rules()
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import re
|
||||
import logging
|
||||
from pathlib import PurePath
|
||||
from pathlib import PurePath, PureWindowsPath
|
||||
|
||||
from conf import settings
|
||||
from core.download_client import DownloadClient
|
||||
@@ -29,21 +28,28 @@ class Renamer:
|
||||
else:
|
||||
for i in range(0, self.torrent_count):
|
||||
info = self.recent_info[i]
|
||||
name = info.name
|
||||
hash = info.hash
|
||||
path_name = PurePath(info.content_path).name \
|
||||
if PurePath(info.content_path).name != info.content_path \
|
||||
else PureWindowsPath(info.content_path).name
|
||||
try:
|
||||
name = info.name
|
||||
hash = info.hash
|
||||
path_name = PurePath(info.content_path).name
|
||||
new_name = method_dict[settings.method](name)
|
||||
logger.debug(f"{path_name}")
|
||||
logger.debug(f"{new_name}")
|
||||
if path_name != new_name:
|
||||
self.client.rename_torrent_file(hash, path_name, new_name)
|
||||
self.rename_count += 1
|
||||
except:
|
||||
logger.warning(f"{info.name} rename failed")
|
||||
logger.warning(f"{path_name} rename failed")
|
||||
if settings.remove_bad_torrent:
|
||||
self.client.delete_torrent(info.hash)
|
||||
self.client.delete_torrent(hash)
|
||||
self.print_result()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from const_dev import DEV_SETTINGS
|
||||
settings.init(DEV_SETTINGS)
|
||||
client = DownloadClient()
|
||||
rename = Renamer(client)
|
||||
rename.run()
|
||||
|
||||
@@ -2,5 +2,5 @@ qbittorrent-api
|
||||
bs4
|
||||
requests
|
||||
lxml
|
||||
zhconv
|
||||
thefuzz
|
||||
|
||||
|
||||
Reference in New Issue
Block a user