Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Sep 1, 2024
1 parent 07432de commit 4aa0d19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/trackers/HDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ async def search_filename(self, search_term, search_file_folder, meta):
url = "https://hdbits.org/api/torrents"

# Handle disc case
if search_file_folder == 'folder' and meta.get('is_disc'):
if search_file_folder == 'folder' and meta.get('is_disc'):
bd_summary_path = os.path.join(meta['base_dir'], 'tmp', meta['uuid'], 'BD_SUMMARY_00.txt')
bd_summary = None

Expand Down
22 changes: 11 additions & 11 deletions src/trackers/PTP.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ async def get_ptp_id_imdb(self, search_term, search_file_folder, meta):
response = requests.get(url, params=params, headers=headers)
await asyncio.sleep(1)
console.print(f"[green]Searching PTP for: [bold yellow]{filename}[/bold yellow]")

try:
if response.status_code == 200:
response = response.json()
# console.print(f"[blue]Raw API Response: {response}[/blue]")

if int(response['TotalResults']) >= 1:
for movie in response['Movies']:
if len(movie['Torrents']) >= 1:
Expand All @@ -113,43 +113,43 @@ async def get_ptp_id_imdb(self, search_term, search_file_folder, meta):
ptp_torrent_id = torrent['Id']
dummy, ptp_torrent_hash, *_ = await self.get_imdb_from_torrent_id(ptp_torrent_id)
console.print(f'[bold green]Matched release with PTP ID: [yellow]{ptp_torrent_id}[/yellow][/bold green]')

# Call get_torrent_info and print the results
tinfo = await self.get_torrent_info(imdb_id, meta)
console.print(f"[cyan]Torrent Info: {tinfo}[/cyan]")

return imdb_id, ptp_torrent_id, ptp_torrent_hash

# If no match in filelist > path, check directly in filepath
if torrent.get('FilePath') == filename:
imdb_id = movie['ImdbId']
ptp_torrent_id = torrent['Id']
dummy, ptp_torrent_hash, *_ = await self.get_imdb_from_torrent_id(ptp_torrent_id)
console.print(f'[bold green]Matched release with PTP ID: [yellow]{ptp_torrent_id}[/yellow][/bold green]')

# Call get_torrent_info and print the results
tinfo = await self.get_torrent_info(imdb_id, meta)
console.print(f"[cyan]Torrent Info: {tinfo}[/cyan]")

return imdb_id, ptp_torrent_id, ptp_torrent_hash

console.print(f'[yellow]Could not find any release matching [bold yellow]{filename}[/bold yellow] on PTP')
return None, None, None

elif response.status_code in [400, 401, 403]:
console.print(f"[bold red]PTP: {response.text}")
return None, None, None

elif response.status_code == 503:
console.print("[bold yellow]PTP Unavailable (503)")
return None, None, None

else:
return None, None, None

except Exception as e:
console.print(f'[red]An error occurred: {str(e)}[/red]')

console.print(f'[yellow]Could not find any release matching [bold yellow]{filename}[/bold yellow] on PTP')
return None, None, None

Expand Down

0 comments on commit 4aa0d19

Please sign in to comment.