Skip to content

Commit

Permalink
Merge branch 'master' into descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Nov 1, 2024
2 parents 41c5815 + c3eea23 commit 48f5f4e
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/bbcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def clean_unit3d_description(self, desc, site):
bot_image_urls = [
"https://blutopia.xyz/favicon.ico", # Example bot image URL
"https://i.ibb.co/2NVWb0c/uploadrr.webp",
"https://blutopia/favicon.ico",
# Add any other known bot image URLs here
]
imagelist = [
Expand Down
28 changes: 25 additions & 3 deletions src/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ async def find_existing_torrent(self, meta):
torrenthash = None
if torrent_storage_dir is not None and os.path.exists(torrent_storage_dir):
if meta.get('torrenthash', None) is not None:
console.print("torrenthash:", torrenthash)
valid, torrent_path = await self.is_valid_torrent(meta, f"{torrent_storage_dir}/{meta['torrenthash']}.torrent", meta['torrenthash'], torrent_client, print_err=True)
if valid:
torrenthash = meta['torrenthash']
elif meta.get('ext_torrenthash', None) is not None:
console.print("ext_torrenthash:", meta.get('ext_torrenthash'))
valid, torrent_path = await self.is_valid_torrent(meta, f"{torrent_storage_dir}/{meta['ext_torrenthash']}.torrent", meta['ext_torrenthash'], torrent_client, print_err=True)
if valid:
torrenthash = meta['ext_torrenthash']
Expand All @@ -89,6 +91,7 @@ async def find_existing_torrent(self, meta):
if not torrenthash:
console.print("[bold yellow]No Valid .torrent found")
if not torrenthash:
console.print("No torrenthash in find_existing")
return None
torrent_path = f"{torrent_storage_dir}/{torrenthash}.torrent"
valid2, torrent_path = await self.is_valid_torrent(meta, torrent_path, torrenthash, torrent_client, print_err=False)
Expand All @@ -98,6 +101,7 @@ async def find_existing_torrent(self, meta):
return None

async def is_valid_torrent(self, meta, torrent_path, torrenthash, torrent_client, print_err=False):
console.print("We've moved into torrent validation")
valid = False
wrong_file = False

Expand Down Expand Up @@ -209,6 +213,8 @@ async def search_qbit_for_torrent(self, meta, client):
try:
qbt_client = qbittorrentapi.Client(host=client['qbit_url'], port=client['qbit_port'], username=client['qbit_user'], password=client['qbit_pass'], VERIFY_WEBUI_CERTIFICATE=client.get('VERIFY_WEBUI_CERTIFICATE', True))
qbt_client.auth_log_in()
if meta['debug']:
console.print("We logged into qbittorrent")
except qbittorrentapi.LoginFailed:
console.print("[bold red]INCORRECT QBIT LOGIN CREDENTIALS")
return None
Expand All @@ -230,22 +236,38 @@ async def search_qbit_for_torrent(self, meta, client):
for torrent in torrents:
try:
torrent_path = torrent.get('content_path', f"{torrent.save_path}{torrent.name}")
# console.print("Trying torrent_paths")
except AttributeError:
if meta['debug']:
console.print(torrent)
console.print_exception()
continue
if remote_path_map:
torrent_path = torrent_path.replace(remote_path, local_path)
# Replace remote path with local path only if not already mapped
if not torrent_path.startswith(local_path):
torrent_path = torrent_path.replace(remote_path, local_path)
if meta['debug']:
console.print("Replaced paths round 2:", torrent_path)

# Check if the local path was accidentally duplicated and correct it
if torrent_path.startswith(f"{local_path}/{local_path.split('/')[-1]}"):
torrent_path = torrent_path.replace(f"{local_path}/{local_path.split('/')[-1]}", local_path)
if meta['debug']:
console.print("Corrected duplicate in torrent path round 2:", torrent_path)

# Standardize path separators for the local OS
torrent_path = torrent_path.replace(os.sep, '/').replace('/', os.sep)
if meta['debug']:
console.print("Final torrent path after remote mapping round 2:", torrent_path)

if meta['is_disc'] in ("", None) and len(meta['filelist']) == 1:
if torrent_path == meta['filelist'][0] and len(torrent.files) == len(meta['filelist']):
if torrent_path.lower() == meta['filelist'][0].lower() and len(torrent.files) == len(meta['filelist']):
valid, torrent_path = await self.is_valid_torrent(meta, f"{torrent_storage_dir}/{torrent.hash}.torrent", torrent.hash, 'qbit', print_err=False)
if valid:
console.print(f"[green]Found a matching .torrent with hash: [bold yellow]{torrent.hash}")
return torrent.hash
elif meta['path'] == torrent_path:

elif os.path.normpath(meta['path']).lower() == os.path.normpath(torrent_path).lower():
valid, torrent_path = await self.is_valid_torrent(meta, f"{torrent_storage_dir}/{torrent.hash}.torrent", torrent.hash, 'qbit', print_err=False)
if valid:
console.print(f"[green]Found a matching .torrent with hash: [bold yellow]{torrent.hash}")
Expand Down
114 changes: 93 additions & 21 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,57 +564,129 @@ async def gather_prep(self, meta, mode):
if match:
found_match = True
else:
timeout_duration = 2 # seconds
# Process all trackers with API = true if no specific tracker is set in meta
default_trackers = self.config['TRACKERS'].get('default_trackers', "").split(", ")

if "PTP" in default_trackers and not found_match:
if str(self.config['TRACKERS'].get('PTP', {}).get('useAPI')).lower() == "true":
ptp = PTP(config=self.config)
meta, match = await self.update_metadata_from_tracker('PTP', ptp, meta, search_term, search_file_folder)
if match:
found_match = True
try:
meta, match = await asyncio.wait_for(
self.update_metadata_from_tracker('PTP', ptp, meta, search_term, search_file_folder),
timeout=timeout_duration
)
if match:
found_match = True
except asyncio.TimeoutError:
print("PTP tracker request timed out.")
except aiohttp.ClientSSLError:
print("PTP tracker request failed due to SSL error.")
except requests.exceptions.ConnectionError as conn_err:
print(f"PTP tracker request failed due to connection error: {conn_err}")

if not meta['is_disc']:
if "BLU" in default_trackers and not found_match:
if str(self.config['TRACKERS'].get('BLU', {}).get('useAPI')).lower() == "true":
blu = BLU(config=self.config)
meta, match = await self.update_metadata_from_tracker('BLU', blu, meta, search_term, search_file_folder)
if match:
found_match = True
try:
meta, match = await asyncio.wait_for(
self.update_metadata_from_tracker('BLU', blu, meta, search_term, search_file_folder),
timeout=timeout_duration
)
if match:
found_match = True
except asyncio.TimeoutError:
print("BLU tracker request timed out.")
except aiohttp.ClientSSLError:
print("BLU tracker request failed due to SSL error.")
except requests.exceptions.ConnectionError as conn_err:
print(f"BLU tracker request failed due to connection error: {conn_err}")

if "AITHER" in default_trackers and not found_match:
if str(self.config['TRACKERS'].get('AITHER', {}).get('useAPI')).lower() == "true":
aither = AITHER(config=self.config)
meta, match = await self.update_metadata_from_tracker('AITHER', aither, meta, search_term, search_file_folder)
if match:
found_match = True
try:
meta, match = await asyncio.wait_for(
self.update_metadata_from_tracker('AITHER', aither, meta, search_term, search_file_folder),
timeout=timeout_duration
)
if match:
found_match = True
except asyncio.TimeoutError:
print("AITHER tracker request timed out.")
except aiohttp.ClientSSLError:
print("AITHER tracker request failed due to SSL error.")
except requests.exceptions.ConnectionError as conn_err:
print(f"AITHER tracker request failed due to connection error: {conn_err}")

if "LST" in default_trackers and not found_match:
if str(self.config['TRACKERS'].get('LST', {}).get('useAPI')).lower() == "true":
lst = LST(config=self.config)
meta, match = await self.update_metadata_from_tracker('LST', lst, meta, search_term, search_file_folder)
if match:
found_match = True
try:
meta, match = await asyncio.wait_for(
self.update_metadata_from_tracker('LST', lst, meta, search_term, search_file_folder),
timeout=timeout_duration
)
if match:
found_match = True
except asyncio.TimeoutError:
print("LST tracker request timed out.")
except aiohttp.ClientSSLError:
print("LST tracker request failed due to SSL error.")
except requests.exceptions.ConnectionError as conn_err:
print(f"LST tracker request failed due to connection error: {conn_err}")

if "OE" in default_trackers and not found_match:
if str(self.config['TRACKERS'].get('OE', {}).get('useAPI')).lower() == "true":
oe = OE(config=self.config)
meta, match = await self.update_metadata_from_tracker('OE', oe, meta, search_term, search_file_folder)
if match:
found_match = True
try:
meta, match = await asyncio.wait_for(
self.update_metadata_from_tracker('OE', oe, meta, search_term, search_file_folder),
timeout=timeout_duration
)
if match:
found_match = True
except asyncio.TimeoutError:
print("OE tracker request timed out.")
except aiohttp.ClientSSLError:
print("OE tracker request failed due to SSL error.")
except requests.exceptions.ConnectionError as conn_err:
print(f"OE tracker request failed due to connection error: {conn_err}")

if "TIK" in default_trackers and not found_match:
if str(self.config['TRACKERS'].get('TIK', {}).get('useAPI')).lower() == "true":
tik = TIK(config=self.config)
meta, match = await self.update_metadata_from_tracker('TIK', tik, meta, search_term, search_file_folder)
if match:
found_match = True
try:
meta, match = await asyncio.wait_for(
self.update_metadata_from_tracker('TIK', tik, meta, search_term, search_file_folder),
timeout=timeout_duration
)
if match:
found_match = True
except asyncio.TimeoutError:
print("TIK tracker request timed out.")
except aiohttp.ClientSSLError:
print("TIK tracker request failed due to SSL error.")
except requests.exceptions.ConnectionError as conn_err:
print(f"TIK tracker request failed due to connection error: {conn_err}")

if "HDB" in default_trackers and not found_match:
if str(self.config['TRACKERS'].get('HDB', {}).get('useAPI')).lower() == "true":
hdb = HDB(config=self.config)
meta, match = await self.update_metadata_from_tracker('HDB', hdb, meta, search_term, search_file_folder)
if match:
found_match = True
try:
meta, match = await asyncio.wait_for(
self.update_metadata_from_tracker('HDB', hdb, meta, search_term, search_file_folder),
timeout=timeout_duration
)
if match:
found_match = True
except asyncio.TimeoutError:
print("HDB tracker request timed out.")
except aiohttp.ClientSSLError:
print("HDB tracker request failed due to SSL error.")
except requests.exceptions.ConnectionError as conn_err:
print(f"HDB tracker request failed due to connection error: {conn_err}")

if not found_match:
console.print("[yellow]No matches found on any trackers.[/yellow]")
Expand Down
4 changes: 4 additions & 0 deletions src/vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

core = vs.core

# core.std.LoadPlugin(path="/usr/local/lib/vapoursynth/libffms2.so")
# core.std.LoadPlugin(path="/usr/local/lib/vapoursynth/libsub.so")
# core.std.LoadPlugin(path="/usr/local/lib/vapoursynth/libimwri.so")


def CustomFrameInfo(clip, text):
def FrameProps(n, f, clip):
Expand Down

0 comments on commit 48f5f4e

Please sign in to comment.