feat: add media fusion hashes

This commit is contained in:
Bhanu
2024-11-12 22:51:37 -08:00
parent 20c38fce46
commit ece4600dde
3 changed files with 57 additions and 0 deletions
+1
View File
@@ -25,3 +25,4 @@ PROXY_DEBRID_STREAM_DEBRID_DEFAULT_SERVICE=realdebrid # if you want your users w
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
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)
CUSTOM_HEADER_HTML=None # only set it if you know what it is
SCRAPE_MEDIAFUSION=False # MediaFusion has better hashes for Indian content
+4
View File
@@ -24,6 +24,7 @@ from comet.utils.general import (
get_indexer_manager,
get_zilean,
get_torrentio,
get_mediafusion,
filter,
get_torrent_hash,
translate,
@@ -258,6 +259,9 @@ async def stream(request: Request, b64config: str, type: str, id: str):
if settings.SCRAPE_TORRENTIO:
tasks.append(get_torrentio(log_name, type, full_id))
if settings.SCRAPE_MEDIAFUSION:
tasks.append(get_mediafusion(log_name, type, full_id))
search_response = await asyncio.gather(*tasks)
for results in search_response:
for result in results:
+52
View File
@@ -423,6 +423,58 @@ async def get_torrentio(log_name: str, type: str, full_id: str):
return results
async def get_mediafusion(log_name: str, type: str, full_id: str):
results = []
# https://mediafusion.elfhosted.com/stream/series/tt0903747:1:2.json
try:
try:
get_mediafusion = requests.get(
f"https://mediafusion.elfhosted.com/stream/{type}/{full_id}.json"
).json()
except:
get_mediafusion = requests.get(
f"https://mediafusion.elfhosted.com/stream/{type}/{full_id}.json",
proxies={
"http": settings.DEBRID_PROXY_URL,
"https": settings.DEBRID_PROXY_URL,
},
).json()
for torrent in get_mediafusion ["streams"]:
description = torrent.get("description", None)
if not description:
continue
url = torrent.get("url", "")
info_hash = None
if "info_hash=" in url:
info_hash = url.split("info_hash=")[1].split("&")[0] # "&" handles series hashes
if not info_hash:
continue
title = description.split("\n")[0] if "\n" in description else description
tracker = description.split("🔗 ")[1] if "🔗" in description else "Unknown"
results.append(
{
"Title": title,
"InfoHash": info_hash,
"Size": None,
"Tracker": f"MediaFusion|{tracker}",
}
)
logger.info(f"{len(results)} torrents found for {log_name} with MediaFusion")
except Exception as e:
logger.warning(
f"Exception while getting torrents for {log_name} with MediaFusion, your IP is most likely blacklisted (you should try proxying Comet): {e}"
)
pass
return results
async def filter(torrents: list, name: str, year: int):
results = []