1212
1313# Internal utilities
1414from StreamingCommunity .Util .message import start_message
15- from StreamingCommunity .Util .os import os_manager
16- from StreamingCommunity .Util .os import get_wvd_path
17- from StreamingCommunity .Lib .Downloader .DASH .downloader import DASH_Download
15+ from StreamingCommunity .Util .os import os_manager , get_wvd_path
1816
1917
2018# Logic class
21- from .util .ScrapeSerie import GetSerieInfo
19+ from .util .ScrapeSerie import GetSerieInfo , delete_stream_episode
2220from StreamingCommunity .Api .Template .Util import (
2321 manage_selection ,
2422 map_episode_title ,
3129
3230
3331# Player
32+ from StreamingCommunity import DASH_Downloader
3433from .util .get_license import get_playback_session , get_auth_token , generate_device_id
3534
3635
@@ -65,12 +64,14 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
6564 # Generate mpd and license URLs
6665 url_id = obj_episode .get ('url' ).split ('/' )[- 1 ]
6766 device_id = generate_device_id ()
68- mpd_url , mpd_headers = get_playback_session (get_auth_token (device_id ), device_id , url_id )
67+ token_mpd = get_auth_token (device_id )
68+
69+ mpd_url , mpd_headers = get_playback_session (token_mpd , device_id , url_id )
6970 parsed_url = urlparse (mpd_url )
7071 query_params = parse_qs (parsed_url .query )
7172
7273 # Download the episode
73- r_proc = DASH_Download (
74+ r_proc = DASH_Downloader (
7475 cdm_device = get_wvd_path (),
7576 license_url = 'https://www.crunchyroll.com/license/v1/license/widevine' ,
7677 mpd_url = mpd_url ,
@@ -95,6 +96,9 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
9596 try : os .remove (status ['path' ])
9697 except Exception : pass
9798
99+ # Delete episode stream
100+ delete_stream_episode (url_id , query_params ['playbackGuid' ][0 ], mpd_headers )
101+
98102 return status ['path' ], status ['stopped' ]
99103
100104def download_episode (index_season_selected : int , scrape_serie : GetSerieInfo , download_all : bool = False , episode_selection : str = None ) -> None :
0 commit comments