Skip to content

Commit

Permalink
ANT: BDMV fixes thanks to Kitty
Browse files Browse the repository at this point in the history
  • Loading branch information
L4GSP1KE committed Oct 11, 2023
1 parent e4b6c4d commit 3aeb95c
Showing 1 changed file with 41 additions and 29 deletions.
70 changes: 41 additions & 29 deletions src/trackers/ANT.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
# import discord
import os
import asyncio
import requests
import distutils.util
import platform
from pymediainfo import MediaInfo

from src.trackers.COMMON import COMMON
from src.console import console
Expand All @@ -19,7 +21,7 @@ class ANT():
"""

###############################################################
######## EDIT ME ########
# ####### EDIT ME ##### #
###############################################################

# ALSO EDIT CLASS NAME ABOVE
Expand All @@ -30,10 +32,11 @@ def __init__(self, config):
self.source_flag = 'ANT'
self.search_url = 'https://anthelion.me/api.php'
self.upload_url = 'https://anthelion.me/api.php'
self.banned_groups = ['Ozlem', 'RARBG', 'FGT', 'STUTTERSHIT', 'LiGaS', 'DDR', 'Zeus', 'TBS', 'aXXo', 'CrEwSaDe', 'DNL', 'EVO', 'FaNGDiNG0', 'HD2DVD', 'HDTime', 'iPlanet', 'KiNGDOM', 'NhaNc3', 'PRoDJi', 'SANTi', 'ViSiON', 'WAF', 'YIFY', 'YTS', 'MkvCage', 'mSD']
self.banned_groups = ['Ozlem', 'RARBG', 'FGT', 'STUTTERSHIT', 'LiGaS', 'DDR', 'Zeus', 'TBS', 'aXXo', 'CrEwSaDe', 'DNL', 'EVO',
'FaNGDiNG0', 'HD2DVD', 'HDTime', 'iPlanet', 'KiNGDOM', 'NhaNc3', 'PRoDJi', 'SANTi', 'ViSiON', 'WAF', 'YIFY',
'YTS', 'MkvCage', 'mSD']
self.signature = None
pass


async def get_flags(self, meta):
flags = []
Expand All @@ -58,66 +61,77 @@ async def get_flags(self, meta):
return flags

###############################################################
###### STOP HERE UNLESS EXTRA MODIFICATION IS NEEDED ######
# #### STOP HERE UNLESS EXTRA MODIFICATION IS NEEDED ### #
###############################################################

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")))) == False:
if meta['anon'] == 0 and bool(distutils.util.strtobool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) is False:
anon = 0
else:
anon = 1

if meta['bdinfo'] != None:
mi_dump = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/BD_SUMMARY_00.txt", 'r', encoding='utf-8').read()
if meta['bdinfo'] is not None:
bd_dump = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/BD_SUMMARY_00.txt", 'r', encoding='utf-8').read()
bd_dump = f'[spoiler=BDInfo][pre]{bd_dump}[/pre][/spoiler]'
path = os.path.join(meta['bdinfo']['path'], 'STREAM')
m2ts = os.path.join(path, meta['bdinfo']['files'][0]['file'])
media_info_output = str(MediaInfo.parse(m2ts, output="text", full=False))
mi_dump = media_info_output.replace('\r\n', '\n')
else:
mi_dump = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/MEDIAINFO.txt", 'r', encoding='utf-8').read()
open_torrent = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/[{self.tracker}]{meta['clean_name']}.torrent", 'rb')
files = {'file_input': open_torrent}
data = {
'api_key' : self.config['TRACKERS'][self.tracker]['api_key'].strip(),
'action' : 'upload',
'tmdbid' : meta['tmdb'],
'mediainfo' : mi_dump,
'flags[]' : flags,
'anonymous' : anon,
'screenshots' : '\n'.join([x['raw_url'] for x in meta['image_list']][:4])
'api_key': self.config['TRACKERS'][self.tracker]['api_key'].strip(),
'action': 'upload',
'tmdbid': meta['tmdb'],
'mediainfo': mi_dump,
'flags[]': flags,
'anonymous': anon,
'screenshots': '\n'.join([x['raw_url'] for x in meta['image_list']][:4])
}
if meta['bdinfo'] is not None:
data.update({
'media': 'Blu-ray',
'releasegroup': str(meta['tag'])[1:],
'release_desc': bd_dump,
'flagchangereason': "BDMV Uploaded with L4G's Upload Assistant"})
if meta['scene']:
# ID of "Scene?" checkbox on upload form is actually "censored"
data['censored'] = 1
headers = {
'User-Agent': f'Upload Assistant/2.1 ({platform.system()} {platform.release()})'
}
if meta['debug'] == False:
}
if meta['debug'] is False:
response = requests.post(url=self.upload_url, files=files, data=data, headers=headers)
if response.status_code in [200, 201]:
response = response.json()
try:
console.print(response.json())
except:
console.print(response)
except Exception:
console.print("It may have uploaded, go check")
return
return
else:
console.print(f"[cyan]Request Data:")
console.print("[cyan]Request Data:")
console.print(data)
open_torrent.close()


async def edit_desc(self, meta):
return


async def search_existing(self, meta):
dupes = []
console.print("[yellow]Searching for existing torrents on site...")
params = {
'apikey' : self.config['TRACKERS'][self.tracker]['api_key'].strip(),
't' : 'search',
'o' : 'json'
'apikey': self.config['TRACKERS'][self.tracker]['api_key'].strip(),
't': 'search',
'o': 'json'
}
if str(meta['tmdb']) != "0":
params['tmdb'] = meta['tmdb']
params['tmdb'] = meta['tmdb']
elif int(meta['imdb_id'].replace('tt', '')) != 0:
params['imdb'] = meta['imdb_id']
try:
Expand All @@ -129,10 +143,8 @@ async def search_existing(self, meta):
if int(file['size']) > int(largest['size']):
largest = file
result = largest['name']
# difference = SequenceMatcher(None, meta['clean_name'], result).ratio()
# if difference >= 0.05:
dupes.append(result)
except:
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)

Expand Down

0 comments on commit 3aeb95c

Please sign in to comment.