Skip to content

Commit

Permalink
Print links and allow skip ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Aug 30, 2024
1 parent 26956c9 commit 5caa9f5
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 44 deletions.
6 changes: 3 additions & 3 deletions data/example-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -179,7 +179,7 @@
"password": "password",
"my_announce_url": "https://hdts-announce.ru/announce.php?pid=<PASS_KEY/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",
Expand Down
108 changes: 68 additions & 40 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/trackers/HDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 5caa9f5

Please sign in to comment.