From cef29094dc7c14e118d838567ddd818c1bd0e216 Mon Sep 17 00:00:00 2001 From: UrloMythus Date: Mon, 9 Feb 2026 16:49:20 +0100 Subject: [PATCH] Add auto-update domains + some bug fix --- Src/API/cb01.py | 6 ++-- Src/API/guardaflix.py | 19 ++++++++-- Src/API/guardaserie.py | 2 +- Src/API/guardoserie.py | 20 +++++++++-- Src/API/toonitalia.py | 2 +- Src/Utilities/config.py | 1 - Src/Utilities/update_config.py | 64 ++++++++++++++++++++++++++++++++++ run.py | 11 ++++++ 8 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 Src/Utilities/update_config.py diff --git a/Src/API/cb01.py b/Src/API/cb01.py index f1a1c86..e768296 100644 --- a/Src/API/cb01.py +++ b/Src/API/cb01.py @@ -172,14 +172,14 @@ async def series_search_streams(text,search_text,response_text,headers,season,ep if match: streams = await get_maxstream(match.group(2),streams,client) else: - match = re.search(rf'{season}×{episode}\s*–\s*]*href="[^"]*"[^>]*>[^<]*\s– ]*href="[^"]*',response_text) + match = re.search(rf'{season}×{episode}\s*–\s*]*href="[^"]*"[^>]*>[^<]*\s– ]*href="[^"]*.*',response_text) if match: links = match.group(0) soup = BeautifulSoup(links,'lxml',parse_only=SoupStrainer('a')) host_links = soup.find_all('a') mixdrop_real_link = await get_stayonline(host_links[1]['href'],client) status = False - #streams,status = await mixdrop(mixdrop_real_link,client,MFP,MFP_CREDENTIALS,streams,"CB01",proxies,ForwardProxy,"") + streams,status = await mixdrop(mixdrop_real_link,client,MFP,MFP_CREDENTIALS,streams,"CB01",proxies,ForwardProxy,"") if status == False: streams = await get_maxstream(host_links[0]['href'],streams,client) return streams @@ -255,7 +255,7 @@ async def cb01(streams,id,MFP,MFP_CREDENTIALS,client): async def test_animeworld(): from curl_cffi.requests import AsyncSession async with AsyncSession() as client: - test_id = "tt0158552:1:2" # This is an example ID format + test_id = "tt12324366:2:2" # This is an example ID format MFP = "0" results = await cb01({'streams': []},test_id,MFP,['test','test'],client) print(results) diff --git a/Src/API/guardaflix.py b/Src/API/guardaflix.py index 5e3a2ea..5aa9916 100644 --- a/Src/API/guardaflix.py +++ b/Src/API/guardaflix.py @@ -9,6 +9,7 @@ from Src.API.extractors.uqload import uqload from Src.API.extractors.dropload import dropload import logging from Src.Utilities.config import setup_logging +from Src.Utilities.update_config import update_site import json import random level = config.LEVEL @@ -36,7 +37,15 @@ if GF_ForwardProxy == "1": else: ForwardProxy = "" - +async def new_domain(url,data,headers,proxies,ForwardProxy,client): + url = url.split('/wp-admin')[0] + headers['Origin'] = url + headers['Referer'] = f'{url}/' + response = await client.post(ForwardProxy + f'{url}/wp-admin/admin-ajax.php', data = data, headers = headers, proxies = proxies) + if response.status_code != 200: + logger.warning(f"Guardaflix Failed to fetch search results: {response.status_code}") + result = update_site(client,['guardaplay','Guardaflix']) + return response.text async def get_player(page_link,MFP, MFP_CREDENTIALS,client, headers,streams): response = await client.get(ForwardProxy + page_link, headers= headers, proxies = proxies) @@ -63,9 +72,13 @@ async def search(showname,date,MFP,MFP_CREDENTIALS,client,streams): 'term': showname, } response = await client.post(ForwardProxy + f'{GF_DOMAIN}/wp-admin/admin-ajax.php', headers=headers, data=data, proxies = proxies) + text = response.text if response.status_code != 200: - logger.warning(f"Guardaflix Failed to fetch search results: {response.status_code}") - soup = BeautifulSoup(response.text,'lxml', parse_only= SoupStrainer('a')) + if response.status_code == 400: + text = await new_domain(response.url,data,headers,proxies,ForwardProxy,client) + if len(text) < 10: + logger.warning(f"Guardaflix Failed to fetch search results: {response.status_code}") + soup = BeautifulSoup(text,'lxml', parse_only= SoupStrainer('a')) a_tags = soup.find_all('a') for a in a_tags: href = a['href'] diff --git a/Src/API/guardaserie.py b/Src/API/guardaserie.py index 299b4db..8734818 100644 --- a/Src/API/guardaserie.py +++ b/Src/API/guardaserie.py @@ -117,7 +117,7 @@ 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 = "tt10919420:1:1" # This is an example ID format tt0460649 + test_id = "tt12324366:2:2" # This is an example ID format tt0460649 results = await guardaserie({'streams': []},test_id, client) print(results) diff --git a/Src/API/guardoserie.py b/Src/API/guardoserie.py index c5c287a..7911f65 100644 --- a/Src/API/guardoserie.py +++ b/Src/API/guardoserie.py @@ -10,6 +10,7 @@ from Src.API.extractors.loadm import loadm from Src.API.extractors.dropload import dropload import logging from Src.Utilities.config import setup_logging +from Src.Utilities.update_config import update_site level = config.LEVEL import json import random @@ -32,12 +33,21 @@ if GO_PROXY == "1": "https": proxy } GO_ForwardProxy = config.GO_ForwardProxy + if GO_ForwardProxy == "1": ForwardProxy = env_vars.get('ForwardProxy') else: ForwardProxy = "" - +async def new_domain(url,data,headers,proxies,ForwardProxy,client): + url = url.split('/wp-admin')[0] + headers['Origin'] = url + headers['Referer'] = f'{url}/' + response = await client.post(ForwardProxy + f'{url}/wp-admin/admin-ajax.php', data = data, headers = headers, proxies = proxies) + if response.status_code != 200: + logger.warning(f"Guardoserie Failed to fetch search results: {response.status_code}") + result = await update_site(client,['guardoserie_2','Guardoserie']) + return response.text async def get_player(page_link,MFP,MFP_CREDENTIALS,client, headers, streams): response = await client.get(ForwardProxy + page_link, headers= headers, proxies = proxies) @@ -63,9 +73,13 @@ async def search(showname,date,season,episode,MFP, MFP_CREDENTIALS,ismovie,clien showname = quote(showname) data = f's={showname}&action=searchwp_live_search&swpengine=default&swpquery={showname}' response = await client.post(ForwardProxy + f'{GO_DOMAIN}/wp-admin/admin-ajax.php', data = data, headers = headers, proxies = proxies) + text = response.text if response.status_code != 200: - logger.warning(f"Guardoserie Failed to fetch search results: {response.status_code}") - soup = BeautifulSoup(response.text,'lxml', parse_only= SoupStrainer('a', class_='ss-title')) + if response.status_code == 400: + text = await new_domain(response.url,data,headers,proxies,ForwardProxy,client) + if len(text) < 10: + logger.warning(f"Guardoserie Failed to fetch search results: {response.status_code}") + soup = BeautifulSoup(text,'lxml', parse_only= SoupStrainer('a', class_='ss-title')) a_tags = soup.find_all('a') for a in a_tags: href = a['href'] diff --git a/Src/API/toonitalia.py b/Src/API/toonitalia.py index ab2c7e0..cc846f0 100644 --- a/Src/API/toonitalia.py +++ b/Src/API/toonitalia.py @@ -114,7 +114,7 @@ async def toonitalia(streams,id,client,MFP,MFP_CREDENTIALS): async def test_toonitalia(): from curl_cffi.requests import AsyncSession async with AsyncSession() as client: - results = await toonitalia({'streams': []},"tt1466074:1:1",client,"0",['test','test']) + results = await toonitalia({'streams': []},"tt0096697:1:1",client,"0",['test','test']) print(results) diff --git a/Src/Utilities/config.py b/Src/Utilities/config.py index 7ddde7b..a167eea 100644 --- a/Src/Utilities/config.py +++ b/Src/Utilities/config.py @@ -5,7 +5,6 @@ import logging with open('config.json') as f: # Load JSON data from file config = json.load(f) - # Accessing SC_DOMAIN SITE = config["Siti"] SC_DOMAIN = SITE["StreamingCommunity"]['url'] diff --git a/Src/Utilities/update_config.py b/Src/Utilities/update_config.py new file mode 100644 index 0000000..229d41b --- /dev/null +++ b/Src/Utilities/update_config.py @@ -0,0 +1,64 @@ +link = 'https://raw.githubusercontent.com/Arrowar/SC_Domains/main/domains.json' +import json +import os +import logging +from Src.Utilities.config import setup_logging +import Src.Utilities.config as config + +level = config.LEVEL +logger = setup_logging(level) + +async def fetch_domain(client,site_name): + response = await client.get(link) + data = response.json() + domain = data[site_name[0]]['full_url'][:-1] + return domain +def write_config(domain,site_name): + try: + json_file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'config.json') + + with open(json_file_path, 'r') as json_file: + config_data = json.load(json_file) + try: + config_data['Siti'][site_name[1]]['url'] = domain + with open(json_file_path, 'w') as json_file: + json.dump(config_data, json_file, indent=4) + return True + except Exception as e: + with open(json_file_path, 'w') as json_file: + json.dump(config_data, json_file, indent=4) + logger.info('Failed to write into config: ',e) + return False + except Exception as e: + logger.info('Failed to write into config: ',e) + return False + + +async def update_site(client,site_name): + try: + domain = await fetch_domain(client,site_name) + result = write_config(domain,site_name) + return result + except Exception as e: + return False +async def update_all_sites(client): + try: + sites = [['cb01new','CB01'],['guardaserie','Guardaserie'],['eurostreamings','Eurostreaming'],['guardaplay','Guardaflix'],['guardoserie_2','Guardoserie'],['animeworld','AnimeWorld'],['toonitalia','Toonitalia']] + for item in sites: + domain = await fetch_domain(client,item) + write_config(domain,item) + except Exception as e: + logger.info('Failed to update domains: ',e) +async def test_update_site(): + from curl_cffi.requests import AsyncSession + async with AsyncSession() as client: + result = await update_site(client,['guardoserie_2','Guardoserie']) + + #result = await update_all_sites(client) + #domain = await update_site(client,['eurostreamings','Eurostreaming']) + #write_config(domain,['eurostreamings','Eurostreaming']) + + +if __name__ == "__main__": + import asyncio + asyncio.run(test_update_site()) \ No newline at end of file diff --git a/run.py b/run.py index cff819f..ebc9013 100644 --- a/run.py +++ b/run.py @@ -19,6 +19,7 @@ from Src.API.realtime import search_catalog as realtime from Src.API.realtime import meta_catalog as meta_catalog_realtime from Src.API.realtime import realtime as streams_realtime from Src.Utilities.dictionaries import STREAM,extra_sources,provider_map +from Src.Utilities.update_config import update_all_sites from Src.API.epg import tivu, tivu_get,epg_guide,convert_bho_1,convert_bho_2,convert_bho_3 from Src.API.extractors.uprot import get_uprot_numbers,generate_uprot_txt import logging @@ -346,6 +347,16 @@ async def execute_uprot(request: Request,user_input = Form(...),PHPSESSID: str = elif status == False: return static.TemplateResponse('uprot.html',{'request':request,"image_url": 'https://tinyurl.com/tryagaindumb'}) +@app.get('/update') +async def update(request: Request): + async with AsyncSession(proxies = proxies) as client: + result = await update_all_sites(client) + if result: + return JSONResponse(content={"message": "200"}) + if not result: + return JSONResponse(content={"message": "Failed"}) + + if __name__ == '__main__': import uvicorn uvicorn.run("run:app", host=HOST, port=PORT, log_level=level) \ No newline at end of file