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