Skip to content

Commit ece4600

Browse files
committed
feat: add media fusion hashes
1 parent 20c38fc commit ece4600

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

.env-sample

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE=realdebrid # if you want your users w
2525
PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY=CHANGE_ME # if you want your users who use the Debrid Stream Proxy not to have to specify Debrid information, but to use the default one instead
2626
TITLE_MATCH_CHECK=True # disable if you only use Jackett / Prowlarr / Torrentio and are sure you're only scraping good titles, for example (keep it True if Zilean is enabled)
2727
CUSTOM_HEADER_HTML=None # only set it if you know what it is
28+
SCRAPE_MEDIAFUSION=False # MediaFusion has better hashes for Indian content

comet/api/stream.py

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
get_indexer_manager,
2525
get_zilean,
2626
get_torrentio,
27+
get_mediafusion,
2728
filter,
2829
get_torrent_hash,
2930
translate,
@@ -258,6 +259,9 @@ async def stream(request: Request, b64config: str, type: str, id: str):
258259
if settings.SCRAPE_TORRENTIO:
259260
tasks.append(get_torrentio(log_name, type, full_id))
260261

262+
if settings.SCRAPE_MEDIAFUSION:
263+
tasks.append(get_mediafusion(log_name, type, full_id))
264+
261265
search_response = await asyncio.gather(*tasks)
262266
for results in search_response:
263267
for result in results:

comet/utils/general.py

+52
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,58 @@ async def get_torrentio(log_name: str, type: str, full_id: str):
423423

424424
return results
425425

426+
async def get_mediafusion(log_name: str, type: str, full_id: str):
427+
results = []
428+
# https://mediafusion.elfhosted.com/stream/series/tt0903747:1:2.json
429+
try:
430+
try:
431+
get_mediafusion = requests.get(
432+
f"https://mediafusion.elfhosted.com/stream/{type}/{full_id}.json"
433+
).json()
434+
except:
435+
get_mediafusion = requests.get(
436+
f"https://mediafusion.elfhosted.com/stream/{type}/{full_id}.json",
437+
proxies={
438+
"http": settings.DEBRID_PROXY_URL,
439+
"https": settings.DEBRID_PROXY_URL,
440+
},
441+
).json()
442+
443+
for torrent in get_mediafusion ["streams"]:
444+
description = torrent.get("description", None)
445+
446+
if not description:
447+
continue
448+
449+
url = torrent.get("url", "")
450+
info_hash = None
451+
if "info_hash=" in url:
452+
info_hash = url.split("info_hash=")[1].split("&")[0] # "&" handles series hashes
453+
454+
if not info_hash:
455+
continue
456+
457+
title = description.split("\n")[0] if "\n" in description else description
458+
tracker = description.split("🔗 ")[1] if "🔗" in description else "Unknown"
459+
460+
results.append(
461+
{
462+
"Title": title,
463+
"InfoHash": info_hash,
464+
"Size": None,
465+
"Tracker": f"MediaFusion|{tracker}",
466+
}
467+
)
468+
469+
logger.info(f"{len(results)} torrents found for {log_name} with MediaFusion")
470+
471+
except Exception as e:
472+
logger.warning(
473+
f"Exception while getting torrents for {log_name} with MediaFusion, your IP is most likely blacklisted (you should try proxying Comet): {e}"
474+
)
475+
pass
476+
477+
return results
426478

427479
async def filter(torrents: list, name: str, year: int):
428480
results = []

0 commit comments

Comments
 (0)