1818
1919if TYPE_CHECKING :
2020 from ..core import Client
21- from ..utils import Quality
2221
2322
2423class Video :
@@ -226,7 +225,9 @@ def get_m3u8_urls(self) -> dict:
226225 def download (self ,
227226 path : Union [str , os .PathLike ],
228227 downloader : Union [Callable , str ] = "threaded" ,
229- quality : Quality | str = 'best' ,
228+ quality : str = 'best' ,
229+ remux : bool = False ,
230+ display_remux : Callable [[int , int ], None ] = None ,
230231 * ,
231232 display : Callable [[int , int ], None ] = display .default ()) -> str :
232233 '''
@@ -237,6 +238,8 @@ def download(self,
237238 quality (Quality | str | int): The video quality.
238239 downloader (Callable): The download backend.
239240 display (Callable): The progress display.
241+ remux (bool): Whether to remux the video from MPEG-TS to MP4 (h264)
242+ display_remux (Callable[[int, int], None], optional): The display backend for remuxing.
240243
241244 Returns:
242245 str: The downloader video path.
@@ -249,37 +252,14 @@ def download(self,
249252 self .logger .info ('Starting download for %s at %s' , self , path )
250253
251254 try :
252- self .client .core .download (video = self , quality = quality , path = path , callback = display , downloader = downloader )
255+ self .client .core .download (video = self , quality = quality , path = path , callback = display , downloader = downloader ,
256+ remux = remux , callback_remux = display_remux )
253257
254258 except Exception as e :
255259 self .logger .error (f"An error occured while downloading video { e } " )
256260
257261 return path
258262
259- def get_direct_url (self , quality : Quality ) -> str :
260- '''
261- Get the direct video URL given a specific quality.
262-
263- Args:
264- quality (Quality): The video quality.
265-
266- Returns:
267- str: The direct url.
268- '''
269-
270- from ..utils import Quality
271- qual = Quality (quality )
272-
273- # Get remote
274- sources = self .fetch ('page@mediaDefinitions' )
275- remote = [s for s in sources if 'remote' in s ][0 ]['videoUrl' ]
276-
277- # Parse quality
278- quals = {int (s ['quality' ]): s ['videoUrl' ]
279- for s in self .client .call (remote ).json ()}
280-
281- return qual .select (quals )
282-
283263 # === Interaction methods === #
284264
285265 def _assert_internal_success (self , res : dict ) -> None :
0 commit comments