Skip to content

Commit 3cbabfb

Browse files
committed
core: Fix requirements
1 parent 6efeb96 commit 3cbabfb

File tree

7 files changed

+70
-36
lines changed

7 files changed

+70
-36
lines changed

StreamingCommunity/Api/Player/supervideo.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66

77
# External libraries
8-
import httpx
98
import jsbeautifier
109
from bs4 import BeautifulSoup
10+
from curl_cffi import requests
1111

1212

1313
# Internal utilities
@@ -28,7 +28,6 @@ def __init__(self, url: str) -> None:
2828
- url (str): The URL of the video source.
2929
"""
3030
self.headers = get_headers()
31-
self.client = httpx.Client()
3231
self.url = url
3332

3433
def make_request(self, url: str) -> str:
@@ -42,8 +41,10 @@ def make_request(self, url: str) -> str:
4241
- str: The response content if successful, None otherwise.
4342
"""
4443
try:
45-
response = self.client.get(url, headers=self.headers, timeout=MAX_TIMEOUT, follow_redirects=True)
46-
response.raise_for_status()
44+
response = requests.get(url, headers=self.headers, timeout=MAX_TIMEOUT, impersonate="chrome110")
45+
if response.status_code >= 400:
46+
logging.error(f"Request failed with status code: {response.status_code}")
47+
return None
4748
return response.text
4849

4950
except Exception as e:

