Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
nathom committed Feb 25, 2021
1 parent 69728e2 commit 678910d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
27 changes: 18 additions & 9 deletions qobuz_dl/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def download_and_tag(

if artist or album_artist:
new_track_title = (
f"{artist if artist else album_artist}" f' - {track_metadata["title"]}'
f"{artist if artist else album_artist}"
f' - {track_metadata["title"]}'
)
if version:
new_track_title = f"{new_track_title} ({version})"
Expand Down Expand Up @@ -215,11 +216,13 @@ def download_id_by_type(
album_format, quality_met = get_format(client, meta, quality)
if not downgrade_quality and not quality_met:
logger.info(
f"{OFF}Skipping {album_title} as doesn't met quality requirement"
f"{OFF}Skipping {album_title} as it doesn't "
"meet quality requirement"
)
return

logger.info(f"\n{YELLOW}Downloading: {album_title}\nQuality: {album_format}\n")
logger.info(f"\n{YELLOW}Downloading: {album_title}\n"
f"Quality: {album_format}\n")
dirT = (
meta["artist"]["name"],
album_title,
Expand All @@ -233,14 +236,16 @@ def download_id_by_type(
if no_cover:
logger.info(f"{OFF}Skipping cover")
else:
get_extra(meta["image"]["large"], dirn, og_quality=cover_og_quality)
get_extra(meta["image"]["large"], dirn,
og_quality=cover_og_quality)

if "goodies" in meta:
try:
get_extra(meta["goodies"][0]["url"], dirn, "booklet.pdf")
except: # noqa
pass
media_numbers = [track["media_number"] for track in meta["tracks"]["items"]]
media_numbers = [track["media_number"] for track in
meta["tracks"]["items"]]
is_multiple = True if len([*{*media_numbers}]) > 1 else False
for i in meta["tracks"]["items"]:
parse = client.get_track_url(i["id"], quality)
Expand All @@ -267,10 +272,12 @@ def download_id_by_type(
meta = client.get_track_meta(item_id)
track_title = get_title(meta)
logger.info(f"\n{YELLOW}Downloading: {track_title}")
track_format, quality_met = get_format(client, meta, quality, True, parse)
track_format, quality_met = get_format(client, meta,
quality, True, parse)
if not downgrade_quality and not quality_met:
logger.info(
f"{OFF}Skipping {track_title} as doesn't met quality requirement"
f"{OFF}Skipping {track_title} as it doesn't "
"meet quality requirement"
)
return
dirT = (
Expand All @@ -286,10 +293,12 @@ def download_id_by_type(
logger.info(f"{OFF}Skipping cover")
else:
get_extra(
meta["album"]["image"]["large"], dirn, og_quality=cover_og_quality
meta["album"]["image"]["large"], dirn,
og_quality=cover_og_quality
)
is_mp3 = True if int(quality) == 5 else False
download_and_tag(dirn, count, parse, meta, meta, True, is_mp3, embed_art)
download_and_tag(dirn, count, parse, meta,
meta, True, is_mp3, embed_art)
else:
logger.info(f"{OFF}Demo. Skipping")
logger.info(f"{GREEN}Completed")
14 changes: 4 additions & 10 deletions qobuz_dl/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,10 @@ def _format_genres(genres: list) -> str:
'Pop/Rock, Rock, Alternatif et Indé'
'''

if len(genres) <= 1:
return ''.join(genres)

prev = genres[0]
new_genres = [prev]
for genre in genres[1:]:
new_genres.append(genre.replace(f'{prev}→', ''))
prev = genre

return ', '.join(new_genres)
if genres == []:
return ''
else:
return ', '.join(genres[-1].split("→"))


# Use KeyError catching instead of dict.get to avoid empty tags
Expand Down

0 comments on commit 678910d

Please sign in to comment.