diff --git a/data/example-config.py b/data/example-config.py index 78fa1ccec..4bff88201 100644 --- a/data/example-config.py +++ b/data/example-config.py @@ -60,7 +60,7 @@ # "anon" : "False" }, "PTP": { - "useAPI": False, # Set to True if using PTP + "useAPI": False, # Set to True if using PTP "add_web_source_to_desc": True, "ApiUser": "ptp api user", "ApiKey": 'ptp api key', @@ -147,7 +147,7 @@ "api_key": "CBR api key", "announce_url": "https://capybarabr.com/announce/customannounceurl", # "anon" : False - }, + }, "LST": { "api_key": "LST api key", "announce_url": "https://lst.gg/announce/customannounceurl", @@ -179,7 +179,7 @@ "password": "password", "my_announce_url": "https://hdts-announce.ru/announce.php?pid=", # "anon" : "False" - "announce_url": "https://hdts-announce.ru/announce.php", #DO NOT EDIT THIS LINE + "announce_url": "https://hdts-announce.ru/announce.php", # DO NOT EDIT THIS LINE }, "OE": { "api_key": "OE api key", diff --git a/src/prep.py b/src/prep.py index 922c56096..33fa57016 100644 --- a/src/prep.py +++ b/src/prep.py @@ -70,6 +70,22 @@ def __init__(self, screens, img_host, config): self.img_host = img_host.lower() tmdb.API_KEY = config['DEFAULT']['tmdb_api'] + async def prompt_user_for_id_selection(self, blu_tmdb=None, blu_imdb=None, blu_tvdb=None, blu_filename=None, imdb=None): + if imdb: + imdb = str(imdb).zfill(7) # Convert to string and ensure IMDb ID is 7 characters long by adding leading zeros + console.print(f"[cyan]Found IMDb ID: https://www.imdb.com/title/tt{imdb}[/cyan]") + if blu_tmdb or blu_imdb or blu_tvdb: + if blu_imdb: + blu_imdb = str(blu_imdb).zfill(7) # Convert to string and ensure IMDb ID is 7 characters long by adding leading zeros + console.print(f"[cyan]Found the following IDs on BLU:[/cyan]") + console.print(f"TMDb ID: {blu_tmdb}") + console.print(f"IMDb ID: https://www.imdb.com/title/tt{blu_imdb}") + console.print(f"TVDb ID: {blu_tvdb}") + console.print(f"Filename: {blu_filename}") + + selection = input("Do you want to use this ID? (y/n): ").strip().lower() + return selection == 'y' + async def update_metadata_from_tracker(self, tracker_name, tracker_instance, meta, search_term, search_file_folder): tracker_key = tracker_name.lower() manual_key = f"{tracker_key}_manual" @@ -84,30 +100,37 @@ async def update_metadata_from_tracker(self, tracker_name, tracker_instance, met blu_tmdb, blu_imdb, blu_tvdb, blu_mal, blu_desc, blu_category, meta['ext_torrenthash'], blu_imagelist, blu_filename = await COMMON(self.config).unit3d_torrent_info("BLU", tracker_instance.torrent_url, tracker_instance.search_url, id=meta[tracker_key]) if blu_tmdb not in [None, '0'] or blu_imdb not in [None, '0'] or blu_tvdb not in [None, '0']: console.print(f"[green]Valid data found on {tracker_name}, setting meta values[/green]") - if blu_tmdb not in [None, '0']: - meta['tmdb_manual'] = blu_tmdb - if blu_imdb not in [None, '0']: - meta['imdb'] = str(blu_imdb) - if blu_tvdb not in [None, '0']: - meta['tvdb_id'] = blu_tvdb - if blu_mal not in [None, '0']: - meta['mal'] = blu_mal - if blu_desc not in [None, '0', '']: - meta['blu_desc'] = blu_desc - if blu_category.upper() in ['MOVIE', 'TV SHOW', 'FANRES']: - meta['category'] = 'TV' if blu_category.upper() == 'TV SHOW' else blu_category.upper() - if meta.get('image_list', []) == []: - meta['image_list'] = blu_imagelist - if blu_filename: - meta['blu_filename'] = blu_filename # Store the filename in meta for later use - found_match = True # Set flag if any relevant data is found + # Prompt user for selection + if await self.prompt_user_for_id_selection(blu_tmdb, blu_imdb, blu_tvdb, blu_filename): + if blu_tmdb not in [None, '0']: + meta['tmdb_manual'] = blu_tmdb + if blu_imdb not in [None, '0']: + meta['imdb'] = str(blu_imdb) + if blu_tvdb not in [None, '0']: + meta['tvdb_id'] = blu_tvdb + if blu_mal not in [None, '0']: + meta['mal'] = blu_mal + if blu_desc not in [None, '0', '']: + meta['blu_desc'] = blu_desc + if blu_category.upper() in ['MOVIE', 'TV SHOW', 'FANRES']: + meta['category'] = 'TV' if blu_category.upper() == 'TV SHOW' else blu_category.upper() + if meta.get('image_list', []) == []: + meta['image_list'] = blu_imagelist + if blu_filename: + meta['blu_filename'] = blu_filename # Store the filename in meta for later use + found_match = True # Set flag if any relevant data is found + else: + console.print(f"[yellow]User skipped the found ID on {tracker_name}[/yellow]") else: console.print(f"[yellow]No valid data found on {tracker_name}[/yellow]") else: meta['imdb'], meta['ext_torrenthash'] = await tracker_instance.get_imdb_from_torrent_id(meta[tracker_key]) if meta['imdb']: - console.print(f"[green]{tracker_name} IMDb ID found: {meta['imdb']}[/green]") - found_match = True + if await self.prompt_user_for_id_selection(imdb=meta['imdb']): + console.print(f"[green]{tracker_name} IMDb ID found: {meta['imdb']}[/green]") + found_match = True + else: + console.print(f"[yellow]User skipped the found IMDb ID on {tracker_name}[/yellow]") else: console.print(f"[yellow]No IMDb ID found on {tracker_name}[/yellow]") else: @@ -121,34 +144,39 @@ async def update_metadata_from_tracker(self, tracker_name, tracker_instance, met meta['tvdb_id'] = str(tvdb_id) if tvdb_id else meta.get('tvdb_id') meta['hdb_name'] = hdb_name elif tracker_name == "BLU": - # Attempt to search using the file name if ID is not available blu_tmdb, blu_imdb, blu_tvdb, blu_mal, blu_desc, blu_category, meta['ext_torrenthash'], blu_imagelist, blu_filename = await COMMON(self.config).unit3d_torrent_info("BLU", tracker_instance.torrent_url, tracker_instance.search_url, file_name=search_term) if blu_tmdb not in [None, '0'] or blu_imdb not in [None, '0'] or blu_tvdb not in [None, '0']: console.print(f"[green]Valid data found on {tracker_name} using file name, setting meta values[/green]") - if blu_tmdb not in [None, '0']: - meta['tmdb_manual'] = blu_tmdb - if blu_imdb not in [None, '0']: - meta['imdb'] = str(blu_imdb) - if blu_tvdb not in [None, '0']: - meta['tvdb_id'] = blu_tvdb - if blu_mal not in [None, '0']: - meta['mal'] = blu_mal - if blu_desc not in [None, '0', '']: - meta['blu_desc'] = blu_desc - if blu_category.upper() in ['MOVIE', 'TV SHOW', 'FANRES']: - meta['category'] = 'TV' if blu_category.upper() == 'TV SHOW' else blu_category.upper() - if meta.get('image_list', []) == []: - meta['image_list'] = blu_imagelist - if blu_filename: - meta['blu_filename'] = blu_filename # Store the filename in meta for later use - found_match = True + if await self.prompt_user_for_id_selection(blu_tmdb, blu_imdb, blu_tvdb, blu_filename): + if blu_tmdb not in [None, '0']: + meta['tmdb_manual'] = blu_tmdb + if blu_imdb not in [None, '0']: + meta['imdb'] = str(blu_imdb) + if blu_tvdb not in [None, '0']: + meta['tvdb_id'] = blu_tvdb + if blu_mal not in [None, '0']: + meta['mal'] = blu_mal + if blu_desc not in [None, '0', '']: + meta['blu_desc'] = blu_desc + if blu_category.upper() in ['MOVIE', 'TV SHOW', 'FANRES']: + meta['category'] = 'TV' if blu_category.upper() == 'TV SHOW' else blu_category.upper() + if meta.get('image_list', []) == []: + meta['image_list'] = blu_imagelist + if blu_filename: + meta['blu_filename'] = blu_filename # Store the filename in meta for later use + found_match = True + else: + console.print(f"[yellow]No valid data found on {tracker_name}[/yellow]") else: imdb = tracker_id = None if imdb: - console.print(f"[green]{tracker_name} IMDb ID found: {imdb}[/green]") - meta['imdb'] = str(imdb) - found_match = True + if await self.prompt_user_for_id_selection(imdb=imdb): + console.print(f"[green]{tracker_name} IMDb ID found: {imdb}[/green]") + meta['imdb'] = str(imdb) + found_match = True + else: + console.print(f"[yellow]User skipped the found IMDb ID on {tracker_name}[/yellow]") if tracker_id: meta[tracker_key] = tracker_id diff --git a/src/trackers/HDB.py b/src/trackers/HDB.py index 25136f5dc..a38ad377a 100644 --- a/src/trackers/HDB.py +++ b/src/trackers/HDB.py @@ -553,7 +553,7 @@ async def search_filename(self, search_term, search_file_folder): hdb_name = each['name'] hdb_torrenthash = each['hash'] hdb_id = each['id'] - console.print(f'[bold green]Matched release with HDB ID: [yellow]{hdb_id}[/yellow][/bold green]') + console.print(f'[bold green]Matched release with HDB ID: [yellow]https://hdbits.org/details.php?id={hdb_id}[/yellow][/bold green]') return hdb_imdb, hdb_tvdb, hdb_name, hdb_torrenthash, hdb_id except Exception as e: console.print_exception()