StreamingCommunity/Api/Player/vixcloud.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(self, url: str, is_series: bool, media_id: int = None, proxy: str =
3939
self.is_series = is_series
4040
self.media_id = media_id
4141
self.iframe_src = None
42+
self.window_parameter = None
4243

4344
def get_iframe(self, episode_id: int) -> None:
4445
"""
@@ -109,41 +110,45 @@ def get_content(self) -> None:
109110
# Parse script to get video information
110111
self.parse_script(script_text=script)
111112

113+
except httpx.HTTPStatusError as e:
114+
if e.response.status_code == 404:
115+
console.print("[yellow]This content will be available soon![/yellow]")
116+
return
117+
118+
logging.error(f"Error getting content: {e}")
119+
raise
120+
112121
except Exception as e:
113122
logging.error(f"Error getting content: {e}")
114123
raise
115124

116-
def get_playlist(self) -> str:
125+
def get_playlist(self) -> str | None:
117126
"""
118127
Generate authenticated playlist URL.
119128
120129
Returns:
121-
str: Fully constructed playlist URL with authentication parameters
130+
str | None: Fully constructed playlist URL with authentication parameters, or None if content unavailable
122131
"""
132+
if not self.window_parameter:
133+
return None
134+
123135
params = {}
124136

125-
# Add 'h' parameter if video quality is 1080p
126137
if self.canPlayFHD:
127138
params['h'] = 1
128139

129-
# Parse the original URL
130140
parsed_url = urlparse(self.window_parameter.url)
131141
query_params = parse_qs(parsed_url.query)
132142

133-
# Check specifically for 'b=1' in the query parameters
134143
if 'b' in query_params and query_params['b'] == ['1']:
135144
params['b'] = 1
136145

137-
# Add authentication parameters (token and expiration)
138146
params.update({
139147
"token": self.window_parameter.token,
140148
"expires": self.window_parameter.expires
141149
})
142150

143-
# Build the updated query string
144151
query_string = urlencode(params)
145-
146-
# Construct the new URL with updated query parameters
147152
return urlunparse(parsed_url._replace(query=query_string))
148153

149154

StreamingCommunity/Api/Site/altadefinizione/film.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,32 @@ def download_film(select_title: MediaItem) -> str:
6161
# Extract mostraguarda URL
6262
try:
6363
response = httpx.get(select_title.url, headers=get_headers(), timeout=10)
64+
response.raise_for_status()
65+
6466
soup = BeautifulSoup(response.text, 'html.parser')
6567
iframes = soup.find_all('iframe')
6668
mostraguarda = iframes[0]['src']
6769

6870
except Exception as e:
6971
console.print(f"[red]Site: {site_constant.SITE_NAME}, request error: {e}, get mostraguarda")
72+
return None
7073

7174
# Extract supervideo URL
75+
supervideo_url = None
7276
try:
7377
response = httpx.get(mostraguarda, headers=get_headers(), timeout=10)
78+
response.raise_for_status()
79+
7480
soup = BeautifulSoup(response.text, 'html.parser')
7581
pattern = r'//supervideo\.[^/]+/[a-z]/[a-zA-Z0-9]+'
7682
supervideo_match = re.search(pattern, response.text)
7783
supervideo_url = 'https:' + supervideo_match.group(0)
7884

7985
except Exception as e:
8086
console.print(f"[red]Site: {site_constant.SITE_NAME}, request error: {e}, get supervideo URL")
81-
87+
console.print("[yellow]This content will be available soon![/yellow]")
88+
return None
89+
8290
# Init class
8391
video_source = VideoSource(supervideo_url)
8492
master_playlist = video_source.get_playlist()

StreamingCommunity/Api/Site/altadefinizione/util/ScrapeSerie.py

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,52 @@ def collect_season(self) -> None:
3838
soup = BeautifulSoup(response.text, "html.parser")
3939
self.series_name = soup.find("title").get_text(strip=True).split(" - ")[0]
4040

41-
# Process all seasons
42-
season_items = soup.find_all('div', class_='accordion-item')
43-
44-
for season_idx, season_item in enumerate(season_items, 1):
45-
season_header = season_item.find('div', class_='accordion-header')
46-
if not season_header:
47-
continue
48-
49-
season_name = season_header.get_text(strip=True)
41+
# Find all season dropdowns
42+
seasons_dropdown = soup.find('div', class_='dropdown seasons')
43+
if not seasons_dropdown:
44+
return
45+
46+
# Get all season items
47+
season_items = seasons_dropdown.find_all('span', {'data-season': True})
48+
49+
for season_item in season_items:
50+
season_num = int(season_item['data-season'])
51+
season_name = season_item.get_text(strip=True)
5052

51-
# Create a new season and get a reference to it
53+
# Create a new season
5254
current_season = self.seasons_manager.add_season({
53-
'number': season_idx,
55+
'number': season_num,
5456
'name': season_name
5557
})
5658

57-
# Find episodes for this season
58-
episode_divs = season_item.find_all('div', class_='down-episode')
59-
for ep_idx, ep_div in enumerate(episode_divs, 1):
60-
episode_name_tag = ep_div.find('b')
61-
if not episode_name_tag:
59+
# Find all episodes for this season
60+
episodes_container = soup.find('div', {'class': 'dropdown mirrors', 'data-season': str(season_num)})
61+
if not episodes_container:
62+
continue
63+
64+
# Get all episode mirrors for this season
65+
episode_mirrors = soup.find_all('div', {'class': 'dropdown mirrors',
66+
'data-season': str(season_num)})
67+
68+
for mirror in episode_mirrors:
69+
episode_data = mirror.get('data-episode', '').split('-')
70+
if len(episode_data) != 2:
71+
continue
72+
73+
ep_num = int(episode_data[1])
74+
75+
# Find supervideo link
76+
supervideo_span = mirror.find('span', {'data-id': 'supervideo'})
77+
if not supervideo_span:
6278
continue
6379

64-
episode_name = episode_name_tag.get_text(strip=True)
65-
link_tag = ep_div.find('a', string=lambda text: text and "Supervideo" in text)
66-
episode_url = link_tag['href'] if link_tag else None
80+
episode_url = supervideo_span.get('data-link', '')
6781

6882
# Add episode to the season
6983
if current_season:
7084
current_season.episodes.add({
71-
'number': ep_idx,
72-
'name': episode_name,
85+
'number': ep_num,
86+
'name': f"Episodio {ep_num}",
7387
'url': episode_url
7488
})
7589

StreamingCommunity/Api/Site/streamingcommunity/film.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def download_film(select_title: MediaItem, proxy: str = None) -> str:
6262
video_source.get_content()
6363
master_playlist = video_source.get_playlist()
6464

65+
if master_playlist is None:
66+
console.print(f"[red]Site: {site_constant.SITE_NAME}, error: No master playlist found[/red]")
67+
return None
68+
6569
# Define the filename and path for the downloaded film
6670
title_name = os_manager.get_sanitize_file(select_title.name) + ".mp4"
6771
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))

StreamingCommunity/Upload/update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def update():
7979
try:
8080
current_version = importlib.metadata.version(__title__)
8181
except importlib.metadata.PackageNotFoundError:
82-
console.print(f"[yellow]Warning: Could not determine installed version for '{__title__}' via importlib.metadata. Falling back to source version.[/yellow]")
82+
#console.print(f"[yellow]Warning: Could not determine installed version for '{__title__}' via importlib.metadata. Falling back to source version.[/yellow]")
8383
current_version = source_code_version
8484

8585
# Get commit details

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ m3u8
66
certifi
77
psutil
88
unidecode
9+
curl_cffi
910
dnspython
1011
jsbeautifier
1112
pathvalidate
1213
pycryptodomex
1314
ua-generator
1415
qbittorrent-api
1516
pyTelegramBotAPI
17+
beautifulsoup4

0 commit comments

Comments
 (0)