66
77
88# External libraries
9- import httpx
109from bs4 import BeautifulSoup
1110from rich .console import Console
1211
1312
1413# Internal utilities
1514from StreamingCommunity .Util .headers import get_userAgent
16- from StreamingCommunity .Util .config_json import config_manager
15+ from StreamingCommunity .Util .http_client import create_client
1716from .Helper .Vixcloud .util import WindowVideo , WindowParameter , StreamsCollection
1817from .Helper .Vixcloud .js_parser import JavaScriptParser
1918
2019
2120# Variable
22- MAX_TIMEOUT = config_manager .get_int ("REQUESTS" , "timeout" )
23- REQUEST_VERIFY = config_manager .get_bool ('REQUESTS' , 'verify' )
2421console = Console ()
2522
2623
@@ -57,7 +54,7 @@ def get_iframe(self, episode_id: int) -> None:
5754 }
5855
5956 try :
60- response = httpx . get (f"{ self .url } /iframe/{ self .media_id } " , headers = self . headers , params = params , timeout = MAX_TIMEOUT , verify = REQUEST_VERIFY )
57+ response = create_client ( headers = self . headers ). get (f"{ self .url } /iframe/{ self .media_id } " , params = params )
6158 response .raise_for_status ()
6259
6360 # Parse response with BeautifulSoup to get iframe source
@@ -100,7 +97,7 @@ def get_content(self) -> None:
10097 """
10198 try :
10299 if self .iframe_src is not None :
103- response = httpx . get ( self . iframe_src , headers = self .headers , timeout = MAX_TIMEOUT , verify = REQUEST_VERIFY )
100+ response = create_client ( headers = self .headers ). get ( self . iframe_src )
104101 response .raise_for_status ()
105102
106103 # Parse response with BeautifulSoup to get content
@@ -110,14 +107,6 @@ def get_content(self) -> None:
110107 # Parse script to get video information
111108 self .parse_script (script_text = script )
112109
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-
121110 except Exception as e :
122111 logging .error (f"Error getting content: { e } " )
123112 raise
@@ -178,15 +167,15 @@ def get_embed(self, episode_id: int):
178167 str: Parsed script content
179168 """
180169 try :
181- response = httpx . get (f"{ self .url } /embed-url/{ episode_id } " , headers = self . headers , timeout = MAX_TIMEOUT , verify = REQUEST_VERIFY )
170+ response = create_client ( headers = self . headers ). get (f"{ self .url } /embed-url/{ episode_id } " )
182171 response .raise_for_status ()
183172
184173 # Extract and clean embed URL
185174 embed_url = response .text .strip ()
186175 self .iframe_src = embed_url
187176
188177 # Fetch video content using embed URL
189- video_response = httpx . get (embed_url , verify = REQUEST_VERIFY )
178+ video_response = create_client ( headers = self . headers ). get (embed_url )
190179 video_response .raise_for_status ()
191180
192181 # Parse response with BeautifulSoup to get content of the scriot
0 commit comments