mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-09 14:11:55 -04:00
Fix issue where Deezer track wouldn’t download
This commit is contained in:
parent
e6978c05b8
commit
6edb422eff
3 changed files with 20 additions and 5 deletions
|
@ -1,12 +1,11 @@
|
|||
import copy
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
from pprint import pformat
|
||||
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
from .constants import CONFIG_PATH, DOWNLOADS_DIR, FOLDER_FORMAT, TRACK_FORMAT
|
||||
from .constants import (CONFIG_PATH, DOWNLOADS_DIR, FOLDER_FORMAT, TRACK_FORMAT, CONFIG_DIR)
|
||||
from .exceptions import InvalidSourceError
|
||||
|
||||
yaml = YAML()
|
||||
|
@ -95,6 +94,9 @@ class Config:
|
|||
self.dump(self.file)
|
||||
|
||||
def reset(self):
|
||||
if not os.path.isdir(CONFIG_DIR):
|
||||
os.makedirs(CONFIG_DIR, exist_ok=True)
|
||||
|
||||
self.dump(self.defaults)
|
||||
|
||||
def load(self):
|
||||
|
|
|
@ -256,11 +256,13 @@ class MusicDL(list):
|
|||
)
|
||||
elif isinstance(media, Artist):
|
||||
fmt = "{name}"
|
||||
elif isinstance(media, Track):
|
||||
fmt = "{artist} - {title}\nReleased on {year}"
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
fields = (fname for _, fname, _, _ in Formatter().parse(fmt) if fname)
|
||||
ret = fmt.format(**{k: media.get(k, "Unknown") for k in fields})
|
||||
ret = fmt.format(**{k: media.get(k, default="Unknown") for k in fields})
|
||||
return ret
|
||||
|
||||
def interactive_search(
|
||||
|
|
|
@ -152,11 +152,12 @@ class Track:
|
|||
progress_bar: bool = True,
|
||||
database: MusicDB = None,
|
||||
tag: bool = False,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Download the track.
|
||||
|
||||
:param quality: (5, 6, 7, 27)
|
||||
:param quality: (0, 1, 2, 3, 4)
|
||||
:type quality: int
|
||||
:param folder: folder to download the files to
|
||||
:type folder: Optional[Union[str, os.PathLike]]
|
||||
|
@ -243,6 +244,9 @@ class Track:
|
|||
if tag:
|
||||
self.tag()
|
||||
|
||||
if not kwargs.get("keep_cover", True) and hasattr(self, 'cover_path'):
|
||||
os.remove(self.cover_path)
|
||||
|
||||
return True
|
||||
|
||||
def download_cover(self):
|
||||
|
@ -269,7 +273,6 @@ class Track:
|
|||
"""
|
||||
formatter = self.meta.get_formatter()
|
||||
logger.debug("Track meta formatter %s", pformat(formatter))
|
||||
# filename = sanitize_filepath(self.file_format.format(**formatter))
|
||||
filename = clean_format(self.file_format, formatter)
|
||||
self.final_path = (
|
||||
os.path.join(self.folder, filename)[:250].strip()
|
||||
|
@ -439,6 +442,13 @@ class Track:
|
|||
click.secho(f"Converting {self!s}", fg="blue")
|
||||
engine.convert()
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
if hasattr(self, 'meta'):
|
||||
return self.meta.title
|
||||
else:
|
||||
raise Exception("Track must be loaded before accessing title")
|
||||
|
||||
def get(self, *keys, default=None):
|
||||
"""Safe get method that allows for layered access.
|
||||
|
||||
|
@ -1025,6 +1035,7 @@ class Playlist(Tracklist):
|
|||
quality: int = 6,
|
||||
filters: Callable = None,
|
||||
database: MusicDB = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""Download and tag all of the tracks.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue