diff --git a/requirements.txt b/requirements.txt index 19e7c5038..b20352a43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,4 +18,5 @@ beautifulsoup4 pyoxipng rich Jinja2 -pyotp \ No newline at end of file +pyotp +str2bool \ No newline at end of file diff --git a/src/prep.py b/src/prep.py index f4e731cf0..e53ae336d 100644 --- a/src/prep.py +++ b/src/prep.py @@ -17,7 +17,7 @@ import re import math import sys - import distutils.util + from str2bool import str2bool import asyncio from guessit import guessit import ntpath @@ -97,7 +97,7 @@ async def gather_prep(self, meta, mode): meta['filelist'] = [] try: guess_name = bdinfo['title'].replace('-',' ') - filename = guessit(re.sub("[^0-9a-zA-Z\[\]]+", " ", guess_name), {"excludes" : ["country", "language"]})['title'] + filename = guessit(re.sub(r"[^0-9a-zA-Z\[\\]]+", " ", guess_name), {"excludes" : ["country", "language"]})['title'] untouched_filename = bdinfo['title'] try: meta['search_year'] = guessit(bdinfo['title'])['year'] @@ -105,7 +105,7 @@ async def gather_prep(self, meta, mode): meta['search_year'] = "" except Exception: guess_name = bdinfo['label'].replace('-',' ') - filename = guessit(re.sub("[^0-9a-zA-Z\[\]]+", " ", guess_name), {"excludes" : ["country", "language"]})['title'] + filename = guessit(re.sub(r"[^0-9a-zA-Z\[\\]]+", " ", guess_name), {"excludes" : ["country", "language"]})['title'] untouched_filename = bdinfo['label'] try: meta['search_year'] = guessit(bdinfo['label'])['year'] @@ -164,7 +164,7 @@ async def gather_prep(self, meta, mode): videopath, meta['filelist'] = self.get_video(videoloc, meta.get('mode', 'discord')) video, meta['scene'], meta['imdb'] = self.is_scene(videopath, meta.get('imdb', None)) guess_name = ntpath.basename(video).replace('-',' ') - filename = guessit(re.sub("[^0-9a-zA-Z\[\]]+", " ", guess_name), {"excludes" : ["country", "language"]}).get("title", guessit(re.sub("[^0-9a-zA-Z]+", " ", guess_name), {"excludes" : ["country", "language"]})["title"]) + filename = guessit(re.sub(r"[^0-9a-zA-Z\[\\]]+", " ", guess_name), {"excludes" : ["country", "language"]}).get("title", guessit(re.sub("[^0-9a-zA-Z]+", " ", guess_name), {"excludes" : ["country", "language"]})["title"]) untouched_filename = os.path.basename(video) try: meta['search_year'] = guessit(video)['year'] @@ -359,8 +359,8 @@ async def gather_prep(self, meta, mode): meta['edition'], meta['repack'] = self.get_edition(meta['path'], bdinfo, meta['filelist'], meta.get('manual_edition')) if "REPACK" in meta.get('edition', ""): - meta['repack'] = re.search("REPACK[\d]?", meta['edition'])[0] - meta['edition'] = re.sub("REPACK[\d]?", "", meta['edition']).strip().replace(' ', ' ') + meta['repack'] = re.search(r"REPACK[\d]?", meta['edition'])[0] + meta['edition'] = re.sub(r"REPACK[\d]?", "", meta['edition']).strip().replace(' ', ' ') @@ -1371,7 +1371,7 @@ def get_romaji(self, tmdb_name, mal): result = {'title' : {}} difference = 0 for anime in media: - search_name = re.sub("[^0-9a-zA-Z\[\]]+", "", tmdb_name.lower().replace(' ', '')) + search_name = re.sub(r"[^0-9a-zA-Z\[\\]]+", "", tmdb_name.lower().replace(' ', '')) for title in anime['title'].values(): if title != None: title = re.sub(u'[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uff9f\u4e00-\u9faf\u3400-\u4dbf]+ (?=[A-Za-z ]+–)', "", title.lower().replace(' ', ''), re.U) @@ -2012,7 +2012,7 @@ def torf_cb(self, torrent, filepath, pieces_done, pieces_total): cli_ui.info_progress("Hashing...", pieces_done, pieces_total) def create_random_torrents(self, base_dir, uuid, num, path): - manual_name = re.sub("[^0-9a-zA-Z\[\]\'\-]+", ".", os.path.basename(path)) + manual_name = re.sub(r"[^0-9a-zA-Z\[\]\'\-]+", ".", os.path.basename(path)) base_torrent = Torrent.read(f"{base_dir}/tmp/{uuid}/BASE.torrent") for i in range(1, int(num) + 1): new_torrent = base_torrent @@ -2022,7 +2022,6 @@ def create_random_torrents(self, base_dir, uuid, num, path): def create_base_from_existing_torrent(self, torrentpath, base_dir, uuid): if os.path.exists(torrentpath): base_torrent = Torrent.read(torrentpath) - base_torrent.creation_date = datetime.now() base_torrent.trackers = ['https://fake.tracker'] base_torrent.comment = "Created by L4G's Upload Assistant" base_torrent.created_by = "Created by L4G's Upload Assistant" @@ -2513,8 +2512,8 @@ async def get_season_episode(self, video, meta): for lang, names in values.items(): if lang == "jp": for name in names: - romaji_check = re.sub("[^0-9a-zA-Z\[\]]+", "", romaji.lower().replace(' ', '')) - name_check = re.sub("[^0-9a-zA-Z\[\]]+", "", name.lower().replace(' ', '')) + romaji_check = re.sub(r"[^0-9a-zA-Z\[\\]]+", "", romaji.lower().replace(' ', '')) + name_check = re.sub(r"[^0-9a-zA-Z\[\\]]+", "", name.lower().replace(' ', '')) diff = SequenceMatcher(None, romaji_check, name_check).ratio() if romaji_check in name_check: if diff >= difference: @@ -2527,8 +2526,8 @@ async def get_season_episode(self, video, meta): difference = diff if lang == "us": for name in names: - eng_check = re.sub("[^0-9a-zA-Z\[\]]+", "", eng_title.lower().replace(' ', '')) - name_check = re.sub("[^0-9a-zA-Z\[\]]+", "", name.lower().replace(' ', '')) + eng_check = re.sub(r"[^0-9a-zA-Z\[\\]]+", "", eng_title.lower().replace(' ', '')) + name_check = re.sub(r"[^0-9a-zA-Z\[\\]]+", "", name.lower().replace(' ', '')) diff = SequenceMatcher(None, eng_check, name_check).ratio() if eng_check in name_check: if diff >= difference: @@ -2645,7 +2644,7 @@ def get_service(self, video, tag, audio, guess_title): } - video_name = re.sub("[.()]", " ", video.replace(tag, '').replace(guess_title, '')) + video_name = re.sub(r"[.()]", " ", video.replace(tag, '').replace(guess_title, '')) if "DTS-HD MA" in audio: video_name = video_name.replace("DTS-HD.MA.", "").replace("DTS-HD MA ", "") for key, value in services.items(): @@ -2794,7 +2793,7 @@ async def tag_override(self, meta): else: pass elif key == 'personalrelease': - meta[key] = bool(distutils.util.strtobool(str(value.get(key, 'False')))) + meta[key] = bool(str2bool(str(value.get(key, 'False')))) elif key == 'template': meta['desc_template'] = value.get(key) else: @@ -2849,7 +2848,7 @@ async def package(self, meta): generic.write(f"\nThumbnail Image:\n") for each in meta['image_list']: generic.write(f"{each['img_url']}\n") - title = re.sub("[^0-9a-zA-Z\[\]]+", "", meta['title']) + title = re.sub(r"[^0-9a-zA-Z\[\\]]+", "", meta['title']) archive = f"{meta['base_dir']}/tmp/{meta['uuid']}/{title}" torrent_files = glob.glob1(f"{meta['base_dir']}/tmp/{meta['uuid']}","*.torrent") if isinstance(torrent_files, list) and len(torrent_files) > 1: @@ -2859,7 +2858,7 @@ async def package(self, meta): try: if os.path.exists(f"{meta['base_dir']}/tmp/{meta['uuid']}/BASE.torrent"): base_torrent = Torrent.read(f"{meta['base_dir']}/tmp/{meta['uuid']}/BASE.torrent") - manual_name = re.sub("[^0-9a-zA-Z\[\]\'\-]+", ".", os.path.basename(meta['path'])) + manual_name = re.sub(r"[^0-9a-zA-Z\[\]\'\-]+", ".", os.path.basename(meta['path'])) Torrent.copy(base_torrent).write(f"{meta['base_dir']}/tmp/{meta['uuid']}/{manual_name}.torrent", overwrite=True) # shutil.copy(os.path.abspath(f"{meta['base_dir']}/tmp/{meta['uuid']}/BASE.torrent"), os.path.abspath(f"{meta['base_dir']}/tmp/{meta['uuid']}/{meta['name'].replace(' ', '.')}.torrent").replace(' ', '.')) filebrowser = self.config['TRACKERS'].get('MANUAL', {}).get('filebrowser', None) diff --git a/src/trackers/ACM.py b/src/trackers/ACM.py index 121c60cbc..194a2d0a2 100644 --- a/src/trackers/ACM.py +++ b/src/trackers/ACM.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os import platform +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -207,7 +207,7 @@ async def upload(self, meta): region_id = await common.unit3d_region_ids(meta.get('region')) distributor_id = await common.unit3d_distributor_ids(meta.get('distributor')) acm_name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/AITHER.py b/src/trackers/AITHER.py index 7930871eb..308383a5f 100644 --- a/src/trackers/AITHER.py +++ b/src/trackers/AITHER.py @@ -3,7 +3,7 @@ import asyncio import requests from difflib import SequenceMatcher -import distutils.util +from str2bool import str2bool import json import os import platform @@ -39,7 +39,7 @@ async def upload(self, meta): type_id = await self.get_type_id(meta['type']) resolution_id = await self.get_res_id(meta['resolution']) name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/ANT.py b/src/trackers/ANT.py index 06f492cc0..1297f45ab 100644 --- a/src/trackers/ANT.py +++ b/src/trackers/ANT.py @@ -3,8 +3,8 @@ import os import asyncio import requests -import distutils.util import platform +from str2bool import str2bool from pymediainfo import MediaInfo from src.trackers.COMMON import COMMON @@ -72,7 +72,7 @@ async def upload(self, meta): common = COMMON(config=self.config) await common.edit_torrent(meta, self.tracker, self.source_flag) flags = await self.get_flags(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) is False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) is False: anon = 0 else: anon = 1 diff --git a/src/trackers/BHD.py b/src/trackers/BHD.py index d6ce9bca1..d9e73acdf 100644 --- a/src/trackers/BHD.py +++ b/src/trackers/BHD.py @@ -3,7 +3,7 @@ import asyncio import requests from difflib import SequenceMatcher -import distutils.util +from str2bool import str2bool import urllib import os import platform @@ -39,7 +39,7 @@ async def upload(self, meta): tags = await self.get_tags(meta) custom, edition = await self.get_edition(meta, tags) bhd_name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 @@ -263,7 +263,7 @@ async def search_existing(self, meta): async def get_live(self, meta): draft = self.config['TRACKERS'][self.tracker]['draft_default'].strip() - draft = bool(distutils.util.strtobool(str(draft))) #0 for send to draft, 1 for live + draft = bool(str2bool(str(draft))) #0 for send to draft, 1 for live if draft: draft_int = 0 else: diff --git a/src/trackers/BHDTV.py b/src/trackers/BHDTV.py index 97d0e1c8e..ea6f911c1 100644 --- a/src/trackers/BHDTV.py +++ b/src/trackers/BHDTV.py @@ -4,7 +4,7 @@ from torf import Torrent import requests from src.console import console -import distutils.util +from str2bool import str2bool from pprint import pprint import os import traceback @@ -54,7 +54,7 @@ async def upload(self, meta): # 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( - distutils.util.strtobool(self.config['TRACKERS'][self.tracker].get('anon', "False"))) == False: + str2bool(self.config['TRACKERS'][self.tracker].get('anon', "False"))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/BLU.py b/src/trackers/BLU.py index 44dbaf85f..9f2757327 100644 --- a/src/trackers/BLU.py +++ b/src/trackers/BLU.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os import platform +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -49,7 +49,7 @@ async def upload(self, meta): resolution_id = await self.get_res_id(meta['resolution']) 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(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/CBR.py b/src/trackers/CBR.py index aedb30937..445f4e9d5 100644 --- a/src/trackers/CBR.py +++ b/src/trackers/CBR.py @@ -2,7 +2,7 @@ # import discord import asyncio import requests -import distutils.util +from str2bool import str2bool import os import platform @@ -40,7 +40,7 @@ async def upload(self, meta): region_id = await common.unit3d_region_ids(meta.get('region')) distributor_id = await common.unit3d_distributor_ids(meta.get('distributor')) name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2obool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/FL.py b/src/trackers/FL.py index 06cd4bb0b..5813f469a 100644 --- a/src/trackers/FL.py +++ b/src/trackers/FL.py @@ -3,7 +3,7 @@ import re import os from pathlib import Path -import distutils.util +from str2bool import str2bool import json import glob import pickle @@ -98,7 +98,7 @@ async def edit_name(self, meta): fl_name = fl_name.replace('DTS7.1', 'DTS').replace('DTS5.1', 'DTS').replace('DTS2.0', 'DTS').replace('DTS1.0', 'DTS') fl_name = fl_name.replace('Dubbed', '').replace('Dual-Audio', '') fl_name = ' '.join(fl_name.split()) - fl_name = re.sub("[^0-9a-zA-ZÀ-ÿ. &+'\-\[\]]+", "", fl_name) + fl_name = re.sub(r"[^0-9a-zA-ZÀ-ÿ. &+'\-\[\]]+", "", fl_name) fl_name = fl_name.replace(' ', '.').replace('..', '.') return fl_name @@ -161,7 +161,7 @@ async def upload(self, meta): if int(meta.get('imdb_id', '').replace('tt', '')) != 0: data['imdbid'] = meta.get('imdb_id', '').replace('tt', '') data['description'] = meta['imdb_info'].get('genres', '') - if self.uploader_name not in ("", None) and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if self.uploader_name not in ("", None) and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: data['epenis'] = self.uploader_name if has_ro_audio: data['materialro'] = 'on' @@ -319,7 +319,7 @@ async def edit_desc(self, meta): desc = bbcode.convert_code_to_quote(desc) desc = bbcode.convert_comparison_to_centered(desc, 900) desc = desc.replace('[img]', '[img]').replace('[/img]', '[/img]') - desc = re.sub("(\[img=\d+)]", "[img]", desc, flags=re.IGNORECASE) + desc = re.sub(r"(\[img=\d+)]", "[img]", desc, flags=re.IGNORECASE) if meta['is_disc'] != 'BDMV': url = "https://up.img4k.net/api/description" data = { diff --git a/src/trackers/FNP.py b/src/trackers/FNP.py index f255b2c43..8c7ecd0fe 100644 --- a/src/trackers/FNP.py +++ b/src/trackers/FNP.py @@ -2,7 +2,7 @@ # import discord import asyncio import requests -import distutils.util +from str2bool import str2bool import os import platform @@ -82,7 +82,7 @@ async def upload(self, meta): 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(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/HDB.py b/src/trackers/HDB.py index 7fab14991..b8eafcb7c 100644 --- a/src/trackers/HDB.py +++ b/src/trackers/HDB.py @@ -192,7 +192,7 @@ async def edit_name(self, meta): hdb_name = hdb_name.replace('Dubbed', '').replace('Dual-Audio', '') hdb_name = hdb_name.replace('REMUX', 'Remux') hdb_name = ' '.join(hdb_name.split()) - hdb_name = re.sub("[^0-9a-zA-ZÀ-ÿ. :&+'\-\[\]]+", "", hdb_name) + hdb_name = re.sub(r"[^0-9a-zA-ZÀ-ÿ. :&+'\-\[\]]+", "", hdb_name) hdb_name = hdb_name.replace(' .', '.').replace('..', '.') return hdb_name @@ -431,7 +431,7 @@ async def edit_desc(self, meta): desc = bbcode.convert_code_to_quote(desc) desc = bbcode.convert_spoiler_to_hide(desc) desc = bbcode.convert_comparison_to_centered(desc, 1000) - desc = re.sub("(\[img=\d+)]", "[img]", desc, flags=re.IGNORECASE) + desc = re.sub(r"(\[img=\d+)]", "[img]", desc, flags=re.IGNORECASE) descfile.write(desc) if self.rehost_images == True: console.print("[green]Rehosting Images...") diff --git a/src/trackers/HDT.py b/src/trackers/HDT.py index 6b9fa0320..6bcf76964 100644 --- a/src/trackers/HDT.py +++ b/src/trackers/HDT.py @@ -6,8 +6,8 @@ import glob import cli_ui import pickle -import distutils from pathlib import Path +from str2bool import str2bool from bs4 import BeautifulSoup from unidecode import unidecode from pymediainfo import MediaInfo @@ -105,7 +105,7 @@ async def edit_name(self, meta): hdt_name = hdt_name.replace(' DV ', ' DoVi ') hdt_name = ' '.join(hdt_name.split()) - hdt_name = re.sub("[^0-9a-zA-ZÀ-ÿ. &+'\-\[\]]+", "", hdt_name) + hdt_name = re.sub(r"[^0-9a-zA-ZÀ-ÿ. &+'\-\[\]]+", "", hdt_name) hdt_name = hdt_name.replace(':', '').replace('..', ' ').replace(' ', ' ') return hdt_name @@ -173,7 +173,7 @@ async def upload(self, meta): data['season'] = 'false' # Anonymous check - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: data['anonymous'] = 'false' else: data['anonymous'] = 'true' diff --git a/src/trackers/HP.py b/src/trackers/HP.py index 250e9e851..7c11e0744 100644 --- a/src/trackers/HP.py +++ b/src/trackers/HP.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os import platform +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -78,7 +78,7 @@ async def upload(self, meta): 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(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/HUNO.py b/src/trackers/HUNO.py index 9b69e74e3..ee13c0338 100644 --- a/src/trackers/HUNO.py +++ b/src/trackers/HUNO.py @@ -3,7 +3,7 @@ import asyncio import requests from difflib import SequenceMatcher -import distutils.util +from str2bool import str2bool import os import re import platform @@ -37,7 +37,7 @@ async def upload(self, meta): cat_id = await self.get_cat_id(meta['category']) type_id = await self.get_type_id(meta) resolution_id = await self.get_res_id(meta['resolution']) - if meta['anon'] == 0 and bool(distutils.util.strtobool(self.config['TRACKERS']['HUNO'].get('anon', "False"))) == False: + if meta['anon'] == 0 and bool(str2bool(self.config['TRACKERS']['HUNO'].get('anon', "False"))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/JPTV.py b/src/trackers/JPTV.py index 354b1be1a..06253aebe 100644 --- a/src/trackers/JPTV.py +++ b/src/trackers/JPTV.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os import platform +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -92,7 +92,7 @@ async def upload(self, meta): region_id = await common.unit3d_region_ids(meta.get('region')) distributor_id = await common.unit3d_distributor_ids(meta.get('distributor')) jptv_name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/LCD.py b/src/trackers/LCD.py index 5c3f14309..a457a601a 100644 --- a/src/trackers/LCD.py +++ b/src/trackers/LCD.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os import platform +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -40,7 +40,7 @@ async def upload(self, meta): region_id = await common.unit3d_region_ids(meta.get('region')) distributor_id = await common.unit3d_distributor_ids(meta.get('distributor')) name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/LST.py b/src/trackers/LST.py index 5d42b1ba2..d748fd939 100644 --- a/src/trackers/LST.py +++ b/src/trackers/LST.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os import platform +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -89,7 +89,7 @@ async def upload(self, meta): 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(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/LT.py b/src/trackers/LT.py index aeb6b3550..b5965c843 100644 --- a/src/trackers/LT.py +++ b/src/trackers/LT.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os import platform +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -108,7 +108,7 @@ async def upload(self, meta): #region_id = await common.unit3d_region_ids(meta.get('region')) distributor_id = await common.unit3d_distributor_ids(meta.get('distributor')) lt_name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/MTV.py b/src/trackers/MTV.py index aba9b3b5d..cee1de771 100644 --- a/src/trackers/MTV.py +++ b/src/trackers/MTV.py @@ -8,8 +8,8 @@ import cli_ui import pickle import re -import distutils.util from pathlib import Path +from str2bool import str2bool from src.trackers.COMMON import COMMON class MTV(): @@ -75,7 +75,7 @@ async def upload(self, meta): mtv_name = await self.edit_name(meta) # anon - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 @@ -221,7 +221,7 @@ async def edit_name(self, meta): if meta['tag'] == "": mtv_name = f"{mtv_name}-NoGrp" mtv_name = ' '.join(mtv_name.split()) - mtv_name = re.sub("[^0-9a-zA-ZÀ-ÿ. &+'\-\[\]]+", "", mtv_name) + mtv_name = re.sub(r"[^0-9a-zA-ZÀ-ÿ. &+'\-\[\]]+", "", mtv_name) mtv_name = mtv_name.replace(' ', '.').replace('..', '.') return mtv_name diff --git a/src/trackers/NBL.py b/src/trackers/NBL.py index 813cb871b..56e01a671 100644 --- a/src/trackers/NBL.py +++ b/src/trackers/NBL.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os from guessit import guessit +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console diff --git a/src/trackers/OE.py b/src/trackers/OE.py index bb69a3e02..332fc6d7f 100644 --- a/src/trackers/OE.py +++ b/src/trackers/OE.py @@ -3,7 +3,7 @@ import asyncio import requests from difflib import SequenceMatcher -import distutils.util +from str2bool import str2bool import json import os import platform @@ -37,7 +37,7 @@ async def upload(self, meta): type_id = await self.get_type_id(meta['type'], meta.get('tv_pack', 0), meta.get('video_codec'), meta.get('category', "")) resolution_id = await self.get_res_id(meta['resolution']) oe_name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/OTW.py b/src/trackers/OTW.py index 0425b3924..697a2197f 100644 --- a/src/trackers/OTW.py +++ b/src/trackers/OTW.py @@ -2,7 +2,7 @@ # import discord import asyncio import requests -import distutils.util +from str2bool import str2bool import os import platform @@ -82,7 +82,7 @@ async def upload(self, meta): 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(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/PTER.py b/src/trackers/PTER.py index b9fcecfa0..71eb1c2a1 100644 --- a/src/trackers/PTER.py +++ b/src/trackers/PTER.py @@ -7,7 +7,7 @@ import traceback import json import glob -import distutils.util +from str2bool import str2bool import cli_ui import pickle from unidecode import unidecode @@ -187,7 +187,7 @@ async def edit_desc(self, meta): desc = bbcode.convert_spoiler_to_hide(desc) desc = bbcode.convert_comparison_to_centered(desc, 1000) desc = desc.replace('[img]', '[img]') - desc = re.sub("(\[img=\d+)]", "[img]", desc, flags=re.IGNORECASE) + desc = re.sub(r"(\[img=\d+)]", "[img]", desc, flags=re.IGNORECASE) descfile.write(desc) if self.rehost_images == True: @@ -288,7 +288,7 @@ async def pterimg_upload(self, meta): return image_list async def get_anon(self, anon): - if anon == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if anon == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 'no' else: anon = 'yes' diff --git a/src/trackers/PTP.py b/src/trackers/PTP.py index 7ededcac7..91944df34 100644 --- a/src/trackers/PTP.py +++ b/src/trackers/PTP.py @@ -2,9 +2,9 @@ import requests import asyncio import re -import distutils.util import os from pathlib import Path +from str2bool import str2bool import time import traceback import json @@ -33,7 +33,7 @@ def __init__(self, config): self.announce_url = config['TRACKERS']['PTP'].get('announce_url', '').strip() self.username = config['TRACKERS']['PTP'].get('username', '').strip() self.password = config['TRACKERS']['PTP'].get('password', '').strip() - self.web_source = distutils.util.strtobool(str(config['TRACKERS']['PTP'].get('add_web_source_to_desc', True))) + self.web_source = str2bool(str(config['TRACKERS']['PTP'].get('add_web_source_to_desc', True))) self.user_agent = f'Upload Assistant/2.1 ({platform.system()} {platform.release()})' self.banned_groups = ['aXXo', 'BMDru', 'BRrip', 'CM8', 'CrEwSaDe', 'CTFOH', 'd3g', 'DNL', 'FaNGDiNG0', 'HD2DVD', 'HDTime', 'ION10', 'iPlanet', 'KiNGDOM', 'mHD', 'mSD', 'nHD', 'nikt0', 'nSD', 'NhaNc3', 'OFT', 'PRODJi', 'SANTi', 'SPiRiT', 'STUTTERSHIT', 'ViSION', 'VXT', diff --git a/src/trackers/R4E.py b/src/trackers/R4E.py index 67d33c997..0528c10cc 100644 --- a/src/trackers/R4E.py +++ b/src/trackers/R4E.py @@ -3,7 +3,7 @@ import asyncio import requests from difflib import SequenceMatcher -import distutils.util +from str2bool import str2bool import json import tmdbsimple as tmdb import os @@ -36,7 +36,7 @@ async def upload(self, meta): type_id = await self.get_type_id(meta['resolution']) await common.unit3d_edit_desc(meta, self.tracker, self.signature) name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS']['R4E'].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS']['R4E'].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/RF.py b/src/trackers/RF.py index ca94837b9..aa108340d 100644 --- a/src/trackers/RF.py +++ b/src/trackers/RF.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os import platform +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -41,7 +41,7 @@ async def upload(self, meta): type_id = await self.get_type_id(meta['type']) resolution_id = await self.get_res_id(meta['resolution']) stt_name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/RTF.py b/src/trackers/RTF.py index 8ef181d6b..28ce55924 100644 --- a/src/trackers/RTF.py +++ b/src/trackers/RTF.py @@ -54,7 +54,7 @@ async def upload(self, meta): # 'description' : meta['overview'] + "\n\n" + desc + "\n\n" + "Uploaded by L4G Upload Assistant", 'description': "this is a description", # editing mediainfo so that instead of 1 080p its 1,080p as site mediainfo parser wont work other wise. - 'mediaInfo': re.sub("(\d+)\s+(\d+)", r"\1,\2", mi_dump) if bd_dump == None else f"{bd_dump}", + 'mediaInfo': re.sub(r"(\d+)\s+(\d+)", r"\1,\2", mi_dump) if bd_dump == None else f"{bd_dump}", "nfo": "", "url": "https://www.imdb.com/title/" + (meta['imdb_id'] if str(meta['imdb_id']).startswith("tt") else "tt" + meta['imdb_id']) + "/", # auto pulled from IMDB diff --git a/src/trackers/STC.py b/src/trackers/STC.py index 224e89889..71d70ce2f 100644 --- a/src/trackers/STC.py +++ b/src/trackers/STC.py @@ -2,7 +2,7 @@ import asyncio import requests from difflib import SequenceMatcher -import distutils.util +from str2bool import str2bool import json import os import platform @@ -36,7 +36,7 @@ async def upload(self, meta): type_id = await self.get_type_id(meta['type'], meta.get('tv_pack', 0), meta.get('sd', 0), meta.get('category', "")) resolution_id = await self.get_res_id(meta['resolution']) stc_name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/STT.py b/src/trackers/STT.py index 0a72f7eab..fdeed9e88 100644 --- a/src/trackers/STT.py +++ b/src/trackers/STT.py @@ -3,7 +3,7 @@ import asyncio import requests from difflib import SequenceMatcher -import distutils.util +from str2bool import str2bool import json import os import platform @@ -37,7 +37,7 @@ async def upload(self, meta): type_id = await self.get_type_id(meta['type']) resolution_id = await self.get_res_id(meta['resolution']) stt_name = await self.edit_name(meta) - if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/TDC.py b/src/trackers/TDC.py index e201bcb83..b22ec6cd7 100644 --- a/src/trackers/TDC.py +++ b/src/trackers/TDC.py @@ -2,8 +2,8 @@ # import discord import asyncio import requests -import distutils.util import os +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -77,7 +77,7 @@ async def upload(self, meta): 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(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/THR.py b/src/trackers/THR.py index 3080ae581..f1f74e15b 100644 --- a/src/trackers/THR.py +++ b/src/trackers/THR.py @@ -49,7 +49,7 @@ async def upload(self, session, meta): return else: thr_name = thr_name_manually - torrent_name = re.sub("[^0-9a-zA-Z. '\-\[\]]+", " ", thr_name) + torrent_name = re.sub(r"[^0-9a-zA-Z. '\-\[\]]+", " ", thr_name) if meta.get('is_disc', '') == 'BDMV': diff --git a/src/trackers/TTG.py b/src/trackers/TTG.py index 491a3bacc..6795d13cc 100644 --- a/src/trackers/TTG.py +++ b/src/trackers/TTG.py @@ -7,8 +7,8 @@ from pathlib import Path import traceback import json -import distutils.util import cli_ui +from str2bool import str2bool from unidecode import unidecode from urllib.parse import urlparse, quote from src.trackers.COMMON import COMMON @@ -104,7 +104,7 @@ async def get_type_id(self, meta): return type_id async def get_anon(self, anon): - if anon == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if anon == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 'no' else: anon = 'yes' @@ -327,7 +327,7 @@ async def edit_desc(self, meta): desc = bbcode.convert_spoiler_to_hide(desc) desc = bbcode.convert_comparison_to_centered(desc, 1000) desc = desc.replace('[img]', '[img]') - desc = re.sub("(\[img=\d+)]", "[img]", desc, flags=re.IGNORECASE) + desc = re.sub(r"(\[img=\d+)]", "[img]", desc, flags=re.IGNORECASE) descfile.write(desc) images = meta['image_list'] if len(images) > 0: diff --git a/src/trackers/UNIT3D_TEMPLATE.py b/src/trackers/UNIT3D_TEMPLATE.py index 405e2c9f1..c77e758a7 100644 --- a/src/trackers/UNIT3D_TEMPLATE.py +++ b/src/trackers/UNIT3D_TEMPLATE.py @@ -2,9 +2,9 @@ # import discord import asyncio import requests -import distutils.util import os import platform +from str2bool import str2bool from src.trackers.COMMON import COMMON from src.console import console @@ -82,7 +82,7 @@ async def upload(self, meta): 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(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1 diff --git a/src/trackers/UTP.py b/src/trackers/UTP.py index 9b3476cc3..5ba904811 100644 --- a/src/trackers/UTP.py +++ b/src/trackers/UTP.py @@ -2,7 +2,7 @@ # import discord import asyncio import requests -import distutils.util +from str2bool import str2bool import os import platform @@ -37,7 +37,7 @@ async def upload(self, meta): resolution_id = await self.get_res_id(meta['resolution']) 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(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: + if meta['anon'] == 0 and bool(str2obool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False: anon = 0 else: anon = 1