Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vitiko98 committed Jan 26, 2021
1 parent e57cf32 commit f34975e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions qobuz_dl/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def reset_config(config_file):
password = input("Enter your password\n- ")
config["DEFAULT"]["password"] = hashlib.md5(password.encode("utf-8")).hexdigest()
config["DEFAULT"]["default_folder"] = (
input("Folder for downloads (leave empy for default 'Qobuz Downloads')\n- ")
input("Folder for downloads (leave empty for default 'Qobuz Downloads')\n- ")
or "Qobuz Downloads"
)
config["DEFAULT"]["default_quality"] = (
input(
"Download quality (5, 6, 7, 27) "
"[320, LOSSLESS, 24B <96KHZ, 24B >96KHZ]"
"\n(leave empy for default '6')\n- "
"\n(leave empty for default '6')\n- "
)
or "6"
)
Expand Down
8 changes: 6 additions & 2 deletions qobuz_dl/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,17 @@ def get_id(self, url):

def download_from_id(self, item_id, album=True, alt_path=None):
if handle_download_id(self.downloads_db, item_id, add_id=False):
logger.info(f"{OFF}This release ID ({item_id}) was already downloaded")
logger.info(
f"{OFF}This release ID ({item_id}) was already downloaded "
"according to the local database.\nUse the '--no-db' flag "
"to bypass this."
)
return
try:
downloader.download_id_by_type(
self.client,
item_id,
self.directory if not alt_path else alt_path,
alt_path or self.directory,
str(self.quality),
album,
self.embed_art,
Expand Down
8 changes: 6 additions & 2 deletions qobuz_dl/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import qobuz_dl.metadata as metadata
from qobuz_dl.color import OFF, GREEN, RED, YELLOW, CYAN
from qobuz_dl.exceptions import NonStreamable

QL_DOWNGRADE = "FormatRestrictedByFormatAvailability"
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -145,8 +146,8 @@ def download_and_tag(
if version:
new_track_title = f"{new_track_title} ({version})"

track_file = f'{track_metadata["track_number"]:02}. {new_track_title}{extension}'
final_file = os.path.join(root_dir, sanitize_filename(track_file))
track_file = f'{track_metadata["track_number"]:02}. {new_track_title}'
final_file = os.path.join(root_dir, sanitize_filename(track_file))[:250] + extension

if os.path.isfile(final_file):
logger.info(f"{OFF}{new_track_title} was already downloaded")
Expand Down Expand Up @@ -200,6 +201,9 @@ def download_id_by_type(
if album:
meta = client.get_album_meta(item_id)

if not meta.get("streamable"):
raise NonStreamable("This release is not streamable")

if albums_only and (
meta.get("release_type") != "album"
or meta.get("artist").get("name") == "Various Artists"
Expand Down
4 changes: 4 additions & 0 deletions qobuz_dl/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ class InvalidAppSecretError(Exception):

class InvalidQuality(Exception):
pass


class NonStreamable(Exception):
pass

0 comments on commit f34975e

Please sign in to comment.