Skip to content

Commit 08e3462

Browse files
committed
Improve mpd parser
1 parent be4f40b commit 08e3462

File tree

7 files changed

+184
-39
lines changed

7 files changed

+184
-39
lines changed

StreamingCommunity/Api/Player/supervideo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def make_request(self, url: str) -> str:
4242
- str: The response content if successful, None otherwise.
4343
"""
4444
try:
45-
response = requests.get(url, headers=self.headers, timeout=MAX_TIMEOUT, impersonate="chrome110", verify=REQUEST_VERIFY)
45+
response = requests.get(url, headers=self.headers, timeout=MAX_TIMEOUT, impersonate="chrome136", verify=REQUEST_VERIFY)
4646
if response.status_code >= 400:
4747
logging.error(f"Request failed with status code: {response.status_code}")
4848
return None

StreamingCommunity/Api/Site/crunchyroll/series.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
101101

102102
# Delete episode stream
103103
token = query_params['playbackGuid'][0]
104-
if token:
105-
client.delete_active_stream(url_id, token)
104+
client.delete_active_stream(url_id, token)
106105

107106
return status['path'], status['stopped']
108107

StreamingCommunity/Api/Site/crunchyroll/site.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def title_search(query: str) -> int:
7373
params=params,
7474
headers=headers,
7575
timeout=max_timeout,
76-
impersonate="chrome110"
76+
impersonate="chrome136"
7777
)
7878
response.raise_for_status()
7979

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_series_seasons(series_id, headers, params):
2626
url,
2727
params=params,
2828
headers=headers,
29-
impersonate="chrome110"
29+
impersonate="chrome136"
3030
)
3131
return response
3232

@@ -40,7 +40,7 @@ def get_season_episodes(season_id, headers, params):
4040
url,
4141
params=params,
4242
headers=headers,
43-
impersonate="chrome110"
43+
impersonate="chrome136"
4444
)
4545
return response
4646

@@ -88,13 +88,10 @@ def collect_season(self) -> None:
8888
if seasons:
8989
self.series_name = seasons[0].get("series_title") or seasons[0].get("title")
9090

91-
for season in seasons:
92-
season_num = season.get("season_number", 0)
93-
season_name = season.get("title", f"Season {season_num}")
94-
91+
for i, season in enumerate(seasons, start=1):
9592
self.seasons_manager.add_season({
96-
'number': season_num,
97-
'name': season_name,
93+
'number': i,
94+
'name': season.get("title", f"Season {i}"),
9895
'id': season.get('id')
9996
})
10097

@@ -103,15 +100,10 @@ def _fetch_episodes_for_season(self, season_number: int):
103100
Fetch and cache episodes for a specific season number.
104101
"""
105102
season = self.seasons_manager.get_season_by_number(season_number)
103+
ep_response = get_season_episodes(season.id, self.headers, self.params)
106104

107-
if not season or getattr(season, 'id', None) is None:
108-
logging.error(f"Season {season_number} not found or missing id.")
109-
return []
110-
111-
season_id = season.id
112-
ep_response = get_season_episodes(season_id, self.headers, self.params)
113105
if ep_response.status_code != 200:
114-
logging.error(f"Failed to fetch episodes for season {season_id}")
106+
logging.error(f"Failed to fetch episodes for season {season.id}")
115107
return []
116108

117109
ep_data = ep_response.json()
@@ -149,7 +141,7 @@ def _get_episode_audio_locales_and_urls(self, episode_id):
149141
url,
150142
params=params,
151143
headers=headers,
152-
impersonate="chrome110"
144+
impersonate="chrome136"
153145
)
154146

155147
if response.status_code != 200:

StreamingCommunity/Api/Site/crunchyroll/util/get_license.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def __init__(self) -> None:
1818
config = config_manager.get_dict("SITE_LOGIN", "crunchyroll")
1919
self.device_id = config.get('device_id')
2020
self.etp_rt = config.get('etp_rt')
21-
self.preferred_audio_language = "ja-JP"
2221
self.locale = "it-IT"
2322

2423
self.access_token = None
@@ -54,7 +53,7 @@ def start(self) -> bool:
5453
'device_type': 'Chrome on Windows',
5554
'grant_type': 'etp_rt_cookie',
5655
},
57-
impersonate="chrome110"
56+
impersonate="chrome136"
5857
)
5958

6059
if response.status_code == 400:
@@ -75,7 +74,7 @@ def get_streams(self, media_id: str) -> Dict:
7574
cookies=self._get_cookies(),
7675
headers=self._get_headers(),
7776
params={'locale': self.locale},
78-
impersonate="chrome110"
77+
impersonate="chrome136"
7978
)
8079

8180
if response.status_code == 403:
@@ -99,9 +98,9 @@ def delete_active_stream(self, media_id: str, token: str) -> bool:
9998
f'https://www.crunchyroll.com/playback/v1/token/{media_id}/{token}',
10099
cookies=self._get_cookies(),
101100
headers=self._get_headers(),
102-
impersonate="chrome110"
101+
impersonate="chrome136"
103102
)
104-
103+
response.raise_for_status()
105104
return response.status_code in [200, 204]
106105

107106

0 commit comments

Comments
 (0)