Added delta for eurostreamign

This commit is contained in:
UrloMythus
2025-09-09 12:26:24 +02:00 Unverified
parent 6a9169fc8b
commit 10f381b6d6
+26 -18
View File
@@ -20,7 +20,7 @@ import time
from Src.Utilities.eval import eval_solver from Src.Utilities.eval import eval_solver
import os import os
import json import json
import difflib
import random import random
ES_DOMAIN = config.ES_DOMAIN ES_DOMAIN = config.ES_DOMAIN
@@ -202,18 +202,35 @@ async def scraping_links(atag,MFP,client):
print("Just give up") print("Just give up")
return None,"" return None,""
async def episodes_find(description,season,episode,MFP,client):
episode = episode.zfill(2)
pattern = rf'{season}&#215;{episode}\s*(.*?)(?=<br\s*/?>)'
match = re.findall(pattern, description)
urls= {}
if match:
for episode_details in match:
if "href" in episode_details:
full_url,name = await scraping_links(episode_details.split(' – ', 1)[1],MFP,client)
if full_url:
urls[full_url] = name
return urls
async def search(showname,date,season,episode,MFP,client): async def search(showname,date,season,episode,MFP,client):
headers = random_headers.generate() headers = random_headers.generate()
response = await client.get(ForwardProxy + f"{ES_DOMAIN}/wp-json/wp/v2/search?search={showname}&_fields=id", proxies = proxies, headers = headers) response = await client.get(ForwardProxy + f"{ES_DOMAIN}/wp-json/wp/v2/search?search={quote(showname)}&_fields=id", proxies = proxies, headers = headers)
results = response.json() results = response.json()
for i in results: for i in results:
response = await client.get(ForwardProxy + f"{ES_DOMAIN}/wp-json/wp/v2/posts/{i['id']}?_fields=content", proxies = proxies, headers = headers) response = await client.get(ForwardProxy + f"{ES_DOMAIN}/wp-json/wp/v2/posts/{i['id']}?_fields=content,title", proxies = proxies, headers = headers)
if f'ID articolo non valido' in response.text: if f'ID articolo non valido' in response.text:
continue continue
description = response.json() description = response.json()
title = description['title']['rendered']
description = description['content']['rendered'] description = description['content']['rendered']
ratio = difflib.SequenceMatcher(None, title, showname).ratio()
if ratio >=0.96:
urls = await episodes_find(description,season,episode,MFP,client)
return urls
else:
year_pattern = re.compile(r'(?<!/)(19|20)\d{2}(?!/)') year_pattern = re.compile(r'(?<!/)(19|20)\d{2}(?!/)')
match = year_pattern.search(description) match = year_pattern.search(description)
if match: if match:
@@ -228,17 +245,8 @@ async def search(showname,date,season,episode,MFP,client):
match = year_pattern.search(response_2.text) match = year_pattern.search(response_2.text)
if match: if match:
year = match.group(0) year = match.group(0)
if year == str(date): if abs(int(year) - int(date)) <=1:
episode = episode.zfill(2) urls = await episodes_find(description,season,episode,MFP,client)
pattern = rf'{season}&#215;{episode}\s*(.*?)(?=<br\s*/?>)'
match = re.findall(pattern, description)
urls= {}
if match:
for episode_details in match:
if "href" in episode_details:
full_url,name = await scraping_links(episode_details.split(' – ', 1)[1],MFP,client)
if full_url:
urls[full_url] = name
return urls return urls
@@ -260,7 +268,6 @@ async def eurostreaming(id,client,MFP):
else: else:
showname,date = await get_info_imdb(clean_id,ismovie,type,client) showname,date = await get_info_imdb(clean_id,ismovie,type,client)
print(showname) print(showname)
showname = quote(showname)
urls = await search(showname,date, season,episode,MFP,client) urls = await search(showname,date, season,episode,MFP,client)
return urls return urls
except Exception as e: except Exception as e:
@@ -272,7 +279,7 @@ async def eurostreaming(id,client,MFP):
async def test_euro(): async def test_euro():
from curl_cffi.requests import AsyncSession from curl_cffi.requests import AsyncSession
async with AsyncSession() as client: async with AsyncSession() as client:
results = await eurostreaming("tt6156584:4:5",client,0) results = await eurostreaming("tt2261391:6:1",client,0)
print(results) print(results)
async def test_deltabit(): async def test_deltabit():
@@ -286,4 +293,5 @@ if __name__ == "__main__":
asyncio.run(test_euro()) asyncio.run(test_euro())
#python3 -m Src.API.eurostreaming #python3 -m Src.API.eurostreaming
'''tt11950864''' '''tt11950864
'''