mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-30 15:05:19 -04:00
Misc bug fixes related to playlist downloads
This commit is contained in:
parent
69e8a5d05b
commit
86d877f1f5
5 changed files with 23 additions and 7 deletions
|
@ -387,11 +387,11 @@ class Track:
|
||||||
meta = TrackMetadata(track=item, source=client.source)
|
meta = TrackMetadata(track=item, source=client.source)
|
||||||
try:
|
try:
|
||||||
if client.source == "qobuz":
|
if client.source == "qobuz":
|
||||||
cover_url = item["album"]["image"]["small"]
|
cover_url = item["album"]["image"]["large"]
|
||||||
elif client.source == "tidal":
|
elif client.source == "tidal":
|
||||||
cover_url = tidal_cover_url(item["album"]["cover"], 320)
|
cover_url = tidal_cover_url(item["album"]["cover"], 640)
|
||||||
elif client.source == "deezer":
|
elif client.source == "deezer":
|
||||||
cover_url = item["album"]["cover_medium"]
|
cover_url = item["album"]["cover_large"]
|
||||||
else:
|
else:
|
||||||
raise InvalidSourceError(client.source)
|
raise InvalidSourceError(client.source)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -248,6 +248,7 @@ def lastfm(ctx, source, url):
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("-o", "--open", is_flag=True, help="Open the config file")
|
@click.option("-o", "--open", is_flag=True, help="Open the config file")
|
||||||
|
@click.option("-d", "--directory", is_flag=True, help="Open the config directory")
|
||||||
@click.option("-q", "--qobuz", is_flag=True, help="Set Qobuz credentials")
|
@click.option("-q", "--qobuz", is_flag=True, help="Set Qobuz credentials")
|
||||||
@click.option("-t", "--tidal", is_flag=True, help="Re-login into Tidal")
|
@click.option("-t", "--tidal", is_flag=True, help="Re-login into Tidal")
|
||||||
@click.option("--reset", is_flag=True, help="RESET the config file")
|
@click.option("--reset", is_flag=True, help="RESET the config file")
|
||||||
|
@ -261,6 +262,11 @@ def config(ctx, **kwargs):
|
||||||
click.secho(f"Opening {CONFIG_PATH}", fg="green")
|
click.secho(f"Opening {CONFIG_PATH}", fg="green")
|
||||||
click.launch(CONFIG_PATH)
|
click.launch(CONFIG_PATH)
|
||||||
|
|
||||||
|
if kwargs['directory']:
|
||||||
|
config_dir = os.path.dirname(CONFIG_PATH)
|
||||||
|
click.secho(f"Opening {config_dir}", fg="green")
|
||||||
|
click.launch(config_dir)
|
||||||
|
|
||||||
if kwargs["qobuz"]:
|
if kwargs["qobuz"]:
|
||||||
config.file["qobuz"]["email"] = input(click.style("Qobuz email: ", fg="blue"))
|
config.file["qobuz"]["email"] = input(click.style("Qobuz email: ", fg="blue"))
|
||||||
|
|
||||||
|
|
|
@ -268,6 +268,8 @@ class MusicDL(list):
|
||||||
raise ParsingError(f"Error parsing URL: `{url}`")
|
raise ParsingError(f"Error parsing URL: `{url}`")
|
||||||
|
|
||||||
def handle_lastfm_urls(self, urls):
|
def handle_lastfm_urls(self, urls):
|
||||||
|
# https://www.last.fm/user/nathan3895/playlists/12058911
|
||||||
|
user_regex = re.compile(r"https://www\.last\.fm/user/([^/]+)/playlists/\d+")
|
||||||
lastfm_urls = self.lastfm_url_parse.findall(urls)
|
lastfm_urls = self.lastfm_url_parse.findall(urls)
|
||||||
lastfm_source = self.config.session["lastfm"]["source"]
|
lastfm_source = self.config.session["lastfm"]["source"]
|
||||||
tracks_not_found = 0
|
tracks_not_found = 0
|
||||||
|
@ -276,6 +278,8 @@ class MusicDL(list):
|
||||||
global tracks_not_found
|
global tracks_not_found
|
||||||
try:
|
try:
|
||||||
track = next(self.search(lastfm_source, query, media_type="track"))
|
track = next(self.search(lastfm_source, query, media_type="track"))
|
||||||
|
if self.config.session['metadata']['set_playlist_to_album']:
|
||||||
|
track.version = track.work = None
|
||||||
playlist.append(track)
|
playlist.append(track)
|
||||||
except NoResultsFound:
|
except NoResultsFound:
|
||||||
tracks_not_found += 1
|
tracks_not_found += 1
|
||||||
|
@ -286,6 +290,8 @@ class MusicDL(list):
|
||||||
title, queries = self.get_lastfm_playlist(purl)
|
title, queries = self.get_lastfm_playlist(purl)
|
||||||
|
|
||||||
pl = Playlist(client=self.get_client(lastfm_source), name=title)
|
pl = Playlist(client=self.get_client(lastfm_source), name=title)
|
||||||
|
pl.creator = user_regex.search(purl).group(1)
|
||||||
|
|
||||||
processes = []
|
processes = []
|
||||||
|
|
||||||
for title, artist in queries:
|
for title, artist in queries:
|
||||||
|
@ -382,7 +388,12 @@ class MusicDL(list):
|
||||||
results = tuple(self.search(source, query, media_type, limit=50))
|
results = tuple(self.search(source, query, media_type, limit=50))
|
||||||
|
|
||||||
def title(res):
|
def title(res):
|
||||||
return f"{res[0]+1}. {res[1].album}"
|
if isinstance(res[1], Album):
|
||||||
|
return f"{res[0]+1}. {res[1].meta.album}"
|
||||||
|
elif isinstance(res[1], Track):
|
||||||
|
return f"{res[0]+1}. {res[1].meta.title}"
|
||||||
|
else:
|
||||||
|
raise NotImplementedError(type(res[1]).__name__)
|
||||||
|
|
||||||
def from_title(s):
|
def from_title(s):
|
||||||
num = []
|
num = []
|
||||||
|
|
|
@ -327,7 +327,6 @@ class Playlist(Tracklist):
|
||||||
:param new_tracknumbers: replace tracknumber tag with playlist position
|
:param new_tracknumbers: replace tracknumber tag with playlist position
|
||||||
:type new_tracknumbers: bool
|
:type new_tracknumbers: bool
|
||||||
"""
|
"""
|
||||||
# TODO: redundant parsing with _parse_get_pres
|
|
||||||
if self.client.source == "qobuz":
|
if self.client.source == "qobuz":
|
||||||
self.name = self.meta["name"]
|
self.name = self.meta["name"]
|
||||||
self.image = self.meta["images"]
|
self.image = self.meta["images"]
|
||||||
|
@ -408,7 +407,7 @@ class Playlist(Tracklist):
|
||||||
fname = sanitize_filename(self.name)
|
fname = sanitize_filename(self.name)
|
||||||
self.folder = os.path.join(parent_folder, fname)
|
self.folder = os.path.join(parent_folder, fname)
|
||||||
|
|
||||||
self.__download_index = 1
|
self.__download_index = 1 # used for tracknumbers
|
||||||
self.download_message()
|
self.download_message()
|
||||||
|
|
||||||
def _download_item(self, item: Track, **kwargs):
|
def _download_item(self, item: Track, **kwargs):
|
||||||
|
@ -422,7 +421,6 @@ class Playlist(Tracklist):
|
||||||
if kwargs.get("new_tracknumbers", True):
|
if kwargs.get("new_tracknumbers", True):
|
||||||
item["tracknumber"] = self.__download_index
|
item["tracknumber"] = self.__download_index
|
||||||
item["discnumber"] = 1
|
item["discnumber"] = 1
|
||||||
|
|
||||||
self.__download_index += 1
|
self.__download_index += 1
|
||||||
|
|
||||||
self.downloaded = item.download(**kwargs)
|
self.downloaded = item.download(**kwargs)
|
||||||
|
|
|
@ -277,6 +277,7 @@ class TrackMetadata:
|
||||||
assert hasattr(self, "_album"), "Must set album before accessing"
|
assert hasattr(self, "_album"), "Must set album before accessing"
|
||||||
|
|
||||||
album = self._album
|
album = self._album
|
||||||
|
|
||||||
if self.get("version") and self["version"] not in album:
|
if self.get("version") and self["version"] not in album:
|
||||||
album = f"{self._album} ({self.version})"
|
album = f"{self._album} ({self.version})"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue