From 66bd0aa0db8eff36c28ca7da9f7400edcd8e003b Mon Sep 17 00:00:00 2001 From: Audionut Date: Sun, 24 Nov 2024 19:27:54 +1000 Subject: [PATCH] Faster skips --- src/trackers/ANT.py | 7 ++++--- src/trackers/OE.py | 7 ++++--- src/trackers/RF.py | 19 +++++++++--------- src/trackers/RTF.py | 16 ++++++++------- src/trackers/ULCX.py | 7 ++++--- upload.py | 47 ++++++++++++++++++++++++-------------------- 6 files changed, 56 insertions(+), 47 deletions(-) diff --git a/src/trackers/ANT.py b/src/trackers/ANT.py index 80f7e0f4..c6c8300c 100644 --- a/src/trackers/ANT.py +++ b/src/trackers/ANT.py @@ -61,9 +61,6 @@ async def get_flags(self, meta): return flags async def upload(self, meta, disctype): - if meta.get('category') == "TV": - console.print('[bold red]This site only ALLOWS Movies.') - return common = COMMON(config=self.config) torrent_filename = "BASE" torrent_path = f"{meta['base_dir']}/tmp/{meta['uuid']}/BASE.torrent" @@ -145,6 +142,10 @@ async def edit_desc(self, meta): return async def search_existing(self, meta, disctype): + if meta.get('category') == "TV": + console.print('[bold red]This site only ALLOWS Movies.') + meta['skipping'] = "ANT" + return dupes = [] console.print("[yellow]Searching for existing torrents on site...") params = { diff --git a/src/trackers/OE.py b/src/trackers/OE.py index d71d7b26..f4d118a0 100644 --- a/src/trackers/OE.py +++ b/src/trackers/OE.py @@ -47,9 +47,6 @@ def __init__(self, config): pass async def upload(self, meta, disctype): - if 'concert' in meta['keywords']: - console.print('[bold red]Concerts not allowed.') - return common = COMMON(config=self.config) await common.edit_torrent(meta, self.tracker, self.source_flag) await self.edit_desc(meta, self.tracker, self.signature) @@ -314,6 +311,10 @@ def process_languages(tracks): return async def search_existing(self, meta, disctype): + if 'concert' in meta['keywords']: + console.print('[bold red]Concerts not allowed.') + meta['skipping'] = "OE" + return dupes = [] console.print("[yellow]Searching for existing torrents on site...") params = { diff --git a/src/trackers/RF.py b/src/trackers/RF.py index 3c0dc993..a9078754 100644 --- a/src/trackers/RF.py +++ b/src/trackers/RF.py @@ -33,13 +33,6 @@ def __init__(self, config): pass async def upload(self, meta, disctype): - disallowed_keywords = {'XXX', 'Erotic'} - if any(keyword in meta['keywords'] for keyword in disallowed_keywords): - console.print('[bold red]Concerts not allowed.') - return - if meta.get('category') == "TV": - console.print('[bold red]This site only ALLOWS Movies.') - return common = COMMON(config=self.config) await common.edit_torrent(meta, self.tracker, self.source_flag) await common.unit3d_edit_desc(meta, self.tracker, self.forum_link) @@ -169,6 +162,15 @@ async def get_res_id(self, resolution): return resolution_id async def search_existing(self, meta, disctype): + disallowed_keywords = {'XXX', 'Erotic'} + if any(keyword in meta['keywords'] for keyword in disallowed_keywords): + console.print('[bold red]Erotic not allowed.') + meta['skipping'] = "RF" + return + if meta.get('category') == "TV": + console.print('[bold red]This site only ALLOWS Movies.') + meta['skipping'] = "RF" + return dupes = [] console.print("[yellow]Searching for existing torrents on site...") params = { @@ -179,9 +181,6 @@ async def search_existing(self, meta, disctype): 'resolutions[]': await self.get_res_id(meta['resolution']), 'name': "" } - if meta['category'] == 'TV': - console.print('[bold red]Unable to search site for TV as this site only ALLOWS Movies') - # params['name'] = f"{meta.get('season', '')}{meta.get('episode', '')}" if meta.get('edition', "") != "": params['name'] = params['name'] + meta['edition'] try: diff --git a/src/trackers/RTF.py b/src/trackers/RTF.py index 485c886c..cb146e58 100644 --- a/src/trackers/RTF.py +++ b/src/trackers/RTF.py @@ -30,13 +30,6 @@ def __init__(self, config): pass async def upload(self, meta, disctype): - disallowed_keywords = {'XXX', 'Erotic'} - if any(keyword in meta['keywords'] for keyword in disallowed_keywords): - console.print('[bold red]Concerts not allowed.') - return - if datetime.date.today().year - meta['year'] <= 9: - console.print("[red]ERROR: Not uploading!\nMust be older than 10 Years as per rules") - return common = COMMON(config=self.config) await common.edit_torrent(meta, self.tracker, self.source_flag) await common.unit3d_edit_desc(meta, self.tracker, self.forum_link) @@ -97,6 +90,15 @@ async def upload(self, meta, disctype): console.print(json_data) async def search_existing(self, meta, disctype): + disallowed_keywords = {'XXX', 'Erotic'} + if any(keyword in meta['keywords'] for keyword in disallowed_keywords): + console.print('[bold red]XXX not allowed.') + meta['skipping'] = "RTF" + return + if datetime.date.today().year - meta['year'] <= 9: + console.print("[red]ERROR: Not uploading!\nMust be older than 10 Years as per rules") + meta['skipping'] = "RTF" + return dupes = [] console.print("[yellow]Searching for existing torrents on site...") headers = { diff --git a/src/trackers/ULCX.py b/src/trackers/ULCX.py index 9b66c685..1db2d1f7 100644 --- a/src/trackers/ULCX.py +++ b/src/trackers/ULCX.py @@ -63,9 +63,6 @@ async def get_res_id(self, resolution): return resolution_id async def upload(self, meta, disctype): - if 'concert' in meta['keywords']: - console.print('[bold red]Concerts not allowed.') - return common = COMMON(config=self.config) await common.edit_torrent(meta, self.tracker, self.source_flag) cat_id = await self.get_cat_id(meta['category']) @@ -156,6 +153,10 @@ async def upload(self, meta, disctype): open_torrent.close() async def search_existing(self, meta, disctype): + if 'concert' in meta['keywords']: + console.print('[bold red]Concerts not allowed.') + meta['skipping'] = "ULCX" + return dupes = [] console.print("[yellow]Searching for existing torrents on site...") params = { diff --git a/upload.py b/upload.py index fa638865..718572ba 100644 --- a/upload.py +++ b/upload.py @@ -507,19 +507,21 @@ async def check_mod_q_and_draft(tracker_class, meta, debug, disctype): continue dupes = await tracker_class.search_existing(meta, disctype) - dupes = await common.filter_dupes(dupes, meta) - meta = dupe_check(dupes, meta) - - # Proceed with upload if the meta is set to upload - if meta.get('upload', False): - await tracker_class.upload(meta, disctype) - perm = config['DEFAULT'].get('get_permalink', False) - if perm: - # need a wait so we don't race the api - await asyncio.sleep(5) - await tracker_class.search_torrent_page(meta, disctype) - await asyncio.sleep(0.5) - await client.add_to_client(meta, tracker_class.tracker) + if meta['skipping'] is None: + dupes = await common.filter_dupes(dupes, meta) + meta = dupe_check(dupes, meta) + + # Proceed with upload if the meta is set to upload + if meta.get('upload', False): + await tracker_class.upload(meta, disctype) + perm = config['DEFAULT'].get('get_permalink', False) + if perm: + # need a wait so we don't race the api + await asyncio.sleep(5) + await tracker_class.search_torrent_page(meta, disctype) + await asyncio.sleep(0.5) + await client.add_to_client(meta, tracker_class.tracker) + meta['skipping'] = None if tracker in other_api_trackers: tracker_class = tracker_class_map[tracker](config=config) @@ -557,15 +559,18 @@ async def check_mod_q_and_draft(tracker_class, meta, debug, disctype): await tracker_class.api_test(meta) dupes = await tracker_class.search_existing(meta, disctype) - dupes = await common.filter_dupes(dupes, meta) - meta = dupe_check(dupes, meta) + if meta['skipping'] is None: + dupes = await common.filter_dupes(dupes, meta) + meta = dupe_check(dupes, meta) - # Proceed with upload if the meta is set to upload - if tracker == "TL" or meta.get('upload', False): - await tracker_class.upload(meta, disctype) - if tracker == 'SN': - await asyncio.sleep(16) - await client.add_to_client(meta, tracker_class.tracker) + if meta['skipping'] is None: + # Proceed with upload if the meta is set to upload + if tracker == "TL" or meta.get('upload', False): + await tracker_class.upload(meta, disctype) + if tracker == 'SN': + await asyncio.sleep(16) + await client.add_to_client(meta, tracker_class.tracker) + meta['skipping'] = None if tracker in http_trackers: tracker_class = tracker_class_map[tracker](config=config)