diff --git a/comet/api/core.py b/comet/api/core.py index 75008b9..0738071 100644 --- a/comet/api/core.py +++ b/comet/api/core.py @@ -1,3 +1,4 @@ +import PTT import RTN from fastapi import APIRouter, Request @@ -25,20 +26,9 @@ indexers = settings.INDEXER_MANAGER_INDEXERS web_config = { "indexers": [indexer.replace(" ", "_").lower() for indexer in indexers], "languages": [ - language.replace(" ", "_") - for language in RTN.patterns.language_code_mapping.keys() - ], - "resolutions": [ - "360p", - "480p", - "576p", - "720p", - "1080p", - "1440p", - "2160p", - "4K", - "Unknown", + language for language in PTT.parse.LANGUAGES_TRANSLATION_TABLE.values() ], + "resolutions": [resolution.value for resolution in RTN.models.Resolution], "resultFormat": ["Title", "Metadata", "Size", "Tracker", "Languages"], } diff --git a/comet/api/stream.py b/comet/api/stream.py index 6243237..83544ac 100644 --- a/comet/api/stream.py +++ b/comet/api/stream.py @@ -79,9 +79,12 @@ async def stream(request: Request, b64config: str, type: str, id: str): ) metadata = await get_metadata.json() element = metadata["d"][ - 0 if metadata["d"][0]["id"] not in ["/imdbpicks/summer-watch-guide", "/emmys"] else 1 + 0 + if metadata["d"][0]["id"] + not in ["/imdbpicks/summer-watch-guide", "/emmys"] + else 1 ] - + for element in metadata["d"]: if element["id"] == id: break @@ -166,7 +169,7 @@ async def stream(request: Request, b64config: str, type: str, id: str): data = hash_data["data"] results.append( { - "name": f"[{debrid_extension}⚡] Comet {data['resolution'][0] if data['resolution'] != [] else 'Unknown'}", + "name": f"[{debrid_extension}⚡] Comet {data['resolution']}", "title": format_title(data, config), "torrentTitle": ( data["torrent_title"] @@ -241,7 +244,7 @@ async def stream(request: Request, b64config: str, type: str, id: str): ) else: logger.info( - f"No indexer {'manager ' if not indexer_manager_type else ' '}{'selected by user' if indexer_manager_type else 'defined'} for {log_name}" + f"No indexer {'manager ' if not indexer_manager_type else ''}{'selected by user' if indexer_manager_type else 'defined'} for {log_name}" ) if settings.ZILEAN_URL: @@ -339,23 +342,24 @@ async def stream(request: Request, b64config: str, type: str, id: str): ranked_files = set() for hash in files: - # try: - ranked_file = rtn.rank( - files[hash]["title"], - hash, # , correct_title=name, remove_trash=True - ) - # except: - # continue + try: + ranked_file = rtn.rank( + files[hash]["title"], + hash, # , correct_title=name, remove_trash=True + ) + except: + pass ranked_files.add(ranked_file) sorted_ranked_files = sort_torrents(ranked_files) + len_sorted_ranked_files = len(sorted_ranked_files) logger.info( - f"{len(sorted_ranked_files)} cached files found on {config['debridService']} for {log_name}" + f"{len_sorted_ranked_files} cached files found on {config['debridService']} for {log_name}" ) - if len(sorted_ranked_files) == 0: + if len_sorted_ranked_files == 0: return {"streams": []} sorted_ranked_files = { @@ -409,7 +413,7 @@ async def stream(request: Request, b64config: str, type: str, id: str): data = hash_data["data"] results.append( { - "name": f"[{debrid_extension}⚡] Comet {data['resolution'][0] if data['resolution'] != [] else 'Unknown'}", + "name": f"[{debrid_extension}⚡] Comet {data['resolution']}", "title": format_title(data, config), "torrentTitle": data["torrent_title"], "torrentSize": data["torrent_size"], @@ -453,19 +457,14 @@ async def playback(request: Request, b64config: str, hash: str, index: str): config = config_check(b64config) if not config: return FileResponse("comet/assets/invalidconfig.mp4") - + if ( settings.PROXY_DEBRID_STREAM - and settings.PROXY_DEBRID_STREAM_PASSWORD - == config["debridStreamProxyPassword"] + and settings.PROXY_DEBRID_STREAM_PASSWORD == config["debridStreamProxyPassword"] and config["debridApiKey"] == "" ): - config["debridService"] = ( - settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE - ) - config["debridApiKey"] = ( - settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY - ) + config["debridService"] = settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE + config["debridApiKey"] = settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY async with aiohttp.ClientSession() as session: # Check for cached download link diff --git a/comet/debrid/alldebrid.py b/comet/debrid/alldebrid.py index dc7bf37..a023c2c 100644 --- a/comet/debrid/alldebrid.py +++ b/comet/debrid/alldebrid.py @@ -82,14 +82,14 @@ class AllDebrid: continue filename_parsed = parse(filename) - if episode not in filename_parsed.episode: + if episode not in filename_parsed.episodes: continue if kitsu: - if filename_parsed.season: + if filename_parsed.seasons: continue else: - if season not in filename_parsed.season: + if season not in filename_parsed.seasons: continue files[magnet["hash"]] = { diff --git a/comet/debrid/debridlink.py b/comet/debrid/debridlink.py index b798a67..205f138 100644 --- a/comet/debrid/debridlink.py +++ b/comet/debrid/debridlink.py @@ -70,14 +70,14 @@ class DebridLink: continue filename_parsed = parse(filename) - if episode not in filename_parsed.episode: + if episode not in filename_parsed.episodes: continue if kitsu: - if filename_parsed.season: + if filename_parsed.seasons: continue else: - if season not in filename_parsed.season: + if season not in filename_parsed.seasons: continue files[hash] = { diff --git a/comet/debrid/premiumize.py b/comet/debrid/premiumize.py index bd0ccff..b7c6509 100644 --- a/comet/debrid/premiumize.py +++ b/comet/debrid/premiumize.py @@ -90,14 +90,14 @@ class Premiumize: filename = filenames[index] filename_parsed = parse(filename) - if episode not in filename_parsed.episode: + if episode not in filename_parsed.episodes: continue if kitsu: - if filename_parsed.season: + if filename_parsed.seasons: continue else: - if season not in filename_parsed.season: + if season not in filename_parsed.seasons: continue files[hashes[index]] = { @@ -156,8 +156,8 @@ class Premiumize: if season is not None: filename_parsed = parse(filename) if ( - season in filename_parsed.season - and episode in filename_parsed.episode + season in filename_parsed.seasons + and episode in filename_parsed.episodes ): return file["link"] diff --git a/comet/debrid/realdebrid.py b/comet/debrid/realdebrid.py index accfc3b..b8a54b9 100644 --- a/comet/debrid/realdebrid.py +++ b/comet/debrid/realdebrid.py @@ -75,14 +75,14 @@ class RealDebrid: continue filename_parsed = parse(filename) - if episode not in filename_parsed.episode: + if episode not in filename_parsed.episodes: continue if kitsu: - if filename_parsed.season: + if filename_parsed.seasons: continue else: - if season not in filename_parsed.season: + if season not in filename_parsed.seasons: continue files[hash] = { diff --git a/comet/debrid/torbox.py b/comet/debrid/torbox.py index b5602c3..b629d44 100644 --- a/comet/debrid/torbox.py +++ b/comet/debrid/torbox.py @@ -73,14 +73,14 @@ class TorBox: continue filename_parsed = parse(filename) - if episode not in filename_parsed.episode: + if episode not in filename_parsed.episodes: continue if kitsu: - if filename_parsed.season: + if filename_parsed.seasons: continue else: - if season not in filename_parsed.season: + if season not in filename_parsed.seasons: continue files[torrent["hash"]] = { diff --git a/comet/main.py b/comet/main.py index fb2504b..1694b5a 100644 --- a/comet/main.py +++ b/comet/main.py @@ -129,12 +129,11 @@ def start_log(): "COMET", f"Indexer Manager: {settings.INDEXER_MANAGER_TYPE}|{settings.INDEXER_MANAGER_URL} - Timeout: {settings.INDEXER_MANAGER_TIMEOUT}s", ) + logger.log("COMET", f"Indexers: {', '.join(settings.INDEXER_MANAGER_INDEXERS)}") + logger.log("COMET", f"Get Torrent Timeout: {settings.GET_TORRENT_TIMEOUT}s") else: logger.log("COMET", "Indexer Manager: False") - logger.log("COMET", f"Indexers: {', '.join(settings.INDEXER_MANAGER_INDEXERS)}") - logger.log("COMET", f"Get Torrent Timeout: {settings.GET_TORRENT_TIMEOUT}s") - if settings.ZILEAN_URL: logger.log( "COMET", diff --git a/comet/templates/index.html b/comet/templates/index.html index 2259d16..7fc7779 100644 --- a/comet/templates/index.html +++ b/comet/templates/index.html @@ -593,6 +593,55 @@