Skip to content

Commit

Permalink
Merge pull request #89 from CoolMintChocolate/custom-title
Browse files Browse the repository at this point in the history
Add ability to customize result format
  • Loading branch information
g0ldyy authored Aug 5, 2024
2 parents 1d4c950 + 7dc468e commit fb31455
Show file tree
Hide file tree
Showing 5 changed files with 1,300 additions and 1,258 deletions.
6 changes: 6 additions & 0 deletions comet/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ async def health():
"4K",
"Unknown",
],
"resultFormat": [
"Title",
"Size",
"Tracker",
"Languages",
]
}


Expand Down
6 changes: 3 additions & 3 deletions comet/api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from comet.debrid.manager import getDebrid
from comet.utils.general import (
get_language_emoji,
bytes_to_size,
config_check,
get_debrid_extension,
get_indexer_manager,
Expand All @@ -23,6 +22,7 @@
get_torrent_hash,
translate,
get_balanced_hashes,
format_title
)
from comet.utils.logger import logger
from comet.utils.models import database, rtn, settings
Expand Down Expand Up @@ -170,7 +170,7 @@ async def stream(request: Request, b64config: str, type: str, id: str):
results.append(
{
"name": f"[{debrid_extension}⚡] Comet {data['resolution'][0] if data['resolution'] != [] else 'Unknown'}",
"title": f"{data['title']}\n💾 {bytes_to_size(data['size'])} 🔎 {data['tracker'] if 'tracker' in data else '?'}{languages_str}",
"title": format_title(data['title'], data['size'], data['tracker'] if 'tracker' in data else '?', languages_str, config),
"torrentTitle": data["torrent_title"]
if "torrent_title" in data
else None,
Expand Down Expand Up @@ -387,7 +387,7 @@ async def stream(request: Request, b64config: str, type: str, id: str):
results.append(
{
"name": f"[{debrid_extension}⚡] Comet {data['resolution'][0] if data['resolution'] != [] else 'Unknown'}",
"title": f"{data['title']}\n💾 {bytes_to_size(data['size'])} 🔎 {data['tracker']}{languages_str}",
"title": format_title(data['title'], data['size'], data['tracker'] if 'tracker' in data else '?', languages_str, config),
"torrentTitle": data["torrent_title"],
"torrentSize": data["torrent_size"],
"url": f"{request.url.scheme}://{request.url.netloc}/{b64config}/playback/{hash}/{data['index']}",
Expand Down
Loading

0 comments on commit fb31455

Please sign in to comment.