Skip to content

Commit

Permalink
Revert 319 again
Browse files Browse the repository at this point in the history
Update trackers added since PR
  • Loading branch information
Audionut committed Aug 10, 2024
1 parent 8084502 commit 483f989
Show file tree
Hide file tree
Showing 35 changed files with 88 additions and 88 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ beautifulsoup4
pyoxipng
rich
Jinja2
pyotp
pyotp
str2bool
33 changes: 16 additions & 17 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -97,15 +97,15 @@ 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']
except Exception:
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']
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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(' ', ' ')



Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/ACM.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/AITHER.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/ANT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/trackers/BHD.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/BHDTV.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/BLU.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/CBR.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# import discord
import asyncio
import requests
import distutils.util
from str2bool import str2bool
import os
import platform

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/trackers/FL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/FNP.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# import discord
import asyncio
import requests
import distutils.util
from str2bool import str2bool
import os
import platform

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/HDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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...")
Expand Down
6 changes: 3 additions & 3 deletions src/trackers/HDT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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'
Expand Down
Loading

0 comments on commit 483f989

Please sign in to comment.