Skip to content

Commit

Permalink
Update OE (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
edge20200 authored Oct 16, 2023
1 parent 0de4d98 commit b8cba88
Showing 1 changed file with 47 additions and 50 deletions.
97 changes: 47 additions & 50 deletions src/trackers/OE.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ def __init__(self, config):
self.source_flag = 'OE'
self.search_url = 'https://onlyencodes.cc/api/torrents/filter'
self.upload_url = 'https://onlyencodes.cc/api/torrents/upload'
self.signature = f"\n[center][url=https://onlyencodes.cc/]Created by L4G's Upload Assistant[/url][/center]"
self.banned_groups = ['AROMA', 'EMBER', 'FGT', 'Hi10', 'LAMA']
self.signature = f"\n[center][url=https://onlyencodes.cc/pages/1]OnlyEncodes Uploader - Powered by L4G's Upload Assistant[/url][/center]"
self.banned_groups = ['0neshot', '3LT0N', '4K4U', '4yEo', '$andra', '[Oj]', 'AFG', 'AkihitoSubs', 'AniHLS', 'Anime Time', 'AnimeRG', 'AniURL', 'AR', 'AROMA', 'ASW', 'aXXo', 'BakedFish', 'BiTOR', 'BHDStudio', 'BRrip', 'bonkai', 'Cleo', 'CM8', 'C4K', 'CrEwSaDe', 'core', 'd3g', 'DDR', 'DeadFish', 'DeeJayAhmed', 'DNL', 'ELiTE', 'EMBER', 'eSc', 'EVO', 'EZTV', 'FaNGDiNG0', 'FGT', 'fenix', 'FUM', 'FRDS', 'FROZEN', 'GalaxyTV', 'GalaxyRG', 'GERMini', 'Grym', 'GrymLegacy', 'HAiKU', 'HD2DVD', 'HDTime', 'Hi10', 'ION10', 'iPlanet', 'JacobSwaggedUp', 'JIVE', 'Judas', 'KiNGDOM', 'LAMA', 'Leffe', 'LiGaS', 'LOAD', 'LycanHD', 'MeGusta,' 'MezRips,' 'mHD,' 'Mr.Deadpool', 'mSD', 'NemDiggers', 'neoHEVC', 'NeXus', 'NhaNc3', 'nHD', 'nikt0', 'nSD', 'NhaNc3', 'NOIVTC', 'pahe.in', 'PlaySD', 'playXD', 'PRODJi', 'ProRes', 'project-gxs', 'PSA', 'QaS', 'Ranger', 'RAPiDCOWS', 'RARBG', 'Raze', 'RCDiVX', 'RDN', 'Reaktor', 'REsuRRecTioN', 'RMTeam', 'ROBOTS', 'rubix', 'SANTi', 'SHUTTERSHIT', 'SpaceFish', 'SPASM', 'SSA', 'TBS', 'Telly,' 'Tenrai-Sensei,' 'TERMiNAL,' 'TM', 'topaz', 'TSP', 'TSPxL', 'Trix', 'URANiME', 'UTR', 'VipapkSudios', 'ViSION', 'WAF', 'Wardevil', 'x0r', 'xRed', 'XS', 'YakuboEncodes', 'YIFY', 'YTS', 'YuiSubs', 'ZKBL', 'ZmN', 'ZMNT']
pass

async def upload(self, meta):
common = COMMON(config=self.config)
await common.edit_torrent(meta, self.tracker, self.source_flag)
await common.unit3d_edit_desc(meta, self.tracker, self.signature, comparison=True)
await common.unit3d_edit_desc(meta, self.tracker, self.signature)
cat_id = await self.get_cat_id(meta['category'])
type_id = await self.get_type_id(meta['video_codec'])
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'])
name = await self.edit_name(meta)
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:
anon = 0
else:
Expand All @@ -51,7 +51,7 @@ async def upload(self, meta):
open_torrent = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/[{self.tracker}]{meta['clean_name']}.torrent", 'rb')
files = {'torrent': open_torrent}
data = {
'name' : name,
'name' : oe_name,
'description' : desc,
'mediainfo' : mi_dump,
'bdinfo' : bd_dump,
Expand All @@ -74,27 +74,29 @@ async def upload(self, meta):
'doubleup' : 0,
'sticky' : 0,
}
headers = {
'User-Agent': f'Upload Assistant/2.1 ({platform.system()} {platform.release()})'
}
params = {
'api_token': self.config['TRACKERS'][self.tracker]['api_key'].strip()
}

# Internal
if self.config['TRACKERS'][self.tracker].get('internal', False) == True:
if meta['tag'] != "" and (meta['tag'][1:] in self.config['TRACKERS'][self.tracker].get('internal_groups', [])):
data['internal'] = 1

if meta.get('category') == "TV":
data['season_number'] = meta.get('season_int', '0')
data['episode_number'] = meta.get('episode_int', '0')
headers = {
'User-Agent': f'Upload Assistant/2.1 ({platform.system()} {platform.release()})'
}
params = {
'api_token': self.config['TRACKERS'][self.tracker]['api_key'].strip()
}

if meta['debug'] == False:
response = requests.post(url=self.upload_url, files=files, data=data, headers=headers, params=params)
try:

console.print(response.json())
except:
console.print("It may have uploaded, go check")
open_torrent.close()
return
else:
console.print(f"[cyan]Request Data:")
Expand All @@ -104,30 +106,8 @@ async def upload(self, meta):


async def edit_name(self, meta):
aither_name = meta['name']
has_eng_audio = False
if meta['is_disc'] != "BDMV":
with open(f"{meta.get('base_dir')}/tmp/{meta.get('uuid')}/MediaInfo.json", 'r', encoding='utf-8') as f:
mi = json.load(f)

for track in mi['media']['track']:
if track['@type'] == "Audio":
if track.get('Language', 'None').startswith('en'):
has_eng_audio = True
if not has_eng_audio:
audio_lang = mi['media']['track'][2].get('Language_String', "").upper()
if audio_lang != "":
aither_name = aither_name.replace(meta['resolution'], f"{audio_lang} {meta['resolution']}", 1)
else:
for audio in meta['bdinfo']['audio']:
if audio['language'] == 'English':
has_eng_audio = True
if not has_eng_audio:
audio_lang = meta['bdinfo']['audio'][0]['language'].upper()
if audio_lang != "":
aither_name = aither_name.replace(meta['resolution'], f"{audio_lang} {meta['resolution']}", 1)
# aither_name = aither_name.replace(meta.get('video_encode', meta.get('video_codec', "")), meta.get('video_encode', meta.get('video_codec', "")).replace('.', ''))
return aither_name
oe_name = meta.get('name')
return oe_name

async def get_cat_id(self, category_name):
category_id = {
Expand All @@ -136,12 +116,32 @@ async def get_cat_id(self, category_name):
}.get(category_name, '0')
return category_id

async def get_type_id(self, type):
async def get_type_id(self, type, tv_pack, video_codec, category):
type_id = {
'HEVC': '10',
'AV1': '14',
'AVC': '15',
'DISC': '19',
'REMUX': '20',
'WEBDL': '21',
}.get(type, '0')
if type == "WEBRIP":
if video_codec == "HEVC":
# x265 Encode
type_id = '10'
if video_codec == 'AV1':
# AV1 Encode
type_id = '14'
if video_codec == 'AVC':
# x264 Encode
type_id = '15'
if type == "ENCODE":
if video_codec == "HEVC":
# x265 Encode
type_id = '10'
if video_codec == 'AV1':
# AV1 Encode
type_id = '14'
if video_codec == 'AVC':
# x264 Encode
type_id = '15'
return type_id

async def get_res_id(self, resolution):
Expand All @@ -161,7 +161,7 @@ async def get_res_id(self, resolution):
return resolution_id





async def search_existing(self, meta):
Expand All @@ -171,25 +171,22 @@ async def search_existing(self, meta):
'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']),
'types[]' : await self.get_type_id(meta['type'], meta.get('tv_pack', 0), meta.get('sd', 0), meta.get('category', "")),
'resolutions[]' : await self.get_res_id(meta['resolution']),
'name' : ""
}
if meta['category'] == 'TV':
params['name'] = params['name'] + f" {meta.get('season', '')}{meta.get('episode', '')}"
params['name'] = f"{meta.get('season', '')}{meta.get('episode', '')}"
if meta.get('edition', "") != "":
params['name'] = params['name'] + f" {meta['edition']}"

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:
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
return dupes

0 comments on commit b8cba88

Please sign in to comment.