From 3324d8edff949bb5854ecf85666a57e9d1083834 Mon Sep 17 00:00:00 2001 From: UrloMythus Date: Thu, 19 Sep 2024 18:07:27 +0200 Subject: [PATCH] Fix Okru+ fix skystreaming --- README.md | 2 +- Src/API/cb01.py | 263 ++++++++++++++++++++++++++++++++++ Src/API/cool.py | 20 ++- Src/API/ddlstream.py | 161 +++++++++++++++++++++ Src/API/epg.py | 7 +- Src/API/filmpertutti.py | 7 +- Src/API/lordchannel.py | 12 +- Src/API/okru.py | 26 ++-- Src/API/streamingcommunity.py | 13 +- Src/API/streamingwatch.py | 32 ++++- Src/API/tantifilm.py | 3 +- Src/API/webru.py | 18 ++- Src/API/whvx.py | 126 ++++++++++++++++ Src/Utilities/dictionaries.py | 26 +++- Src/Utilities/info.py | 41 ++++++ config.json | 65 +++++---- run.py | 18 ++- 17 files changed, 761 insertions(+), 79 deletions(-) create mode 100644 Src/API/cb01.py create mode 100644 Src/API/ddlstream.py create mode 100644 Src/API/whvx.py diff --git a/README.md b/README.md index 6979103..abbeb5b 100644 --- a/README.md +++ b/README.md @@ -292,7 +292,7 @@ Open your instance URL and configure MammaMia. Once you are done you can click o -Here is [linked](https://developer.themoviedb.org/docs/getting-started) a tutorial about how to get a TMDB KEY +Here is [linked](https://www.themoviedb.org/settings/api) a tutorial about how to get a TMDB KEY diff --git a/Src/API/cb01.py b/Src/API/cb01.py new file mode 100644 index 0000000..f7f432e --- /dev/null +++ b/Src/API/cb01.py @@ -0,0 +1,263 @@ +import re +from bs4 import BeautifulSoup,SoupStrainer +from Src.Utilities.info import is_movie,get_info_tmdb,get_info_imdb +from Src.Utilities.convert import get_TMDb_id_from_IMDb_id +from fake_headers import Headers + +fake_headers = Headers() + +async def get_stayonline(link,client): + headers = { + 'origin': 'https://stayonline.pro', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 OPR/111.0.0.0', + 'x-requested-with': 'XMLHttpRequest', + } + data = {'id': link.split("/")[-2], 'ref': ''} + response = await client.post('https://stayonline.pro/ajax/linkEmbedView.php', headers=headers, data=data) + real_url = response.json()['data']['value'] + print(real_url) + return real_url + + +async def get_uprot(link,client): + if "msf" in link: + link = link.replace("msf","mse") + + headers = fake_headers.generate() + response = await client.get(link, headers=headers, allow_redirects=True, timeout=10) + soup = BeautifulSoup(response.text, "lxml") + maxstream_url = soup.find("a") + maxstream_url = maxstream_url.get("href") + return maxstream_url + +async def get_true_link_mixdrop(real_link,client): + try: + import string + headers = fake_headers.generate() + response = await client.get(real_link, headers=headers, allow_redirects=True,timeout = 30) + [s1, s2] = re.search(r"\}\('(.+)',.+,'(.+)'\.split", response.text).group(1, 2) + schema = s1.split(";")[2][5:-1] + terms = s2.split("|") + charset = string.digits + string.ascii_letters + d = dict() + for i in range(len(terms)): + d[charset[i]] = terms[i] or charset[i] + s = 'https:' + for c in schema: + s += d[c] if c in d else c + print(s) + return s + except Exception as e: + return None +async def get_true_link_maxstream(maxstream_url,client): + headers = fake_headers.generate() + # Send a GET request to the Maxstream URL + response = await client.get(maxstream_url, headers=headers, allow_redirects=True, timeout=10) + [s1, s2] = re.search(r"\}\('(.+)',.+,'(.+)'\.split", response.text).group(1, 2) + terms = s2.split("|") + urlset_index = terms.index('urlset') + hls_index = terms.index('hls') + sources_index = terms.index('sources') + result = terms[urlset_index + 1 : hls_index] + reversed_elements = result[::-1] + first_part = terms[hls_index +1 : sources_index] + reversed_first_part = first_part[::-1] + first_url_part = "" + for first_part in reversed_first_part: + if "0" in first_part: + first_url_part += first_part + else: + first_url_part += first_part + "-" + + + + base_url = f"https://{first_url_part}.host-cdn.net/hls/" + if len(reversed_elements) == 1: + final_url = base_url + "," + reversed_elements[0] + ".urlset/master.m3u8" + lenght = len(reversed_elements) + i = 1 + for element in reversed_elements: + base_url += element + "," + if lenght == i: + base_url += ".urlset/master.m3u8" + else: + i += 1 + final_url = base_url + return final_url + +async def search_movie(showname,date,client): + try: + showname = showname.replace(" ","+") + headers = fake_headers.generate() + headers['Referer'] = 'https://cb01.technology/' + query = f'https://cb01.technology/?s={showname}' + response = await client.get(query,headers=headers) + soup = BeautifulSoup(response.text, 'lxml',parse_only=SoupStrainer('div', class_='card-content')) + cards = soup.find_all('div', class_='card-content') + year_pattern = re.compile(r'(19|20)\d{2}') + for card in cards: + # Find the link inside the current card + link_tag = card.find('h3', class_='card-title').find('a') + href = link_tag['href'] + + # Find the date span and extract possible years + date_span = card.find('span', style=re.compile('color')) + if date_span: + date_text = date_span.text + # Search for the first occurrence of a year (starting with 19 or 20) + match = year_pattern.search(date_text) + if match: + year = match.group(0) + if year == date : # Check if the year is 2011 + print(f"Link: {href}") + return href + except Exception as e: + print(f'MammaMia: Error in search_series cb01: {e}') + + +async def search_series(showname,date,client): + try: + showname = showname.replace(" ","+") + headers = fake_headers.generate() + headers['Referer'] = 'https://cb01.technology/serietv/' + query = f'https://cb01.technology/serietv/?s={showname}' + response = await client.get(query,headers=headers) + soup = BeautifulSoup(response.text, 'lxml',parse_only=SoupStrainer('div', class_='card-content')) + cards = soup.find_all('div', class_='card-content') + year_pattern = re.compile(r'(19|20)\d{2}') + for card in cards: + # Find the link inside the current card + link_tag = card.find('h3', class_='card-title').find('a') + href = link_tag['href'] + + # Find the date span and extract possible years + date_span = card.find('span', style=re.compile('color')) + if date_span: + date_text = date_span.text + # Search for the first occurrence of a year (starting with 19 or 20) + match = year_pattern.search(date_text) + if match: + year = match.group(0) + if year == date : # Check if the year is 2011 + print(f"Link: {href}") + return href + except Exception as e: + print(f'MammaMia: Error in search_series cb01: {e}') + +async def movie_redirect_url(link,client): + headers = fake_headers.generate() + response = client.get(link, headers=headers, allow_redirects=True, timeout=10) + # Extract the redirect URL from the HTML + soup = BeautifulSoup(response.text, "lxml",parse_only=SoupStrainer('div', id='iframen1')) + redirect_url = soup.find("div", id="iframen1").get("data-src") + return redirect_url +async def series_redirect_url(link,season,episode,client): + if len(episode) == 1: + episode = f'0{episode}' + headers = fake_headers.generate() + response = await client.get(link, headers=headers, allow_redirects=True, timeout=10) + soup = BeautifulSoup(response.text, "lxml") + seasons_text = soup.find_all('div', class_='sp-head') + for season_text in seasons_text: + text = season_text.text + if f'STAGIONE' in text and f'{season}' in text: + text = text.replace("STAGIONE","").replace("ITA", "") + if "A" in text: + if len(season) == 1: + season = f'0{season}' + sp_body = season_text.find_next('div', class_='sp-body') + link_tag = sp_body.find('a') + uprot_long = link_tag.get('href') + response = await client.get(uprot_long, headers=headers, allow_redirects=True, timeout=10) + season = "01" + episode = "04" + pattern1 = rf"(?i)\S*?\.{season}x{episode}\S*?\.mkv.*?href=['\"](.*?)['\"]" + pattern2 = rf"\S*\.S{season}E{episode}\S*?\.mkv.*?href=['\"](.*?)['\"]" + match = re.search(pattern1, response.text) + if match: + maxstream_link = match.group(1) + else: + match = re.search(pattern2, response.text) + if match: + maxstream_link = match.group(1) + print(maxstream_link) + if "stayonline" in maxstream_link: + maxstream_link =await get_stayonline(maxstream_link,client) + maxstream_real_link = await get_uprot(maxstream_link,client) + final_url = await get_true_link_maxstream(maxstream_real_link,client) + print(final_url) + + else: + pattern = re.compile(r'4×03\s*–.*?Maxstream\s*–.*?Mixdrop', re.DOTALL) + match = pattern.search(response.text) + maxstream_link = match.group(1) + mixdrop_link = match.group(2) + print(f"Maxstream: {maxstream_link}") + print(f"Mixdrop: {mixdrop_link}") + mixdrop_real_link = await get_stayonline(mixdrop_link,client) + final_url = await get_true_link_mixdrop(mixdrop_real_link,client) + if final_url == None: + if "stayonline" in maxstream_link: + maxstream_link =await get_stayonline(maxstream_link,client) + maxstream_real_link = await get_uprot(maxstream_link,client) + final_url = await get_true_link_maxstream(maxstream_real_link,client) + print(final_url) + + + + + +async def cb01(id,client): + try: + general = is_movie(id) + ismovie = general[0] + real_id = general[1] + type = "Cb01" + if "tt" in id: + showname, date = await get_info_imdb(real_id,ismovie,type,client) + elif "tmdb" in real_id: + showname, date = get_info_tmdb(real_id,ismovie,type) + if ismovie == 0: + season = general[2] + episode = general[3] + link = await search_series(showname,date,client) + redirect_url = await series_redirect_url(link,season,episode,client) + elif ismovie == 1: + season = None + episode = None + link = await search_movie(showname,date,client) + redirect_url = await movie_redirect_url(link,client) + except Exception as e: + print(f'MammaMia: Error in cb01: {e}') + return None + + + + + + + + + + + + + + + + + + +''' +async def test_animeworld(): + from curl_cffi.requests import AsyncSession + async with AsyncSession() as client: + # Replace with actual id, for example 'anime_id:episode' format + test_id = "tt0158552:1:1" # This is an example ID format + results = await cb01(test_id, client) + +if __name__ == "__main__": + import asyncio + asyncio.run(test_animeworld()) +''' + diff --git a/Src/API/cool.py b/Src/API/cool.py index 15b916a..fe9fc79 100644 --- a/Src/API/cool.py +++ b/Src/API/cool.py @@ -4,6 +4,7 @@ from Src.Utilities.convert import get_TMDb_id_from_IMDb_id from Src.Utilities.loadenv import load_env env_vars = load_env() MYSTERIUS_KEY = env_vars.get('MYSTERIUS_KEY') + async def get_links(slug,season,episode,ismovie,client): try: headers = { @@ -13,7 +14,7 @@ async def get_links(slug,season,episode,ismovie,client): Auths = response.json() Bearer = Auths.get('cookie') ap_session = Auths.get('auth') - + cookies = {'ap_session': ap_session} headers = { @@ -33,6 +34,7 @@ async def get_links(slug,season,episode,ismovie,client): request_url =f'https://altadefinizione-originale.com/api/post/urls/stream/{slug}/{season}/{episode}' print(request_url) response = await client.get(request_url,cookies=cookies,headers=headers) + print(response.text) try: video_data = response.json() # Assuming this is the JSON response containing video streams if 'streams' not in video_data: @@ -63,7 +65,7 @@ async def get_links(slug,season,episode,ismovie,client): print(f"JSONDecodeError: {e}") return None - except client.RequestException as e: + except Exception as e: print(f"Request error: {e}") return None @@ -143,4 +145,16 @@ async def cool(imdb,client): return results except Exception as e: print("Cool Error",e) - return None \ No newline at end of file + return None +''' +async def test_animeworld(): + from curl_cffi.requests import AsyncSession + async with AsyncSession() as client: + # Replace with actual id, for example 'anime_id:episode' format + test_id = "tt1839578:1:1" # This is an example ID format + results = await cool(test_id, client) + +if __name__ == "__main__": + import asyncio + asyncio.run(test_animeworld()) +''' \ No newline at end of file diff --git a/Src/API/ddlstream.py b/Src/API/ddlstream.py new file mode 100644 index 0000000..0f61ae5 --- /dev/null +++ b/Src/API/ddlstream.py @@ -0,0 +1,161 @@ +import requests +import re +from bs4 import BeautifulSoup, SoupStrainer +from Src.Utilities.info import get_info_imdb, is_movie, get_info_tmdb +import urllib.parse +cookies = { + 'ips4_device_key': 'b6f084be79c28bb53ecfc556fd7a2a70', + 'ips4_IPSSessionFront': 'f2b9db91793e084cf2003a07c563e6aa', + 'ips4_member_id': '4029711', + 'ips4_login_key': '41b6a70b16cce2fd39482f5b21a9c35f', + } + +async def search_series(client,id,season,episode,showname): + showname = showname.replace(" ", "%20").replace("–", "+").replace("—","+") + response = await client.get(f"https://ddlstreamitaly.co/search/?&q={showname}%20{season}%20Streaming&type=videobox_video&quick=1&nodes=11&search_and_or=and&search_in=titles&sortby=relevancy") + soup = BeautifulSoup(response.text, 'lxml',parse_only=SoupStrainer('a')) + a_tags = soup.find_all('a', {'data-linktype': 'link'}) + for a in a_tags: + href = a['href'] + response = await client.get(href, cookies = cookies) + soup = BeautifulSoup(response.text, 'lxml') + movie_ids = soup.find_all('a',{'rel':'external nofollow'}) + for database in movie_ids: + link = database['href'] + real_id = link.split('/')[4] + if real_id == id: + meta_description = soup.find('meta',{'name':'description'}) + content = meta_description['content'] + if f"Stagione {season}" in content: + return href + else: + continue + else: + continue + +async def get_episode(client,link,episode): + headers = { + 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0', + 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8', + 'Accept-Language': 'en-US,en;q=0.5', + # 'Accept-Encoding': 'gzip, deflate, br, zstd', + 'Referer': link, + 'DNT': '1', + 'Sec-GPC': '1', + 'Upgrade-Insecure-Requests': '1', + 'Sec-Fetch-Dest': 'document', + 'Sec-Fetch-Mode': 'navigate', + 'Sec-Fetch-Site': 'same-origin', + 'Sec-Fetch-User': '?1', + 'Connection': 'keep-alive', + # 'Cookie': 'ips4_device_key=b6f084be79c28bb53ecfc556fd7a2a70; ips4_IPSSessionFront=f2b9db91793e084cf2003a07c563e6aa; ips4_ipsTimezone=Europe/Rome; ips4_hasJS=true; ips4_noCache=1; ips4_announcement_3=true; ips4_member_id=4029711; ips4_login_key=41b6a70b16cce2fd39482f5b21a9c35f; ips4_loggedIn=1725985598', + 'Priority': 'u=1', + 'Pragma': 'no-cache', + 'Cache-Control': 'no-cache', + } + params = { + 'area': 'online', + } + + + + episode = "6" + response = await client.get(link, cookies = cookies, headers = headers, params = params, impersonate="chrome120") + print(link) + + pattern = rf']*>\s*Part {episode}\s*' + match = re.search(pattern, response.text) + mp4_link = match.group(1) + mp4_link = mp4_link.replace("&","") + mp4_link = mp4_link.replace(";","&") + return mp4_link + +async def search_movie(client,showname,id): + showname = showname.replace(" ", "%20").replace("–", "+").replace("—","+") + showname = urllib.parse.quote_plus(showname) + link = f"https://ddlstreamitaly.co/search/?&q={showname}%20Streaming&quick=1&nodes=11&search_and_or=and&search_in=titles&sortby=relevancy" + response = await client.get(link,impersonate = "chrome120") + soup = BeautifulSoup(response.text, 'lxml',parse_only=SoupStrainer('a')) + a_tags = soup.find_all('a', {'data-linktype': 'link'}) + for a in a_tags: + href = a['href'] + response = requests.get(href, cookies = cookies) + soup = BeautifulSoup(response.text, 'lxml', parse_only=SoupStrainer('a')) + movie_ids = soup.find_all('a',{'rel':'external nofollow'}) + for database in movie_ids: + link = database['href'] + real_id = link.split('/')[4] + if real_id == id: + return href + else: + continue + return + + + +async def get_mp4(client,link): + response = await client.get(link, cookies = cookies) + soup = BeautifulSoup(response.text,'lxml',parse_only=SoupStrainer('source')) + source_tag = soup.find('source') + final_url = source_tag['src'] + res = source_tag.get('res') + return final_url,res + + + + + + + + + + + + + + +async def ddlstream(imdb,client): + try: + general = is_movie(imdb) + ismovie = general[0] + id = general[1] + type = "DDLStream" + if "tt" in imdb: + showname = await get_info_imdb(id,ismovie,type,client) + print(showname) + else: + showname = get_info_tmdb(id,ismovie,type) + if ismovie == 0: + season = general[2] + episode = general[3] + page_link = await search_series(client,id,season,episode,showname) + mp4_link = await get_episode(client,page_link,episode) + final_url = await get_mp4(client,mp4_link) + print(final_url) + return final_url + else: + page_link = await search_movie(client,showname,id) + mp4_link = page_link + "?area=online" + final_url = await get_mp4(client,mp4_link) + print(final_url) + return final_url + + except Exception as e: + print(f"MammaMia: DDLStream Failed {e}") + return None,None + +''' +async def test_animeworld(): + from curl_cffi.requests import AsyncSession + async with AsyncSession() as client: + test_id = "tt6263850" # This is an example ID format + results = await ddlstream(test_id, client) + print(results) + +if __name__ == "__main__": + import asyncio + asyncio.run(test_animeworld()) + + + #python3 -m Src.API.ddlstream +''' \ No newline at end of file diff --git a/Src/API/epg.py b/Src/API/epg.py index 1e506b8..858ac06 100644 --- a/Src/API/epg.py +++ b/Src/API/epg.py @@ -139,9 +139,6 @@ convert_bho_3 = { async def tivu_get(id,client): try: - cookies = { - 'ASP.NET_SessionId': 'p2fk5silp5mjgtx0j5chjrh3', - } ik = tivu[id] headers = { 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0', @@ -162,11 +159,11 @@ async def tivu_get(id,client): 'Pragma': 'no-cache', 'Cache-Control': 'no-cache', } - data = { 'ik': ik } - response = await client.post('https://www.tivu.tv/getPrograms.ashx', cookies=cookies, headers=headers, data=data) + + response = await client.post('https://www.tivu.tv/getPrograms.ashx', headers=headers, data=data) soup = BeautifulSoup(response.text,'lxml') tr_element = soup.find('tr', class_='in_onda') hour_range = tr_element.find_all('td')[0].text.strip() diff --git a/Src/API/filmpertutti.py b/Src/API/filmpertutti.py index f166c34..e474ab3 100644 --- a/Src/API/filmpertutti.py +++ b/Src/API/filmpertutti.py @@ -9,6 +9,7 @@ from Src.Utilities.info import get_info_tmdb, is_movie, get_info_imdb from Src.Utilities.convert_date import convert_US_date import Src.Utilities.config as config FT_DOMAIN = config.FT_DOMAIN +import urllib.parse WOA = 0 #Some basic headers headers = { @@ -122,6 +123,7 @@ async def filmpertutti(imdb,client): tmdba = imdb_id.replace("tmdb:","") showname,date = get_info_tmdb(tmdba,ismovie,type) showname = showname.replace(" ", "+").replace("–", "+").replace("—","+") + showname = urllib.parse.quote_plus(showname) #Build the query query = f'https://filmpertutti.{FT_DOMAIN}/wp-json/wp/v2/posts?search={showname}&page=1&_fields=link,id' try: @@ -135,6 +137,7 @@ async def filmpertutti(imdb,client): real_link = await get_real_link(episode_link,client) #let's get delivery link, streaming link streaming_link = await get_true_link(real_link,client) + print(streaming_link) return streaming_link elif ismovie == 1: film_link = get_film(url) @@ -156,6 +159,8 @@ async def test_animeworld(): if __name__ == "__main__": import asyncio asyncio.run(test_animeworld()) + + ''' @@ -163,8 +168,6 @@ if __name__ == "__main__": - - ''' series_response = await client.get(link, headers=headers, follow_redirects=True) series_soup = BeautifulSoup(series_response.text, 'lxml') diff --git a/Src/API/lordchannel.py b/Src/API/lordchannel.py index 6421c9c..cf5c476 100644 --- a/Src/API/lordchannel.py +++ b/Src/API/lordchannel.py @@ -31,7 +31,6 @@ async def search(showname,date,season,episode,ismovie,client): 'media': showname, '_': '1724421723999', } - response = await client.get(f'https://lordchannel.{LC_DOMAIN}/live_search/', params=params, cookies=cookies, headers=headers, allow_redirects=True, impersonate = "chrome120") data = json.loads(response.text) for entry in data['data']: @@ -99,13 +98,14 @@ async def lordchannel(imdb,client): return None,None - -#async def test_animeworld(): +''' +async def test_animeworld(): async with httpx.AsyncClient() as client: - results = await lordchannel("tt6468322:1:1",client) + results = await lordchannel("tt14134334:1:1",client) print(results) -#if __name__ == "__main__": +if __name__ == "__main__": import httpx import asyncio - asyncio.run(test_animeworld()) \ No newline at end of file + asyncio.run(test_animeworld()) + ''' \ No newline at end of file diff --git a/Src/API/okru.py b/Src/API/okru.py index fb348b1..abacce7 100644 --- a/Src/API/okru.py +++ b/Src/API/okru.py @@ -5,14 +5,18 @@ from Src.Utilities.dictionaries import okru async def okru_get_url(id,client): - embed_link = okru[id] - print(embed_link) - response = await client.get(embed_link, allow_redirects=True, impersonate = "chrome120") - soup = BeautifulSoup(response.text, 'lxml') - div = soup.find('div', {'data-module': 'OKVideo'}) - data_options = div.get('data-options') - data = json.loads(data_options) - metadata = json.loads(data['flashvars']['metadata']) - m3u8_link = metadata['hlsMasterPlaylistUrl'] - print("MammaMia: Found results for Okru") - return m3u8_link + try: + embed_link = okru[id] + print(embed_link) + response = await client.get(embed_link, allow_redirects=True, impersonate = "chrome120") + soup = BeautifulSoup(response.text, 'lxml') + div = soup.find('div', {'data-module': 'OKVideo'}) + data_options = div.get('data-options') + data = json.loads(data_options) + metadata = json.loads(data['flashvars']['metadata']) + m3u8_link = metadata['hlsMasterPlaylistUrl'] + print("MammaMia: Found results for Okru") + return m3u8_link + except Exception as e: + print("MammaMia: No results found for Okru") + return None \ No newline at end of file diff --git a/Src/API/streamingcommunity.py b/Src/API/streamingcommunity.py index 7528ef8..1f28a3e 100644 --- a/Src/API/streamingcommunity.py +++ b/Src/API/streamingcommunity.py @@ -8,6 +8,8 @@ import re from urllib.parse import urlparse, parse_qs from fake_headers import Headers from Src.Utilities.loadenv import load_env +import urllib.parse + env_vars = load_env() #Get domain SC_DOMAIN = config.SC_DOMAIN @@ -22,8 +24,8 @@ async def get_version(client): try: random_headers = headers.generate() - random_headers['Referer'] = "https://streamingcommunity.buzz/" - random_headers['Origin'] = "https://streamingcommunity.buzz" + random_headers['Referer'] = f"https://streamingcommunity.{SC_DOMAIN}/" + random_headers['Origin'] = f"https://streamingcommunity.{SC_DOMAIN}" base_url = f'https://streamingcommunity.{SC_DOMAIN}/richiedi-un-titolo' response = await client.get(base_url, headers=random_headers, allow_redirects = True, impersonate="chrome120") #Soup the response @@ -41,8 +43,10 @@ async def search(query,date,ismovie, client,SC_FAST_SEARCH): random_headers = headers.generate() random_headers['Referer'] = "https://streamingcommunity.buzz/" random_headers['Origin'] = "https://streamingcommunity.buzz" + random_headers['Accept'] = 'application/json' # Assuming the API returns JSON + random_headers['Content-Type'] = 'application/json' #Do a request to get the ID of serie/move and it's slug in the URL - response = await client.get(query, headers = random_headers, allow_redirects=True,impersonate = "chrome120") + response = await client.get(query, headers = random_headers, allow_redirects=True) print(response) response = response.json() @@ -228,6 +232,7 @@ async def streaming_community(imdb,client,SC_FAST_SEARCH): showname,date = get_info_tmdb(tmdba,ismovie,type) showname = showname.replace(" ", "+").replace("–", "+").replace("—","+") + showname = urllib.parse.quote_plus(showname) query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}' version = await get_version(client) tid,slug = await search(query,date,ismovie,client,SC_FAST_SEARCH) @@ -250,7 +255,7 @@ async def test_animeworld(): from curl_cffi.requests import AsyncSession async with AsyncSession() as client: # Replace with actual id, for example 'anime_id:episode' format - test_id = "tt16288804:1:1" # This is an example ID format + test_id = "tt12930350" # This is an example ID format results = await streaming_community(test_id, client,"0") if __name__ == "__main__": diff --git a/Src/API/streamingwatch.py b/Src/API/streamingwatch.py index 2329187..ed141bc 100644 --- a/Src/API/streamingwatch.py +++ b/Src/API/streamingwatch.py @@ -4,9 +4,18 @@ from Src.Utilities.info import get_info_tmdb, is_movie, get_info_imdb import Src.Utilities.config as config import re import json +import urllib.parse SW_DOMAIN = config.SW_DOMAIN +async def wponce_get(client): + response = await client.get(f"https://www.streamingwatch.{SW_DOMAIN}/contatto/") + pattern = r'"admin_ajax_nonce":"(\w+)"' + matches = re.findall(pattern, response.text) + wponce = matches[1] + return wponce + async def search(showname,season,episode,date,ismovie,client): if ismovie == 1: + wponce = await wponce_get(client) query = f'https://www.streamingwatch.{SW_DOMAIN}/wp-admin/admin-ajax.php' headers = { 'authority': f'www.streamingwatch.{SW_DOMAIN}', @@ -28,7 +37,7 @@ async def search(showname,season,episode,date,ismovie,client): data = { 'action': 'data_fetch', 'keyword': showname, - '_wpnonce': '648328b831', + '_wpnonce': wponce, } cookies = { 'wordpress_test_cookie': 'WP%20Cookie%20check', @@ -54,7 +63,7 @@ async def search(showname,season,episode,date,ismovie,client): data_json = response.text data = json.loads(data_json) for entry in data: - if f"stagione-{season}-episodio-{episode}" in entry["slug"]: + if f"stagione-{season}-episodio-{episode}" in entry["slug"] and f"stagione-{season}-episodio-{episode}0" not in entry["slug"]: content = entry["content"]["rendered"] #"content":{ # "rendered":"