Skip to content

Commit

Permalink
Add modq and drafts to LST
Browse files Browse the repository at this point in the history
  • Loading branch information
LostRager committed Sep 4, 2024
1 parent 4352cb3 commit 7034c4e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
4 changes: 3 additions & 1 deletion data/example-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@
"LST": {
"api_key": "LST api key",
"announce_url": "https://lst.gg/announce/customannounceurl",
# "anon" : False
# "anon" : False,
# "modq" : False,
# "draft" : False
},
"LT": {
"api_key": "LT api key",
Expand Down
3 changes: 2 additions & 1 deletion src/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def parse(self, args, meta):
parser.add_argument('-nh', '--nohash', action='store_true', required=False, help="Don't hash .torrent")
parser.add_argument('-rh', '--rehash', action='store_true', required=False, help="DO hash .torrent")
parser.add_argument('-ps', '--piece-size-max', dest='piece_size_max', nargs='*', required=False, help="Maximum piece size in MiB", choices=[1, 2, 4, 8, 16], type=int)
parser.add_argument('-dr', '--draft', action='store_true', required=False, help="Send to drafts (BHD)")
parser.add_argument('-dr', '--draft', action='store_true', required=False, help="Send to drafts (BHD, LST)")
parser.add_argument('-mq', '--modq', action='store_true', required=False, help="Send to modQ")
parser.add_argument('-mps', '--max-piece-size', nargs='*', required=False, help="Set max piece size allowed in MiB for default torrent creation (default 64 MiB)", choices=['2', '4', '8', '16', '32', '64', '128'])
parser.add_argument('-client', '--client', nargs='*', required=False, help="Use this torrent client instead of default")
parser.add_argument('-qbt', '--qbit-tag', dest='qbit_tag', nargs='*', required=False, help="Add to qbit with this tag")
Expand Down
10 changes: 10 additions & 0 deletions src/trackers/LST.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ async def upload(self, meta):
cat_id = await self.get_cat_id(meta['category'], meta.get('keywords', ''), meta.get('service', ''))
type_id = await self.get_type_id(meta['type'])
resolution_id = await self.get_res_id(meta['resolution'])
modq = await self.get_flag(meta, 'modq')
draft = await self.get_flag(meta, 'draft')
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'))
Expand Down Expand Up @@ -119,6 +121,8 @@ async def upload(self, meta):
'free': 0,
'doubleup': 0,
'sticky': 0,
'mod_queue_opt_in': modq,
'draft_queue_opt_in': draft,
}

# Internal
Expand Down Expand Up @@ -152,6 +156,12 @@ async def upload(self, meta):
console.print(data)
open_torrent.close()

async def get_flag(self, meta, flag_name):
config_flag = self.config['TRACKERS'][self.tracker].get(flag_name)
if config_flag:
return 1
return 1 if meta.get(flag_name, False) else 0

async def search_existing(self, meta):
dupes = []
console.print("[yellow]Searching for existing torrents on site...")
Expand Down
27 changes: 25 additions & 2 deletions upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async def do_the_thing(base_dir):
for key, value in saved_meta.items():
overwrite_list = [
'trackers', 'dupe', 'debug', 'anon', 'category', 'type', 'screens', 'nohash', 'manual_edition', 'imdb', 'tmdb_manual', 'mal', 'manual',
'hdb', 'ptp', 'blu', 'no_season', 'no_aka', 'no_year', 'no_dub', 'no_tag', 'no_seed', 'client', 'desclink', 'descfile', 'desc', 'draft', 'region', 'freeleech',
'hdb', 'ptp', 'blu', 'no_season', 'no_aka', 'no_year', 'no_dub', 'no_tag', 'no_seed', 'client', 'desclink', 'descfile', 'desc', 'draft', 'modq', 'region', 'freeleech',
'personalrelease', 'unattended', 'season', 'episode', 'torrent_creation', 'qbit_tag', 'qbit_cat', 'skip_imghost_upload', 'imghost', 'manual_source', 'webdv', 'hardcoded-subs'
]
if meta.get(key, None) != value and key in overwrite_list:
Expand Down Expand Up @@ -247,7 +247,7 @@ async def do_the_thing(base_dir):
####### Upload to Trackers ####### # noqa #F266
####################################
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', 'AL', 'HDB', 'SHRI']
api_trackers = ['BLU', 'AITHER', 'STC', 'R4E', 'STT', 'RF', 'ACM', 'LCD', 'HUNO', 'SN', 'LT', 'NBL', 'ANT', 'JPTV', 'TDC', 'OE', 'BHDTV', 'RTF', 'OTW', 'FNP', 'CBR', 'UTP', 'AL', 'HDB', 'SHRI']
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,
Expand Down Expand Up @@ -346,6 +346,29 @@ async def do_the_thing(base_dir):
await bhd.upload(meta)
await client.add_to_client(meta, "BHD")

if tracker == "LST":
lst = LST(config=config)
modq, draft = await asyncio.gather(lst.get_flag(meta, 'modq'), lst.get_flag(meta, 'draft'))

modq = 'Yes' if modq else 'No'
draft = 'Yes' if draft else 'No'

upload_to_lst = meta['unattended'] or cli_ui.ask_yes_no(f"Upload to LST? (draft: {draft}) (modq: {modq}) {debug}", default=meta['unattended'])
if not upload_to_lst:
return

console.print("Uploading to LST")

if check_banned_group('LST', lst.banned_groups, meta):
return

dupes = await lst.search_existing(meta)
dupes = await common.filter_dupes(dupes, meta)
meta = dupe_check(dupes, meta)
if meta['upload']:
await lst.upload(meta)
await client.add_to_client(meta, lst.tracker)

if tracker == "THR":
if meta['unattended']:
upload_to_thr = True
Expand Down

0 comments on commit 7034c4e

Please sign in to comment.