82 lines
2.8 KiB
Python
82 lines
2.8 KiB
Python
from Src.Utilities.info import is_movie
|
|
from bs4 import BeautifulSoup,SoupStrainer
|
|
import re
|
|
import Src.Utilities.config as config
|
|
from fake_headers import Headers
|
|
from Src.Utilities.loadenv import load_env
|
|
from Src.API.extractors.streamhg import streamhg
|
|
from Src.API.extractors.mixdrop import mixdrop
|
|
import json, random
|
|
import logging
|
|
from Src.Utilities.config import setup_logging
|
|
level = config.LEVEL
|
|
logger = setup_logging(level)
|
|
env_vars = load_env()
|
|
GH_PROXY = config.GH_PROXY
|
|
proxies = {}
|
|
if GH_PROXY == "1":
|
|
PROXY_CREDENTIALS = env_vars.get('PROXY_CREDENTIALS')
|
|
proxy_list = json.loads(PROXY_CREDENTIALS)
|
|
proxy = random.choice(proxy_list)
|
|
if proxy == "":
|
|
proxies = {}
|
|
else:
|
|
proxies = {
|
|
"http": proxy,
|
|
"https": proxy
|
|
}
|
|
GH_ForwardProxy = config.GH_ForwardProxy
|
|
if GH_ForwardProxy == "1":
|
|
ForwardProxy = env_vars.get('ForwardProxy')
|
|
else:
|
|
ForwardProxy = ""
|
|
GHD_DOMAIN = config.GHD_DOMAIN
|
|
|
|
random_headers = Headers()
|
|
|
|
|
|
async def search(clean_id,client):
|
|
headers = random_headers.generate()
|
|
response = await client.get(ForwardProxy + f"{GHD_DOMAIN}/set-movie-a/{clean_id}", allow_redirects=True, headers = headers, proxies = proxies)
|
|
if response.status_code != 200:
|
|
logger.warning(f"GuardaHD Failed to fetch search results: {response.status_code}")
|
|
soup = BeautifulSoup(response.text,'lxml',parse_only=SoupStrainer('li'))
|
|
li_tags = soup.find_all('li')
|
|
results = {}
|
|
for tag in li_tags:
|
|
if tag.get('data-link') and (('mixdrop') in tag.text or ('streamhg') in tag.text):
|
|
results[tag.text.strip()] = 'https:' + tag['data-link']
|
|
return results
|
|
|
|
|
|
|
|
async def guardahd(streams,id,client,MFP,MFP_CREDENTIALS):
|
|
try:
|
|
general = await is_movie(id)
|
|
ismovie = general[0]
|
|
clean_id = general[1]
|
|
if ismovie == 0:
|
|
return streams
|
|
results = await search(clean_id,client)
|
|
status = False
|
|
if 'streamhg' in results:
|
|
streams,status = await streamhg(results['streamhg'], client,MFP,MFP_CREDENTIALS,streams,"GuardaHD",proxies, ForwardProxy)
|
|
if 'mixdrop' in results and not status:
|
|
streams,status = await mixdrop(results['mixdrop'],client,MFP,MFP_CREDENTIALS,streams,"GuardaHD",proxies,ForwardProxy,'')
|
|
return streams
|
|
except Exception as e:
|
|
logger.warning(f"MammaMia: GuardaHD Failed {e}")
|
|
return streams
|
|
|
|
async def test_script():
|
|
from curl_cffi.requests import AsyncSession
|
|
async with AsyncSession() as client:
|
|
# Replace with actual id, for example 'anime_id:episode' format
|
|
test_id = "tt16426418" # This is an example ID format
|
|
results = await guardahd({'streams': []},test_id, client,'0','')
|
|
print(results)
|
|
|
|
if __name__ == "__main__":
|
|
import asyncio
|
|
asyncio.run(test_script())
|
|
|