mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-11-22 19:15:25 +01:00
parent
2ff4835299
commit
9cec3fccfb
@ -1,2 +1,2 @@
|
|||||||
from .qopy import Client
|
|
||||||
from .cli import main
|
from .cli import main
|
||||||
|
from .qopy import Client
|
||||||
|
@ -38,15 +38,23 @@ def getDesc(u, mt, multiple=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_format(album_dict, quality):
|
def get_format(client, item_dict, quality, is_track_id=False):
|
||||||
try:
|
|
||||||
if int(quality) == 5:
|
if int(quality) == 5:
|
||||||
return "MP3"
|
return "MP3"
|
||||||
if album_dict["maximum_bit_depth"] == 16 and int(quality) < 7:
|
track_dict = item_dict
|
||||||
|
if not is_track_id:
|
||||||
|
track_dict = [i for i in item_dict["tracks"]["items"]][0]
|
||||||
|
|
||||||
|
try:
|
||||||
|
new_track_dict = client.get_track_url(track_dict["id"], quality)
|
||||||
|
if (
|
||||||
|
new_track_dict["bit_depth"] == 16
|
||||||
|
and new_track_dict["sampling_rate"] == 44.1
|
||||||
|
):
|
||||||
return "FLAC"
|
return "FLAC"
|
||||||
|
return "Hi-Res"
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
return "Hi-Res"
|
|
||||||
|
|
||||||
|
|
||||||
def get_extra(i, dirn, extra="cover.jpg"):
|
def get_extra(i, dirn, extra="cover.jpg"):
|
||||||
@ -134,17 +142,16 @@ def download_id_by_type(client, item_id, path, quality, album=False, embed_art=F
|
|||||||
|
|
||||||
if album:
|
if album:
|
||||||
meta = client.get_album_meta(item_id)
|
meta = client.get_album_meta(item_id)
|
||||||
album_title = (
|
try:
|
||||||
"{} ({})".format(meta["title"], meta["version"])
|
album_title = "{} ({})".format(meta["title"], meta["version"])
|
||||||
if meta["version"]
|
except KeyError:
|
||||||
else meta["title"]
|
album_title = meta["title"]
|
||||||
)
|
|
||||||
print("\nDownloading: {}\n".format(album_title))
|
print("\nDownloading: {}\n".format(album_title))
|
||||||
dirT = (
|
dirT = (
|
||||||
meta["artist"]["name"],
|
meta["artist"]["name"],
|
||||||
album_title,
|
album_title,
|
||||||
meta["release_date_original"].split("-")[0],
|
meta["release_date_original"].split("-")[0],
|
||||||
get_format(meta, quality),
|
get_format(client, meta, quality),
|
||||||
)
|
)
|
||||||
sanitized_title = sanitize_filename("{} - {} [{}] [{}]".format(*dirT))
|
sanitized_title = sanitize_filename("{} - {} [{}] [{}]".format(*dirT))
|
||||||
dirn = os.path.join(path, sanitized_title)
|
dirn = os.path.join(path, sanitized_title)
|
||||||
@ -180,17 +187,16 @@ def download_id_by_type(client, item_id, path, quality, album=False, embed_art=F
|
|||||||
|
|
||||||
if "sample" not in parse and parse["sampling_rate"]:
|
if "sample" not in parse and parse["sampling_rate"]:
|
||||||
meta = client.get_track_meta(item_id)
|
meta = client.get_track_meta(item_id)
|
||||||
track_title = (
|
try:
|
||||||
"{} ({})".format(meta["title"], meta["version"])
|
track_title = "{} ({})".format(meta["title"], meta["version"])
|
||||||
if meta["version"]
|
except KeyError:
|
||||||
else meta["title"]
|
track_title = meta["title"]
|
||||||
)
|
|
||||||
print("\nDownloading: {}\n".format(track_title))
|
print("\nDownloading: {}\n".format(track_title))
|
||||||
dirT = (
|
dirT = (
|
||||||
meta["album"]["artist"]["name"],
|
meta["album"]["artist"]["name"],
|
||||||
track_title,
|
track_title,
|
||||||
meta["album"]["release_date_original"].split("-")[0],
|
meta["album"]["release_date_original"].split("-")[0],
|
||||||
get_format(meta, quality),
|
get_format(client, meta, quality, True),
|
||||||
)
|
)
|
||||||
sanitized_title = sanitize_filename("{} - {} [{}] [{}]".format(*dirT))
|
sanitized_title = sanitize_filename("{} - {} [{}] [{}]".format(*dirT))
|
||||||
dirn = os.path.join(path, sanitized_title)
|
dirn = os.path.join(path, sanitized_title)
|
||||||
|
@ -18,10 +18,18 @@ def tag_flac(filename, root_dir, final_name, d, album, istrack=True, em_image=Fa
|
|||||||
"""
|
"""
|
||||||
audio = FLAC(filename)
|
audio = FLAC(filename)
|
||||||
|
|
||||||
audio["TITLE"] = (
|
try:
|
||||||
"{} ({})".format(d["title"], d["version"]) if d["version"] else d["title"]
|
audio["TITLE"] = "{} ({})".format(d["title"], d["version"])
|
||||||
) # TRACK TITLE
|
except KeyError:
|
||||||
|
audio["TITLE"] = d["title"]
|
||||||
|
|
||||||
audio["TRACKNUMBER"] = str(d["track_number"]) # TRACK NUMBER
|
audio["TRACKNUMBER"] = str(d["track_number"]) # TRACK NUMBER
|
||||||
|
|
||||||
|
try:
|
||||||
|
audio["WORK"] = d["work"]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
audio["COMPOSER"] = d["composer"]["name"] # COMPOSER
|
audio["COMPOSER"] = d["composer"]["name"] # COMPOSER
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -73,17 +81,23 @@ def tag_mp3(filename, root_dir, final_name, d, album, istrack=True, em_image=Fal
|
|||||||
:param str root_dir: Root dir used to get the cover art
|
:param str root_dir: Root dir used to get the cover art
|
||||||
:param str final_name: Final name of the mp3 file (complete path)
|
:param str final_name: Final name of the mp3 file (complete path)
|
||||||
:param dict d: Track dictionary from Qobuz_client
|
:param dict d: Track dictionary from Qobuz_client
|
||||||
:param dict album: Album dictionary from Qobuz_client
|
:param bool istrack: Embed cover art into file
|
||||||
:param bool istrack
|
|
||||||
:param bool em_image: Embed cover art into file
|
:param bool em_image: Embed cover art into file
|
||||||
"""
|
"""
|
||||||
# TODO: add embedded cover art support for mp3
|
# TODO: add embedded cover art support for mp3
|
||||||
audio = EasyMP3(filename)
|
audio = EasyMP3(filename)
|
||||||
|
|
||||||
audio["title"] = (
|
try:
|
||||||
"{} ({})".format(d["title"], d["version"]) if d["version"] else d["title"]
|
audio["title"] = "{} ({})".format(d["title"], d["version"])
|
||||||
) # TRACK TITLE
|
except KeyError:
|
||||||
|
audio["title"] = d["title"]
|
||||||
|
|
||||||
audio["tracknumber"] = str(d["track_number"])
|
audio["tracknumber"] = str(d["track_number"])
|
||||||
|
|
||||||
|
try:
|
||||||
|
audio["discsubtitle"] = d["work"]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
audio["composer"] = d["composer"]["name"]
|
audio["composer"] = d["composer"]["name"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -29,8 +29,13 @@ class Search:
|
|||||||
self.Total.append("[RELEASE] {} - {} - {} [{}]".format(*items))
|
self.Total.append("[RELEASE] {} - {} - {} [{}]".format(*items))
|
||||||
self.appendInfo(i, True)
|
self.appendInfo(i, True)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
try:
|
||||||
|
artist_field = i["performer"]["name"]
|
||||||
|
except KeyError:
|
||||||
|
print("Download: " + i["title"])
|
||||||
|
artist_field = i["composer"]["name"]
|
||||||
items = (
|
items = (
|
||||||
i["performer"]["name"],
|
artist_field,
|
||||||
i["title"],
|
i["title"],
|
||||||
self.seconds(i["duration"]),
|
self.seconds(i["duration"]),
|
||||||
"HI-RES" if i["hires"] else "Lossless",
|
"HI-RES" if i["hires"] else "Lossless",
|
||||||
|
Loading…
Reference in New Issue
Block a user