forked from kenzuya/unshackle
fix(events): emit TRACK_DOWNLOADED once per track after decryption
This commit is contained in:
@@ -733,7 +733,7 @@ class Track:
|
||||
track's init data and stores it on the track, so a service need not declare `drm` itself.
|
||||
"""
|
||||
from unshackle.core.manifests import DASH, HLS, ISM
|
||||
from unshackle.core.manifests.segment_pipeline import license_drm
|
||||
from unshackle.core.manifests.segment_pipeline import license_drm, licensing
|
||||
from unshackle.core.tracks.audio import Audio
|
||||
from unshackle.core.tracks.subtitle import Subtitle
|
||||
from unshackle.core.tracks.video import Video
|
||||
@@ -889,7 +889,6 @@ class Track:
|
||||
media_path.unlink()
|
||||
|
||||
self.path = save_path
|
||||
events.emit(events.Types.TRACK_DOWNLOADED, track=self)
|
||||
|
||||
if drm:
|
||||
progress(downloaded="Decrypting", completed=0, total=None)
|
||||
@@ -926,6 +925,17 @@ class Track:
|
||||
DOWNLOAD_CANCELLED.set()
|
||||
progress(downloaded="[red]FAILED")
|
||||
raise
|
||||
|
||||
if DOWNLOAD_CANCELLED.is_set():
|
||||
return
|
||||
|
||||
if not DOWNLOAD_LICENCE_ONLY.is_set():
|
||||
assert self.path is not None
|
||||
if self.path.stat().st_size <= 3: # Empty UTF-8 BOM == 3 bytes
|
||||
raise OSError("Download failed, the downloaded file is empty.")
|
||||
|
||||
with licensing(ctx):
|
||||
events.emit(events.Types.TRACK_DOWNLOADED, track=self)
|
||||
except DownloadCancelled:
|
||||
abandon()
|
||||
progress(downloaded="[yellow]SKIPPED")
|
||||
@@ -935,16 +945,6 @@ class Track:
|
||||
abandon()
|
||||
raise
|
||||
|
||||
if DOWNLOAD_CANCELLED.is_set():
|
||||
return
|
||||
|
||||
if not DOWNLOAD_LICENCE_ONLY.is_set():
|
||||
assert self.path is not None
|
||||
if self.path.stat().st_size <= 3: # Empty UTF-8 BOM == 3 bytes
|
||||
raise OSError("Download failed, the downloaded file is empty.")
|
||||
|
||||
events.emit(events.Types.TRACK_DOWNLOADED, track=self)
|
||||
|
||||
def delete(self) -> None:
|
||||
if self.path:
|
||||
self.path.unlink()
|
||||
|
||||
Reference in New Issue
Block a user