From 53727f36fc8743cfce7f78a2b5287fa1eb8c04c6 Mon Sep 17 00:00:00 2001 From: Audionut Date: Sun, 8 Sep 2024 00:21:32 +1000 Subject: [PATCH] Add OE filename/description parsing --- src/args.py | 14 ++++++++++++++ src/prep.py | 19 ++++++++++++++----- src/trackers/AITHER.py | 1 + src/trackers/COMMON.py | 3 ++- src/trackers/LST.py | 1 + src/trackers/OE.py | 1 + 6 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/args.py b/src/args.py index 58bf929c4..988c22715 100644 --- a/src/args.py +++ b/src/args.py @@ -46,6 +46,7 @@ def parse(self, args, meta): parser.add_argument('-blu', '--blu', nargs='*', required=False, help="BLU torrent id/link", type=str) parser.add_argument('-aither', '--aither', nargs='*', required=False, help="Aither torrent id/link", type=str) parser.add_argument('-lst', '--lst', nargs='*', required=False, help="LST torrent id/link", type=str) + parser.add_argument('-oe', '--oe', nargs='*', required=False, help="OE torrent id/link", type=str) parser.add_argument('-hdb', '--hdb', nargs='*', required=False, help="HDB torrent id/link", type=str) parser.add_argument('-d', '--desc', nargs='*', required=False, help="Custom Description (string)") parser.add_argument('-pb', '--desclink', nargs='*', required=False, help="Custom Description (link to hastebin/pastebin)") @@ -165,6 +166,19 @@ def parse(self, args, meta): console.print('[red]Continuing without --lst') else: meta['lst'] = value2 + elif key == 'oe': + if value2.startswith('http'): + parsed = urllib.parse.urlparse(value2) + try: + oepath = parsed.path + if oepath.endswith('/'): + oepath = oepath[:-1] + meta['oe'] = oepath.split('/')[-1] + except Exception: + console.print('[red]Unable to parse id from url') + console.print('[red]Continuing without --oe') + else: + meta['oe'] = value2 elif key == 'hdb': if value2.startswith('http'): parsed = urllib.parse.urlparse(value2) diff --git a/src/prep.py b/src/prep.py index f93e12faa..b09f485ef 100644 --- a/src/prep.py +++ b/src/prep.py @@ -6,6 +6,7 @@ from src.trackers.BLU import BLU from src.trackers.AITHER import AITHER from src.trackers.LST import LST +from src.trackers.OE import OE from src.trackers.HDB import HDB from src.trackers.COMMON import COMMON @@ -155,7 +156,7 @@ async def update_metadata_from_tracker(self, tracker_name, tracker_instance, met manual_key = f"{tracker_key}_manual" found_match = False - if tracker_name in ["BLU", "AITHER", "LST"]: # Example for UNIT3D trackers + if tracker_name in ["BLU", "AITHER", "LST", "OE"]: if meta.get(tracker_key) is not None: console.print(f"[cyan]{tracker_name} ID found in meta, reusing existing ID: {meta[tracker_key]}[/cyan]") tracker_data = await COMMON(self.config).unit3d_torrent_info( @@ -446,6 +447,8 @@ async def gather_prep(self, meta, mode): specific_tracker = 'AITHER' elif meta.get('lst'): specific_tracker = 'LST' + elif meta.get('oe'): + specific_tracker = 'OE' # If a specific tracker is found, only process that one if specific_tracker: @@ -475,6 +478,12 @@ async def gather_prep(self, meta, mode): if match: found_match = True + elif specific_tracker == 'OE' and 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 + elif specific_tracker == 'HDB' and 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) @@ -1324,8 +1333,8 @@ def screenshots(self, path, filename, folder_id, base_dir, meta, num_screens=Non .global_args('-loglevel', loglevel) .run(quiet=debug) ) - except Exception: - console.print(traceback.format_exc()) + except (KeyboardInterrupt, Exception): + sys.exit(1) self.optimize_images(image_path) if os.path.getsize(Path(image_path)) <= 75000: @@ -1394,8 +1403,8 @@ def optimize_images(self, image): oxipng.optimize(image, level=6) else: oxipng.optimize(image, level=3) - except Exception: - pass + except (KeyboardInterrupt, Exception): + sys.exit(1) return """ diff --git a/src/trackers/AITHER.py b/src/trackers/AITHER.py index 0dc0c05ab..7da76fe81 100644 --- a/src/trackers/AITHER.py +++ b/src/trackers/AITHER.py @@ -24,6 +24,7 @@ def __init__(self, config): self.source_flag = 'Aither' self.search_url = 'https://aither.cc/api/torrents/filter' self.upload_url = 'https://aither.cc/api/torrents/upload' + self.torrent_url = 'https://aither.cc/api/torrents/' self.signature = "\n[center][url=https://aither.cc/forums/topics/1349/posts/24958]Created by L4G's Upload Assistant[/url][/center]" self.banned_groups = ['4K4U', 'AROMA', 'd3g', 'edge2020', 'EMBER', 'EVO', 'FGT', 'FreetheFish', 'Hi10', 'HiQVE', 'ION10', 'iVy', 'Judas', 'LAMA', 'MeGusta', 'nikt0', 'OEPlus', 'OFT', 'OsC', 'PYC', 'QxR', 'Ralphy', 'RARBG', 'RetroPeeps', 'SAMPA', 'Sicario', 'Silence', 'SkipTT', 'SPDVD', 'STUTTERSHIT', 'SWTYBLZ', 'TAoE', 'TGx', 'Tigole', 'TSP', 'TSPxL', 'VXT', 'Weasley[HONE]', diff --git a/src/trackers/COMMON.py b/src/trackers/COMMON.py index b9a9270d9..19cc873ce 100644 --- a/src/trackers/COMMON.py +++ b/src/trackers/COMMON.py @@ -197,11 +197,12 @@ async def unit3d_torrent_info(self, tracker, torrent_url, search_url, id=None, f return None, None, None, None, None, None, None, None, None response = requests.get(url=url, params=params) + # console.print(f"[blue]Raw API Response: {response}[/blue]") try: json_response = response.json() - # console.print(f"[blue]Raw API Response: {json_response}[/blue]") + # console.print(f"[blue]Raw API Response: {json_response}[/blue]", markup=False) except ValueError: return None, None, None, None, None, None, None, None, None diff --git a/src/trackers/LST.py b/src/trackers/LST.py index 10f667251..7278f7ed4 100644 --- a/src/trackers/LST.py +++ b/src/trackers/LST.py @@ -24,6 +24,7 @@ def __init__(self, config): self.source_flag = 'LST.GG' self.upload_url = 'https://lst.gg/api/torrents/upload' self.search_url = 'https://lst.gg/api/torrents/filter' + self.torrent_url = 'https://lst.gg/api/torrents/' self.signature = "\n[center][url=https://github.com/Audionut/Upload-Assistant]Created by L4G's Upload Assistant[/url][/center]" self.banned_groups = ['aXXo', 'BRrip', 'CM8', 'CrEwSaDe', 'CTFOH', 'DNL', 'FaNGDiNG0', 'HD2DVD', 'HDTime', 'ION10', 'iPlanet', 'KiNGDOM', 'mHD', 'mSD', 'nHD', 'nikt0', 'nSD', 'NhaNc3', 'OFT', 'PRODJi', 'SANTi', 'STUTTERSHIT', 'ViSION', 'VXT', 'WAF', diff --git a/src/trackers/OE.py b/src/trackers/OE.py index a1b4d3156..8cb819518 100644 --- a/src/trackers/OE.py +++ b/src/trackers/OE.py @@ -23,6 +23,7 @@ def __init__(self, config): self.source_flag = 'OE' self.search_url = 'https://onlyencodes.cc/api/torrents/filter' self.upload_url = 'https://onlyencodes.cc/api/torrents/upload' + self.torrent_url = 'https://onlyencodes.cc/api/torrents/' self.signature = "\n[center][url=https://github.com/Audionut/Upload-Assistant]Created by L4G's Upload Assistant[/url][/center]" self.banned_groups = ['0neshot', '3LT0N', '4K4U', '4yEo', '$andra', '[Oj]', 'AFG', 'AkihitoSubs', 'AniHLS', 'Anime Time', 'AnimeRG', 'AniURL', 'AR', 'AROMA', 'ASW', 'aXXo', 'BakedFish', 'BiTOR', 'BHDStudio', 'BRrip', 'bonkai', 'Cleo', 'CM8', 'C4K', 'CrEwSaDe', 'core', 'd3g', 'DDR', 'DeadFish', 'DeeJayAhmed', 'DNL', 'ELiTE', 'EMBER', 'eSc', 'EVO', 'EZTV', 'FaNGDiNG0', 'FGT', 'fenix', 'FUM', 'FRDS', 'FROZEN', 'GalaxyTV', 'GalaxyRG', 'GERMini', 'Grym', 'GrymLegacy', 'HAiKU', 'HD2DVD', 'HDTime', 'Hi10', 'ION10', 'iPlanet', 'JacobSwaggedUp', 'JIVE', 'Judas', 'KiNGDOM', 'LAMA', 'Leffe', 'LiGaS', 'LOAD', 'LycanHD', 'MeGusta,' 'MezRips,' 'mHD,' 'Mr.Deadpool', 'mSD', 'NemDiggers', 'neoHEVC', 'NeXus', 'NhaNc3', 'nHD', 'nikt0', 'nSD', 'NhaNc3', 'NOIVTC', 'pahe.in', 'PlaySD', 'playXD', 'PRODJi', 'ProRes', 'project-gxs', 'PSA', 'QaS', 'Ranger', 'RAPiDCOWS', 'RARBG', 'Raze', 'RCDiVX', 'RDN', 'Reaktor', 'REsuRRecTioN', 'RMTeam', 'ROBOTS', 'rubix', 'SANTi', 'SHUTTERSHIT', 'SpaceFish', 'SPASM', 'SSA', 'TBS', 'Telly,' 'Tenrai-Sensei,' 'TERMiNAL,' 'TM', 'topaz', 'TSP', 'TSPxL', 'Trix', 'URANiME', 'UTR', 'VipapkSudios', 'ViSION', 'WAF', 'Wardevil', 'x0r', 'xRed', 'XS', 'YakuboEncodes', 'YIFY', 'YTS', 'YuiSubs', 'ZKBL', 'ZmN', 'ZMNT'] pass