[O] Reuse existing
This commit is contained in:
+21
-4
@@ -80,6 +80,24 @@ def process_imdb_workflow(imdb_id: str, dl_dir: str = "/data/QB", jellyfin_base_
|
||||
else:
|
||||
jellyfin_dir = f"{jellyfin_base_dir}/Movie"
|
||||
|
||||
print(f"\n=== [0.5] Checking if torrent already exists in qBittorrent ===")
|
||||
qb = get_qb_client()
|
||||
jellyfin_base = Path(jellyfin_dir) / f"{title_dir} [{imdb_id}]"
|
||||
new_name = f"{year} {title} [{imdb_id}]".strip()
|
||||
|
||||
existing_torrents = qb.torrents_info()
|
||||
existing_t_hash = None
|
||||
for t in existing_torrents:
|
||||
if f"[{imdb_id}]" in t.name:
|
||||
existing_t_hash = t.hash
|
||||
break
|
||||
|
||||
hashes_to_process = []
|
||||
|
||||
if existing_t_hash:
|
||||
print(f"Found existing torrent with hash {existing_t_hash}, skipping search and download.")
|
||||
hashes_to_process.append((existing_t_hash, "existing"))
|
||||
else:
|
||||
print(f"\n=== [1] Searching Torrents for {imdb_id} ===")
|
||||
imdb_url = f"https://www.imdb.com/title/{imdb_id}/"
|
||||
search_res = search_mteam_torrents(imdb_url)
|
||||
@@ -114,9 +132,6 @@ def process_imdb_workflow(imdb_id: str, dl_dir: str = "/data/QB", jellyfin_base_
|
||||
print("No torrents selected.")
|
||||
return
|
||||
|
||||
qb = get_qb_client()
|
||||
jellyfin_base = Path(jellyfin_dir) / f"{title_dir} [{imdb_id}]"
|
||||
|
||||
for tid in selected_ids:
|
||||
print(f"\n=== [3] Downloading .torrent for ID: {tid} ===")
|
||||
torrent_bytes = generate_mteam_download_token(tid)
|
||||
@@ -136,7 +151,6 @@ def process_imdb_workflow(imdb_id: str, dl_dir: str = "/data/QB", jellyfin_base_
|
||||
|
||||
print(f"Tracking torrent Hash: {t_hash}")
|
||||
|
||||
new_name = f"{year} {title}".strip()
|
||||
rename_torrent_and_folder(qb, t_hash, new_name)
|
||||
|
||||
while True:
|
||||
@@ -156,6 +170,9 @@ def process_imdb_workflow(imdb_id: str, dl_dir: str = "/data/QB", jellyfin_base_
|
||||
time.sleep(5)
|
||||
print("Download complete!")
|
||||
|
||||
hashes_to_process.append((t_hash, tid))
|
||||
|
||||
for t_hash, tid in hashes_to_process:
|
||||
print(f"\n=== [6] Generating rename mapping using LLM ===")
|
||||
file_tree = get_torrent_file_tree(qb, t_hash)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user