From 3d321071e9243e85787fe4df249f2802854a0552 Mon Sep 17 00:00:00 2001 From: Audionut Date: Mon, 28 Oct 2024 09:21:20 +1000 Subject: [PATCH] Remove dead TDC fixes https://github.com/Audionut/Upload-Assistant/issues/110 --- README.md | 2 +- data/example-config.py | 9 +- src/trackers/TDC.py | 210 ----------------------------------------- upload.py | 29 +++--- 4 files changed, 21 insertions(+), 229 deletions(-) delete mode 100644 src/trackers/TDC.py diff --git a/README.md b/README.md index ac7cfe01f..396951237 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ A simple tool to take the work out of uploading. - Can re-use existing torrents instead of hashing new - Generates proper name for your upload using Mediainfo/BDInfo and TMDb/IMDb conforming to site rules - Checks for existing releases already on site - - Uploads to PTP/BLU/BHD/Aither/THR/STC/R4E(limited)/STT/HP/ACM/LCD/LST/NBL/ANT/FL/HUNO/RF/SN/RTF/OTW/FNP/CBR/UTP/HDB/AL/SHRI/OE/TL/BHDTV/HDT/JPTV/LT/MTV/PTER/TDC/TTG/UTP/PSS/ULCX/SPD/TVC + - Uploads to ACM/Aither/AL/ANT/BHD/BHDTV/BLU/CBR/FNP/FL/HDB/HDT/HP/HUNO/JPTV/LCD/LST/LT/MTV/NBL/OE/OTW/PSS/PTP/PTER/RF/R4E(limited)/RTF/SHRI/SN/SPD/STC/STT/TLC/THR/TL/TVC/TTG/ULCX/UTP - Adds to your client with fast resume, seeding instantly (rtorrent/qbittorrent/deluge/watch folder) - ALL WITH MINIMAL INPUT! - Currently works with .mkv/.mp4/Blu-ray/DVD/HD-DVDs diff --git a/data/example-config.py b/data/example-config.py index fd8dcdb28..e5690839e 100644 --- a/data/example-config.py +++ b/data/example-config.py @@ -56,9 +56,9 @@ "TRACKERS": { # Which trackers do you want to upload to? - # Available tracker: ACM, AITHER, AL, ANT, BHD, BHDTV, BLU, CBR, FNP, HDB, HDT, HP, HUNO, LCD, LST, LT, MTV, NBL, OE, OTW, PSS, PTER, PTP, R4E, RF, RTF, SN, STC, STT, THR, TDC, TIK, TL, ULCX, UTP + # Available tracker: ACM, AITHER, AL, ANT, BHD, BHDTV, BLU, CBR, FNP, HDB, HDT, HP, HUNO, LCD, LST, LT, MTV, NBL, OE, OTW, PSS, PTER, PTP, R4E, RF, RTF, SN, STC, STT, THR, TIK, TL, ULCX, UTP # Remove the trackers from the default_trackers list that are not used, to save being asked everytime - "default_trackers": "ACM, AITHER, AL, ANT, BHD, BHDTV, BLU, CBR, FNP, HDB, HDT, HP, HUNO, LCD, LST, LT, MTV, NBL, OE, OTW, PSS, PTER, PTP, R4E, RF, RTF, SN, STC, STT, THR, TDC, TIK, TL, ULCX, UTP", + "default_trackers": "ACM, AITHER, AL, ANT, BHD, BHDTV, BLU, CBR, FNP, HDB, HDT, HP, HUNO, LCD, LST, LT, MTV, NBL, OE, OTW, PSS, PTER, PTP, R4E, RF, RTF, SN, STC, STT, THR, TIK, TL, ULCX, UTP", "ACM": { "api_key": "ACM api key", @@ -254,11 +254,6 @@ "announce_url": "https://stt.xyz/announce/customannounceurl", # "anon" : False }, - "TDC": { - "api_key": "TDC api key", - "announce_url": "https://thedarkcommunity.cc/announce/customannounceurl", - # "anon" : "False" - }, "THR": { "username": "username", "password": "password", diff --git a/src/trackers/TDC.py b/src/trackers/TDC.py deleted file mode 100644 index 54f7a98fe..000000000 --- a/src/trackers/TDC.py +++ /dev/null @@ -1,210 +0,0 @@ -# -*- coding: utf-8 -*- -# import discord -import asyncio -import requests -from str2bool import str2bool -import bencodepy - -from src.trackers.COMMON import COMMON -from src.console import console - - -class TDC(): - """ - Edit for Tracker: - Edit BASE.torrent with announce and source - Check for duplicates - Set type/category IDs - Upload - """ - - def __init__(self, config): - self.config = config - self.tracker = 'TDC' - self.source_flag = 'TDC' - self.upload_url = 'https://thedarkcommunity.cc/api/torrents/upload' - self.search_url = 'https://thedarkcommunity.cc/api/torrents/filter' - self.signature = "\n[center][url=https://github.com/Audionut/Upload-Assistant]Created by L4G's Upload Assistant[/url][/center]" - self.banned_groups = [""] - pass - - async def get_cat_id(self, category_name): - category_id = { - 'MOVIE': '1', - 'TV': '2', - }.get(category_name, '0') - return category_id - - async def get_type_id(self, type): - type_id = { - 'DISC': '1', - 'REMUX': '2', - 'WEBDL': '4', - 'WEBRIP': '5', - 'HDTV': '6', - 'ENCODE': '3' - }.get(type, '0') - return type_id - - async def get_res_id(self, resolution): - resolution_id = { - '8640p': '10', - '4320p': '1', - '2160p': '2', - '1440p': '3', - '1080p': '3', - '1080i': '4', - '720p': '5', - '576p': '6', - '576i': '7', - '480p': '8', - '480i': '9' - }.get(resolution, '10') - return resolution_id - - async def upload(self, meta, disctype): - common = COMMON(config=self.config) - await common.edit_torrent(meta, self.tracker, self.source_flag) - cat_id = await self.get_cat_id(meta['category']) - type_id = await self.get_type_id(meta['type']) - resolution_id = await self.get_res_id(meta['resolution']) - await common.unit3d_edit_desc(meta, self.tracker, self.signature) - region_id = await common.unit3d_region_ids(meta.get('region')) - distributor_id = await common.unit3d_distributor_ids(meta.get('distributor')) - if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) is False: - anon = 0 - else: - anon = 1 - - if meta['bdinfo'] is not None: - mi_dump = None - bd_dump = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/BD_SUMMARY_00.txt", 'r', encoding='utf-8').read() - else: - mi_dump = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/MEDIAINFO.txt", 'r', encoding='utf-8').read() - bd_dump = None - desc = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/[{self.tracker}]DESCRIPTION.txt", 'r', encoding='utf-8').read() - open_torrent = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/[{self.tracker}]{meta['clean_name']}.torrent", 'rb') - files = {'torrent': open_torrent} - data = { - 'name': meta['name'], - 'description': desc, - 'mediainfo': mi_dump, - 'bdinfo': bd_dump, - 'category_id': cat_id, - 'type_id': type_id, - 'resolution_id': resolution_id, - 'tmdb': meta['tmdb'], - 'imdb': meta['imdb_id'].replace('tt', ''), - 'tvdb': meta['tvdb_id'], - 'mal': meta['mal_id'], - 'igdb': 0, - 'anonymous': anon, - 'stream': meta['stream'], - 'sd': meta['sd'], - 'keywords': meta['keywords'], - 'personal_release': int(meta.get('personalrelease', False)), - 'internal': 0, - 'featured': 0, - 'free': 0, - 'doubleup': 0, - 'sticky': 0, - } - # Internal - if self.config['TRACKERS'][self.tracker].get('internal', False) is True: - if meta['tag'] != "" and (meta['tag'][1:] in self.config['TRACKERS'][self.tracker].get('internal_groups', [])): - data['internal'] = 1 - - if region_id != 0: - data['region_id'] = region_id - if distributor_id != 0: - data['distributor_id'] = distributor_id - if meta.get('category') == "TV": - data['season_number'] = meta.get('season_int', '0') - data['episode_number'] = meta.get('episode_int', '0') - headers = { - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0' - } - params = { - 'api_token': self.config['TRACKERS'][self.tracker]['api_key'].strip() - } - - if meta['debug'] is False: - response = requests.post(url=self.upload_url, files=files, data=data, headers=headers, params=params) - try: - console.print(response.json()) - except Exception: - console.print("It may have uploaded, go check") - return - else: - console.print("[cyan]Request Data:") - console.print(data) - open_torrent.close() - - async def search_existing(self, meta, disctype): - dupes = [] - console.print("[yellow]Searching for existing torrents on site...") - params = { - 'api_token': self.config['TRACKERS'][self.tracker]['api_key'].strip(), - 'tmdbId': meta['tmdb'], - 'categories[]': await self.get_cat_id(meta['category']), - 'types[]': await self.get_type_id(meta['type']), - 'resolutions[]': await self.get_res_id(meta['resolution']), - 'name': "" - } - if meta['category'] == 'TV': - params['name'] = params['name'] + f"{meta.get('season', '')}{meta.get('episode', '')}" - if meta.get('edition', "") != "": - params['name'] = params['name'] + meta['edition'] - - try: - response = requests.get(url=self.search_url, params=params) - response = response.json() - for each in response['data']: - result = [each][0]['attributes']['name'] - # difference = SequenceMatcher(None, meta['clean_name'], result).ratio() - # if difference >= 0.05: - dupes.append(result) - except Exception: - console.print('[bold red]Unable to search for existing torrents on site. Either the site is down or your API key is incorrect') - await asyncio.sleep(5) - - return dupes - - async def search_torrent_page(self, meta, disctype): - torrent_file_path = f"{meta['base_dir']}/tmp/{meta['uuid']}/[{self.tracker}]{meta['clean_name']}.torrent" - Name = meta['name'] - quoted_name = f'"{Name}"' - - params = { - 'api_token': self.config['TRACKERS'][self.tracker]['api_key'].strip(), - 'name': quoted_name - } - - try: - response = requests.get(url=self.search_url, params=params) - response.raise_for_status() - response_data = response.json() - - if response_data['data'] and isinstance(response_data['data'], list): - details_link = response_data['data'][0]['attributes'].get('details_link') - - if details_link: - with open(torrent_file_path, 'rb') as open_torrent: - torrent_data = open_torrent.read() - - torrent = bencodepy.decode(torrent_data) - torrent[b'comment'] = details_link.encode('utf-8') - updated_torrent_data = bencodepy.encode(torrent) - - with open(torrent_file_path, 'wb') as updated_torrent_file: - updated_torrent_file.write(updated_torrent_data) - - return details_link - else: - return None - else: - return None - - except requests.exceptions.RequestException as e: - print(f"An error occurred during the request: {e}") - return None diff --git a/upload.py b/upload.py index a7907c095..88daef201 100644 --- a/upload.py +++ b/upload.py @@ -29,7 +29,6 @@ from src.trackers.MTV import MTV from src.trackers.JPTV import JPTV from src.trackers.TL import TL -from src.trackers.TDC import TDC from src.trackers.HDT import HDT from src.trackers.RF import RF from src.trackers.OE import OE @@ -239,21 +238,29 @@ async def do_the_thing(base_dir): ####### Upload to Trackers ####### # noqa #F266 #################################### common = COMMON(config=config) - api_trackers = ['BLU', 'AITHER', 'STC', 'R4E', 'STT', 'RF', 'ACM', 'LCD', 'HUNO', 'LT', 'JPTV', 'TDC', 'OE', - 'OTW', 'FNP', 'CBR', 'UTP', 'AL', 'SHRI', 'LST', 'TIK', 'PSS', 'ULCX', 'BHD'] - other_api_trackers = ['SN', 'NBL', 'ANT', 'BHDTV', 'RTF', 'TL', 'TVC', 'SPD'] - http_trackers = ['HDB', 'TTG', 'FL', 'PTER', 'HDT', 'MTV'] + api_trackers = [ + 'ACM', 'AITHER', 'AL', 'BHD', 'BLU', 'CBR', 'FNP', 'HUNO', 'JPTV', 'LCD', 'LST', 'LT', + 'OE', 'OTW', 'PSS', 'RF', 'R4E', 'SHRI', 'STC', 'STT', 'TIK', 'ULCX', 'UTP' + ] + other_api_trackers = [ + 'ANT', 'BHDTV', 'NBL', 'RTF', 'SN', 'SPD', 'TL', 'TVC' + ] + http_trackers = [ + 'FL', 'HDB', 'HDT', 'MTV', 'PTER', 'TTG' + ] tracker_class_map = { - 'BLU': BLU, 'BHD': BHD, 'AITHER': AITHER, 'STC': STC, 'R4E': R4E, 'THR': THR, 'STT': STT, 'HP': HP, 'PTP': PTP, 'RF': RF, 'SN': SN, 'TIK': TIK, 'TVC': TVC, - 'ACM': ACM, 'HDB': HDB, 'LCD': LCD, 'TTG': TTG, 'LST': LST, 'HUNO': HUNO, 'FL': FL, 'LT': LT, 'NBL': NBL, 'ANT': ANT, 'PTER': PTER, 'JPTV': JPTV, - 'TL': TL, 'TDC': TDC, 'HDT': HDT, 'MTV': MTV, 'OE': OE, 'BHDTV': BHDTV, 'RTF': RTF, 'OTW': OTW, 'FNP': FNP, 'CBR': CBR, 'UTP': UTP, 'AL': AL, - 'SHRI': SHRI, 'PSS': PSS, 'ULCX': ULCX, 'SPD': SPD} + 'ACM': ACM, 'AITHER': AITHER, 'AL': AL, 'ANT': ANT, 'BHD': BHD, 'BHDTV': BHDTV, 'BLU': BLU, 'CBR': CBR, + 'FNP': FNP, 'FL': FL, 'HDB': HDB, 'HDT': HDT, 'HP': HP, 'HUNO': HUNO, 'JPTV': JPTV, 'LCD': LCD, + 'LST': LST, 'LT': LT, 'MTV': MTV, 'NBL': NBL, 'OE': OE, 'OTW': OTW, 'PSS': PSS, 'PTP': PTP, 'PTER': PTER, + 'R4E': R4E, 'RF': RF, 'RTF': RTF, 'SHRI': SHRI, 'SN': SN, 'SPD': SPD, 'STC': STC, 'STT': STT, 'THR': THR, + 'TIK': TIK, 'TL': TL, 'TVC': TVC, 'TTG': TTG, 'ULCX': ULCX, 'UTP': UTP + } tracker_capabilities = { - 'LST': {'mod_q': True, 'draft': True}, - 'BLU': {'mod_q': True, 'draft': False}, 'AITHER': {'mod_q': True, 'draft': False}, 'BHD': {'draft_live': True}, + 'BLU': {'mod_q': True, 'draft': False}, + 'LST': {'mod_q': True, 'draft': True} } async def check_mod_q_and_draft(tracker_class, meta, debug, disctype):