diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 9d1e009..8cd8714 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -42,4 +42,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.site/index.html b/.site/index.html deleted file mode 100644 index e69de29..0000000 diff --git a/StreamingCommunity/Api/Site/streamingcommunity/site.py b/StreamingCommunity/Api/Site/streamingcommunity/site.py index 5c7fc89..1b887cb 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/site.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/site.py @@ -1,8 +1,11 @@ # 10.12.23 +import json + # External libraries import httpx +from bs4 import BeautifulSoup from rich.console import Console @@ -41,16 +44,34 @@ def title_search(query: str) -> int: media_search_manager.clear() table_show_manager.clear() - search_url = f"{site_constant.FULL_URL}/api/search?q={query}" + try: + response = httpx.get( + site_constant.FULL_URL, + headers={'user-agent': get_userAgent()}, + timeout=max_timeout + ) + response.raise_for_status() + + soup = BeautifulSoup(response.text, 'html.parser') + version = json.loads(soup.find('div', {'id': "app"}).get("data-page"))['version'] + + except Exception as e: + console.print(f"[red]Site: {site_constant.SITE_NAME} version, request error: {e}") + return 0 + + search_url = f"{site_constant.FULL_URL}/search?q={query}" console.print(f"[cyan]Search url: [yellow]{search_url}") try: response = httpx.get( search_url, - headers={'user-agent': get_userAgent()}, - timeout=max_timeout, - follow_redirects=True, - verify=False + headers = { + 'referer': site_constant.FULL_URL, + 'user-agent': get_userAgent(), + 'x-inertia': 'true', + 'x-inertia-version': version + }, + timeout=max_timeout ) response.raise_for_status() @@ -66,7 +87,7 @@ def title_search(query: str) -> int: # Collect json data try: - data = response.json().get('data', []) + data = response.json().get('props').get('titles') except Exception as e: console.log(f"Error parsing JSON response: {e}") return 0 diff --git a/StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py b/StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py index 5cd194c..a022993 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py @@ -96,17 +96,16 @@ class GetSerieInfo: if not season: logging.error(f"Season {number_season} not found") return - + response = httpx.get( - url=f'{self.url}/titles/{self.media_id}-{self.series_name}/stagione-{number_season}', + url=f'{self.url}/titles/{self.media_id}-{self.series_name}/season-{number_season}', headers={ - 'User-Agent': get_userAgent(), - 'x-inertia': 'true', + 'User-Agent': self.headers['user-agent'], + 'x-inertia': 'true', 'x-inertia-version': self.version, }, timeout=max_timeout ) - response.raise_for_status() # Extract episodes from JSON response json_response = response.json().get('props', {}).get('loadedSeason', {}).get('episodes', [])