1212from rich .console import Console
1313
1414
15+ # Internal utilities
16+ from StreamingCommunity .Util .headers import get_userAgent
17+
18+
1519# Variable
1620console = Console ()
1721download_site_data = True
@@ -134,7 +138,7 @@ def _download_reference_config(self) -> None:
134138 console .print (f"[bold cyan]Downloading reference configuration:[/bold cyan] [green]{ self .reference_config_url } [/green]" )
135139
136140 try :
137- response = requests .get (self .reference_config_url , timeout = 10 )
141+ response = requests .get (self .reference_config_url , timeout = 8 , headers = { 'User-Agent' : get_userAgent ()} )
138142
139143 if response .status_code == 200 :
140144 with open (self .file_path , 'wb' ) as f :
@@ -156,7 +160,7 @@ def _validate_and_update_config(self) -> None:
156160 try :
157161 # Download the reference configuration
158162 console .print (f"[bold cyan]Validating configuration with GitHub...[/bold cyan]" )
159- response = requests .get (self .reference_config_url , timeout = 10 )
163+ response = requests .get (self .reference_config_url , timeout = 8 , headers = { 'User-Agent' : get_userAgent ()} )
160164
161165 if not response .ok :
162166 raise Exception (f"Error downloading reference configuration. Code: { response .status_code } " )
@@ -267,13 +271,14 @@ def _load_site_data_from_api(self) -> None:
267271 headers = {
268272 "apikey" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2Zm5ncG94d3Jnc3duenl0YWRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAxNTIxNjMsImV4cCI6MjA1NTcyODE2M30.FNTCCMwi0QaKjOu8gtZsT5yQttUW8QiDDGXmzkn89QE" ,
269273 "Authorization" : f"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2Zm5ncG94d3Jnc3duenl0YWRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAxNTIxNjMsImV4cCI6MjA1NTcyODE2M30.FNTCCMwi0QaKjOu8gtZsT5yQttUW8QiDDGXmzkn89QE" ,
270- "Content-Type" : "application/json"
274+ "Content-Type" : "application/json" ,
275+ "User-Agent" : get_userAgent ()
271276 }
272277
273278 try :
274279 console .print ("[bold cyan]Retrieving site data from API...[/bold cyan]" )
275- response = requests .get ("https://zvfngpoxwrgswnzytadh.supabase.co/rest/v1/public" , headers = headers , timeout = 10 )
276-
280+ response = requests .get ("https://zvfngpoxwrgswnzytadh.supabase.co/rest/v1/public" , timeout = 8 , headers = headers )
281+
277282 if response .ok :
278283 data = response .json ()
279284 if data and len (data ) > 0 :
@@ -282,13 +287,6 @@ def _load_site_data_from_api(self) -> None:
282287 site_count = len (self .configSite ) if isinstance (self .configSite , dict ) else 0
283288 console .print (f"[bold green]Site data retrieved:[/bold green] { site_count } streaming services available" )
284289
285- # Show some sites as examples
286- if site_count > 0 :
287- examples = list (self .configSite .items ())[:3 ]
288- sites_info = []
289- for site , info in examples :
290- url = info .get ('full_url' , 'N/A' )
291- console .print (f" • [cyan]{ site } [/cyan]: { url } " )
292290 else :
293291 console .print ("[bold yellow]API returned an empty data set[/bold yellow]" )
294292 else :
@@ -347,7 +345,7 @@ def download_file(self, url: str, filename: str) -> None:
347345 try :
348346 logging .info (f"Downloading { filename } from { url } ..." )
349347 console .print (f"[bold cyan]File download:[/bold cyan] { os .path .basename (filename )} " )
350- response = requests .get (url , timeout = 10 )
348+ response = requests .get (url , timeout = 8 , headers = { 'User-Agent' : get_userAgent ()} )
351349
352350 if response .status_code == 200 :
353351 with open (filename , 'wb' ) as f :
0 commit comments