1818
1919
2020class 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