Skip to content

Commit be4f40b

Browse files
committed
... enaC ioD
1 parent d874f9c commit be4f40b

File tree

3 files changed

+18
-35
lines changed

3 files changed

+18
-35
lines changed

StreamingCommunity/Api/Site/raiplay/series.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,7 @@ def download_series(select_season: MediaItem, season_selection: str = None, epis
166166
- episode_selection (str, optional): Pre-defined episode selection that bypasses manual input
167167
"""
168168
start_message()
169-
170-
# Extract program name from path_id
171-
program_name = None
172-
if select_season.path_id:
173-
parts = select_season.path_id.strip('/').split('/')
174-
if len(parts) >= 2:
175-
program_name = parts[-1].split('.')[0]
176-
177-
# Init scraper
178-
scrape_serie = GetSerieInfo(program_name)
169+
scrape_serie = GetSerieInfo(select_season.path_id)
179170

180171
# Get seasons info
181172
scrape_serie.collect_info_title()

StreamingCommunity/Api/Site/raiplay/site.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,13 @@ def determine_media_type(item):
3030
using GetSerieInfo.
3131
"""
3232
try:
33-
# Extract program name from path_id
34-
program_name = None
35-
if item.get('path_id'):
36-
parts = item['path_id'].strip('/').split('/')
37-
if len(parts) >= 2:
38-
program_name = parts[-1].split('.')[0]
39-
40-
if not program_name:
41-
return "film"
42-
43-
# Dio stranamente guarda che giro bisogna fare per avere il tipo di media.
44-
scraper = GetSerieInfo(program_name)
33+
scraper = GetSerieInfo(item.get('path_id'))
4534
scraper.collect_info_title()
4635
return scraper.prog_tipology, scraper.prog_description, scraper.prog_year
4736

4837
except Exception as e:
4938
console.print(f"[red]Error determining media type: {e}[/red]")
50-
return "film"
39+
return None, None, None
5140

5241

5342
def title_search(query: str) -> int:
@@ -97,6 +86,9 @@ def title_search(query: str) -> int:
9786
# Process each item and add to media manager
9887
for item in data:
9988
media_type, prog_description, prog_year = determine_media_type(item)
89+
if media_type is None:
90+
continue
91+
10092
media_search_manager.add_media({
10193
'id': item.get('id', ''),
10294
'name': item.get('titolo', ''),

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,34 @@
1818

1919

2020
class GetSerieInfo:
21-
def __init__(self, program_name: str):
21+
def __init__(self, path_id: str):
2222
"""Initialize the GetSerieInfo class."""
2323
self.base_url = "https://www.raiplay.it"
24-
self.program_name = program_name
25-
self.series_name = program_name
26-
self.prog_tipology = None
24+
self.path_id = path_id
25+
self.series_name = None
26+
self.prog_tipology = "film"
2727
self.prog_description = None
2828
self.prog_year = None
2929
self.seasons_manager = SeasonManager()
3030

3131
def collect_info_title(self) -> None:
3232
"""Get series info including seasons."""
3333
try:
34-
program_url = f"{self.base_url}/programmi/{self.program_name}.json"
34+
program_url = f"{self.base_url}/{self.path_id}"
3535
response = httpx.get(url=program_url, headers=get_headers(), timeout=max_timeout)
3636

3737
# If 404, content is not yet available
3838
if response.status_code == 404:
39-
logging.info(f"Content not yet available: {self.program_name}")
39+
logging.info(f"Content not yet available: {program_url}")
4040
return
4141

4242
response.raise_for_status()
4343
json_data = response.json()
4444

45-
# Dio santissimo ma chi ha fatto le cose cosi di merda.
46-
type_check_1 = "tv" if json_data.get('program_info', {}).get('layout', 'single') == 'multi' else "film"
47-
#type_check_2 = "tv" if "tv" in json_data.get('track_info', {}).get('typology', '') else "film"
48-
49-
self.prog_tipology = type_check_1
45+
# Get basic program info
5046
self.prog_description = json_data.get('program_info', '').get('vanity', '')
5147
self.prog_year = json_data.get('program_info', '').get('year', '')
48+
self.series_name = json_data.get('program_info', '').get('title', '')
5249

5350
# Look for seasons in the 'blocks' property
5451
for block in json_data.get('blocks', []):
@@ -60,11 +57,14 @@ def collect_info_title(self) -> None:
6057

6158
# Extract seasons from sets array
6259
for season_set in block.get('sets', []):
60+
self.prog_tipology = "tv"
61+
6362
if 'stagione' in season_set.get('name', '').lower():
6463
self._add_season(season_set, block.get('id'))
6564

6665
elif 'stagione' in block.get('name', '').lower():
6766
self.publishing_block_id = block.get('id')
67+
self.prog_tipology = "tv"
6868

6969
# Extract season directly from block's sets
7070
for season_set in block.get('sets', []):
@@ -88,7 +88,7 @@ def collect_info_season(self, number_season: int) -> None:
8888
season = self.seasons_manager.get_season_by_number(number_season)
8989

9090
# Se stai leggendo questo codice spieami perche hai fatto cosi.
91-
url = f"{self.base_url}/programmi/{self.program_name}/{self.publishing_block_id}/{season.id}/episodes.json"
91+
url = f"{self.base_url}/{self.path_id.replace(".json", "")}/{self.publishing_block_id}/{season.id}/episodes.json"
9292
response = httpx.get(url=url, headers=get_headers(), timeout=max_timeout)
9393
response.raise_for_status()
9494

0 commit comments

Comments
 (0)