Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit d000333
Merge: 7dc1403 5a6c214
Author: b-igu <[email protected]>
Date:   Sun Aug 25 23:50:19 2024 -0300

    Merge branch 'Audionut:master' into master

commit 7dc1403
Author: b-igu <[email protected]>
Date:   Sun Aug 25 19:48:00 2024 -0300

    Added support to AL
  • Loading branch information
Audionut committed Aug 26, 2024
1 parent 5a6c214 commit ae3cccc
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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
- 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/AL
- 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
Expand Down
9 changes: 7 additions & 2 deletions data/example-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

"TRACKERS" : {
# Which trackers do you want to upload to?
# Available tracker: BLU, BHD, AITHER, STC, STT, SN, THR, R4E, HP, ACM, PTP, LCD, LST, PTER, NBL, ANT, MTV, CBR, RTF, HUNO, BHDTV, LT, PTER, TL, TDC, HDT, OE, RF, OTW, FNP, UTP
# Available tracker: BLU, BHD, AITHER, STC, STT, SN, THR, R4E, HP, ACM, PTP, LCD, LST, PTER, NBL, ANT, MTV, CBR, RTF, HUNO, BHDTV, LT, PTER, TL, TDC, HDT, OE, RF, OTW, FNP, UTP, AL
# Remove the ones not used to save being asked everytime
"default_trackers" : "BLU, BHD, AITHER, STC, STT, SN, THR, R4E, HP, ACM, PTP, LCD, LST, PTER, NBL, ANT, MTV, CBR, RTF, HUNO, BHDTV, LT, PTER, TL, TDC, HDT, OE, RF, OTW, FNP, UTP",
"default_trackers" : "BLU, BHD, AITHER, STC, STT, SN, THR, R4E, HP, ACM, PTP, LCD, LST, PTER, NBL, ANT, MTV, CBR, RTF, HUNO, BHDTV, LT, PTER, TL, TDC, HDT, OE, RF, OTW, FNP, UTP, AL",

"BLU" : {
"useAPI" : False, # Set to True if using BLU
Expand Down Expand Up @@ -214,6 +214,11 @@
"announce_url" : "https://UTP/announce/customannounceurl",
# "anon" : False
},
"AL" : {
"api_key" : "AL api key",
"announce_url" : "https://animelovers.club/announce/customannounceurl",
# "anon" : False
},
"MANUAL" : {
# Uncomment and replace link with filebrowser (https://github.com/filebrowser/filebrowser) link to the Upload-Assistant directory, this will link to your filebrowser instead of uploading to uguu.se
# "filebrowser" : "https://domain.tld/filebrowser/files/Upload-Assistant/"
Expand Down
182 changes: 182 additions & 0 deletions src/trackers/AL.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# -*- coding: utf-8 -*-
# import discord
import asyncio
import requests
import os
import platform
from str2bool import str2bool

from src.trackers.COMMON import COMMON
from src.console import console


class AL():
"""
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 = 'AL'
self.source_flag = 'AnimeLovers'
self.upload_url = 'https://animelovers.club/api/torrents/upload'
self.search_url = 'https://animelovers.club/api/torrents/filter'
self.signature = None
self.banned_groups = [""]
pass

async def get_cat_id(self, category_name):
category_id = {
'MOVIE': '1',
'TV': '2',
}.get(category_name, '1')
return category_id

async def get_type_id(self, type):
type_id = {
'BDMV': '1',
'DISC': '1',
'REMUX': '2',
'ENCODE': '3',
'WEBDL': '4',
'WEBRIP': '5',
'HDTV': '6',
'DVDISO': '7',
'DVDRIP': '8',
'RAW': '9',
'BDRIP': '10',
'COLOR': '11',
'MONO': '12'
}.get(type, '1')
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):
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)
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'])
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(str2bool(str(self.config['TRACKERS'][self.tracker].get('anon', "False")))) == False:
anon = 0
else:
anon = 1

if meta['bdinfo'] != 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').read()
open_torrent = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/[{self.tracker}]{meta['clean_name']}.torrent", 'rb')
files = {'torrent': open_torrent}
data = {
'name' : 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) == 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': 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")
return
else:
console.print(f"[cyan]Request Data:")
console.print(data)
open_torrent.close()

async def search_existing(self, meta):
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.get('edition', "") != "":
params['name'] = params['name'] + f" {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

# Got this from CBR and changed the encoding rename
async def edit_name(self, meta):
name = meta['uuid'].replace('.mkv','').replace('.mp4','').replace(".", " ").replace("DDP2 0","DDP2.0").replace("DDP5 1","DDP5.1").replace("H 264","x264").replace("H 265","x265").replace("DD+7 1","DDP7.1").replace("AAC2 0","AAC2.0").replace('DD5 1','DD5.1').replace('DD2 0','DD2.0').replace('TrueHD 7 1','TrueHD 7.1').replace('DTS-HD MA 7 1','DTS-HD MA 7.1').replace('DTS-HD MA 5 1','DTS-HD MA 5.1').replace("TrueHD 5 1","TrueHD 5.1").replace("DTS-X 7 1","DTS-X 7.1").replace("DTS-X 5 1","DTS-X 5.1").replace("FLAC 2 0","FLAC 2.0").replace("FLAC 2 0","FLAC 2.0").replace("FLAC 5 1","FLAC 5.1").replace("DD1 0","DD1.0").replace("DTS ES 5 1","DTS ES 5.1").replace("DTS5 1","DTS 5.1").replace("AAC1 0","AAC1.0").replace("DD+5 1","DDP5.1").replace("DD+2 0","DDP2.0").replace("DD+1 0","DDP1.0")
return name
5 changes: 3 additions & 2 deletions upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from src.trackers.FNP import FNP
from src.trackers.CBR import CBR
from src.trackers.UTP import UTP
from src.trackers.AL import AL
import json
from pathlib import Path
import asyncio
Expand Down Expand Up @@ -247,12 +248,12 @@ async def do_the_thing(base_dir):
####### Upload to Trackers #######
####################################
common = COMMON(config=config)
api_trackers = ['BLU', 'AITHER', 'STC', 'R4E', 'STT', 'RF', 'ACM','LCD','LST','HUNO', 'SN', 'LT', 'NBL', 'ANT', 'JPTV', 'TDC', 'OE', 'BHDTV', 'RTF', 'OTW', 'FNP', 'CBR', 'UTP']
api_trackers = ['BLU', 'AITHER', 'STC', 'R4E', 'STT', 'RF', 'ACM','LCD','LST','HUNO', 'SN', 'LT', 'NBL', 'ANT', 'JPTV', 'TDC', 'OE', 'BHDTV', 'RTF', 'OTW', 'FNP', 'CBR', 'UTP', 'AL']
http_trackers = ['HDB', 'TTG', 'FL', 'PTER', 'HDT', 'MTV']
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,
'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}
'TL' : TL, 'TDC' : TDC, 'HDT' : HDT, 'MTV': MTV, 'OE': OE, 'BHDTV': BHDTV, 'RTF':RTF, 'OTW': OTW, 'FNP': FNP, 'CBR': CBR, 'UTP': UTP, 'AL':AL}

for tracker in trackers:
if meta['name'].endswith('DUPE?'):
Expand Down

0 comments on commit ae3cccc

Please sign in to comment.