From c534ec7bbe20eb498707bc5962e27c7d2378eaed Mon Sep 17 00:00:00 2001 From: UrloMythus Date: Fri, 21 Feb 2025 23:45:36 +0100 Subject: [PATCH] Fix for ExoPlayer for StreamingCommunity --- Src/API/streamingcommunity.py | 2 -- run.py | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Src/API/streamingcommunity.py b/Src/API/streamingcommunity.py index c7a2233..e31d415 100644 --- a/Src/API/streamingcommunity.py +++ b/Src/API/streamingcommunity.py @@ -331,8 +331,6 @@ async def streaming_community(imdb,client,SC_FAST_SEARCH,MFP): #Uid = URL ID episode_id = await get_season_episode_id(tid,slug,season,episode,version,client) url,quality = await get_episode_link(episode_id,tid,version,client,MFP) - print("MammaMia found results for StreamingCommunity") - print("OK") return url,quality,slug except Exception as e: print("MammaMia: StreamingCommunity failed",e) diff --git a/run.py b/run.py index 106ae4b..3662e1f 100644 --- a/run.py +++ b/run.py @@ -23,7 +23,7 @@ from slowapi.middleware import SlowAPIMiddleware from static.static import HTML from urllib.parse import unquote from Src.Utilities.m3u8 import router as m3u8_clone - +import urllib.parse #Configure Env Vars Global_Proxy = config.Global_Proxy if Global_Proxy == "1": @@ -101,7 +101,19 @@ def respond_with(data): resp.headers['Access-Control-Allow-Origin'] = '*' resp.headers['Access-Control-Allow-Headers'] = '*' return resp +async def transform_mfp(mfp_stream_url,client): + try: + response = await client.get(mfp_stream_url) + data = response.json() + url = data['mediaflow_proxy_url'] + "?api_password=" + data['query_params']['api_password'] + "&d=" + urllib.parse.quote(data['destination_url']) + for i in data['request_headers']: + url += f"&h_{i}=({urllib.parse.quote(data['request_headers'][i])})" + + return url + except Exception as e: + print("Transforing MFP failed",e) + return None @app.get('/config') def config(): return RedirectResponse(url="/") @@ -304,7 +316,8 @@ async def addon_stream(request: Request,config, type, id,): if url_streaming_community is not None: print(f"StreamingCommunity Found Results for {id}") if MFP == "1" and "iframe" in url_streaming_community: - url_streaming_community = f'{MFP_url}/extractor/video?api_password={MFP_password}&d={url_streaming_community}&host=VixCloud&redirect_stream=true' + url_streaming_community = f'{MFP_url}/extractor/video?api_password={MFP_password}&d={url_streaming_community}&host=VixCloud&redirect_stream=false' + url_streaming_community = await transform_mfp(url_streaming_community,client) if "hf.space" in MFP_url: streams['streams'].append({"name":f'{Name}', 'title': f'{Icon}StreamingCommunity\n Sorry StreamingCommunity wont work with MFP hosted on HuggingFace','url': url_streaming_community})