mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-13 06:34:45 -04:00
Fix download_videos
key #177
This commit is contained in:
parent
c6e976cade
commit
c4824e875f
1 changed files with 13 additions and 4 deletions
|
@ -874,6 +874,10 @@ class Video(Media):
|
||||||
|
|
||||||
:param kwargs:
|
:param kwargs:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not kwargs.get("download_videos", True):
|
||||||
|
return
|
||||||
|
|
||||||
import m3u8
|
import m3u8
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -892,7 +896,7 @@ class Video(Media):
|
||||||
segment.uri for segment in parsed_m3u.segments
|
segment.uri for segment in parsed_m3u.segments
|
||||||
) as pool:
|
) as pool:
|
||||||
bar = get_tqdm_bar(
|
bar = get_tqdm_bar(
|
||||||
len(pool), desc="Downloading Video", unit="Chunk"
|
len(pool), desc=self._progress_desc, unit="Chunk"
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_tqdm_bar():
|
def update_tqdm_bar():
|
||||||
|
@ -966,6 +970,10 @@ class Video(Media):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _progress_desc(self) -> str:
|
||||||
|
return style(f"Video {self.tracknumber:02}", fg="blue")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self) -> str:
|
def path(self) -> str:
|
||||||
"""Get path to download the mp4 file.
|
"""Get path to download the mp4 file.
|
||||||
|
@ -1497,7 +1505,7 @@ class Album(Tracklist, Media):
|
||||||
if not self.get("streamable", False):
|
if not self.get("streamable", False):
|
||||||
raise NonStreamable(f"This album is not streamable ({self.id} ID)")
|
raise NonStreamable(f"This album is not streamable ({self.id} ID)")
|
||||||
|
|
||||||
self._load_tracks(resp)
|
self._load_tracks(resp, kwargs.get("download_videos", True))
|
||||||
self.loaded = True
|
self.loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -1622,7 +1630,7 @@ class Album(Tracklist, Media):
|
||||||
meta.id = resp["id"]
|
meta.id = resp["id"]
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
def _load_tracks(self, resp):
|
def _load_tracks(self, resp, download_videos: bool = True):
|
||||||
"""Load the tracks into self from an API response.
|
"""Load the tracks into self from an API response.
|
||||||
|
|
||||||
This uses a classmethod to convert an item into a Track object, which
|
This uses a classmethod to convert an item into a Track object, which
|
||||||
|
@ -1631,6 +1639,7 @@ class Album(Tracklist, Media):
|
||||||
logging.debug("Loading %d tracks to album", self.tracktotal)
|
logging.debug("Loading %d tracks to album", self.tracktotal)
|
||||||
for track in _get_tracklist(resp, self.client.source):
|
for track in _get_tracklist(resp, self.client.source):
|
||||||
if track.get("type") == "Music Video":
|
if track.get("type") == "Music Video":
|
||||||
|
if download_videos:
|
||||||
self.append(Video.from_album_meta(track, self.client))
|
self.append(Video.from_album_meta(track, self.client))
|
||||||
else:
|
else:
|
||||||
self.append(
|
self.append(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue