mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-11-22 02:55:25 +01:00
Fix Color code error with windows; close #36
Covers won't be downloaded in their original size anymore by default as they are too big. If you still want to download in the original size, just set the flag --og-cover after running a qobuz-dl command.
This commit is contained in:
parent
fd260ee0f3
commit
5f3c85847f
@ -99,6 +99,7 @@ def main():
|
||||
ignore_singles_eps=arguments.albums_only,
|
||||
no_m3u_for_playlists=arguments.no_m3u,
|
||||
quality_fallback=not arguments.no_fallback,
|
||||
cover_og_quality=arguments.og_cover,
|
||||
)
|
||||
qobuz.initialize_client(email, password, app_id, secrets)
|
||||
|
||||
|
@ -4,6 +4,7 @@ init(autoreset=True)
|
||||
|
||||
DF = Style.NORMAL
|
||||
BG = Style.BRIGHT
|
||||
RESET = Style.RESET_ALL
|
||||
OFF = Style.DIM
|
||||
RED = Fore.RED
|
||||
BLUE = Fore.BLUE
|
||||
|
@ -91,6 +91,9 @@ def add_common_arg(custom_parser, default_folder, default_quality):
|
||||
custom_parser.add_argument(
|
||||
"-e", "--embed-art", action="store_true", help="embed cover art into files"
|
||||
)
|
||||
custom_parser.add_argument(
|
||||
"--og-cover", action="store_true", help="download cover art in its original quality (bigger file)"
|
||||
)
|
||||
|
||||
|
||||
def qobuz_dl_args(
|
||||
|
@ -13,7 +13,7 @@ from pathvalidate import sanitize_filename
|
||||
|
||||
import qobuz_dl.spoofbuz as spoofbuz
|
||||
from qobuz_dl import downloader, qopy
|
||||
from qobuz_dl.color import MAGENTA, OFF, RED, YELLOW, DF
|
||||
from qobuz_dl.color import MAGENTA, OFF, RED, YELLOW, DF, RESET
|
||||
|
||||
WEB_URL = "https://play.qobuz.com/"
|
||||
ARTISTS_SELECTOR = "td.chartlist-artist > a"
|
||||
@ -58,6 +58,7 @@ class QobuzDL:
|
||||
ignore_singles_eps=False,
|
||||
no_m3u_for_playlists=False,
|
||||
quality_fallback=True,
|
||||
cover_og_quality=False,
|
||||
):
|
||||
self.directory = self.create_dir(directory)
|
||||
self.quality = quality
|
||||
@ -68,10 +69,11 @@ class QobuzDL:
|
||||
self.ignore_singles_eps = ignore_singles_eps
|
||||
self.no_m3u_for_playlists = no_m3u_for_playlists
|
||||
self.quality_fallback = quality_fallback
|
||||
self.cover_og_quality = cover_og_quality
|
||||
|
||||
def initialize_client(self, email, pwd, app_id, secrets):
|
||||
self.client = qopy.Client(email, pwd, app_id, secrets)
|
||||
logger.info(f"{YELLOW}Set quality: {QUALITIES[int(self.quality)]}")
|
||||
logger.info(f"{YELLOW}Set quality: {QUALITIES[int(self.quality)]}\n")
|
||||
|
||||
def get_tokens(self):
|
||||
spoofer = spoofbuz.Spoofer()
|
||||
@ -103,6 +105,7 @@ class QobuzDL:
|
||||
self.embed_art,
|
||||
self.ignore_singles_eps,
|
||||
self.quality_fallback,
|
||||
self.cover_og_quality,
|
||||
)
|
||||
|
||||
def handle_url(self, url):
|
||||
@ -283,16 +286,16 @@ class QobuzDL:
|
||||
selected_type = pick(item_types, "I'll search for:\n[press Intro]")[0][
|
||||
:-1
|
||||
].lower()
|
||||
logger.info(f"{YELLOW}Ok, we'll search for {selected_type}s")
|
||||
logger.info(f"{YELLOW}Ok, we'll search for {selected_type}s{RESET}")
|
||||
final_url_list = []
|
||||
while True:
|
||||
query = input(f"{MAGENTA}Enter your search: [Ctrl + c to quit]\n-{DF} ")
|
||||
logger.info(f"{YELLOW}Searching...")
|
||||
logger.info(f"{YELLOW}Searching...{RESET}")
|
||||
options = self.search_by_type(
|
||||
query, selected_type, self.interactive_limit
|
||||
)
|
||||
if not options:
|
||||
logger.info(f"{OFF}Nothing found")
|
||||
logger.info(f"{OFF}Nothing found{RESET}")
|
||||
continue
|
||||
title = (
|
||||
f'*** RESULTS FOR "{query.title()}" ***\n\n'
|
||||
@ -316,7 +319,7 @@ class QobuzDL:
|
||||
if y_n[0][0] == "N":
|
||||
break
|
||||
else:
|
||||
logger.info(f"{YELLOW}Ok, try again...")
|
||||
logger.info(f"{YELLOW}Ok, try again...{RESET}")
|
||||
continue
|
||||
if final_url_list:
|
||||
desc = (
|
||||
|
@ -87,13 +87,13 @@ def get_title(item_dict):
|
||||
return final_title
|
||||
|
||||
|
||||
def get_extra(i, dirn, extra="cover.jpg"):
|
||||
def get_extra(i, dirn, extra="cover.jpg", og_quality=False):
|
||||
extra_file = os.path.join(dirn, extra)
|
||||
if os.path.isfile(extra_file):
|
||||
logger.info(f"{OFF}{extra} was already downloaded")
|
||||
return
|
||||
tqdm_download(
|
||||
i.replace("_600.", "_org."),
|
||||
i.replace("_600.", "_org.") if og_quality else i,
|
||||
extra_file,
|
||||
extra,
|
||||
)
|
||||
@ -174,6 +174,7 @@ def download_id_by_type(
|
||||
embed_art=False,
|
||||
albums_only=False,
|
||||
downgrade_quality=True,
|
||||
cover_og_quality=False,
|
||||
):
|
||||
"""
|
||||
Download and get metadata by ID and type (album or track)
|
||||
@ -186,6 +187,7 @@ def download_id_by_type(
|
||||
:param embed_art album: Embed cover art into files
|
||||
:param bool albums_only: Ignore Singles, EPs and VA releases
|
||||
:param bool downgrade: Skip releases not available in set quality
|
||||
:param bool cover_og_quality: Download cover in its original quality
|
||||
"""
|
||||
count = 0
|
||||
|
||||
@ -217,7 +219,7 @@ def download_id_by_type(
|
||||
sanitized_title = sanitize_filename("{} - {} [{}] [{}]".format(*dirT))
|
||||
dirn = os.path.join(path, sanitized_title)
|
||||
os.makedirs(dirn, exist_ok=True)
|
||||
get_extra(meta["image"]["large"], dirn)
|
||||
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")
|
||||
@ -273,7 +275,7 @@ def download_id_by_type(
|
||||
sanitized_title = sanitize_filename("{} - {} [{}] [{}]".format(*dirT))
|
||||
dirn = os.path.join(path, sanitized_title)
|
||||
os.makedirs(dirn, exist_ok=True)
|
||||
get_extra(meta["album"]["image"]["large"], dirn)
|
||||
get_extra(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)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user