mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-11-22 19:15:25 +01:00
Merge pull request #11 from ktcar214/master
add Version to file tag(complete)
This commit is contained in:
commit
7bb366ae72
@ -31,7 +31,7 @@ def mkDir(dirn):
|
|||||||
|
|
||||||
|
|
||||||
def getDesc(u, mt):
|
def getDesc(u, mt):
|
||||||
return "{} [{}/{}]".format(mt["title"], u["bit_depth"], u["sampling_rate"])
|
return "{}{} [{}/{}]".format(mt["title"],' (' + mt["version"] + ')' if mt["version"] is not None else '', u["bit_depth"], u["sampling_rate"])
|
||||||
|
|
||||||
def getBooklet(i, dirn):
|
def getBooklet(i, dirn):
|
||||||
req_tqdm(i, dirn + "/booklet.pdf", "Downloading booklet")
|
req_tqdm(i, dirn + "/booklet.pdf", "Downloading booklet")
|
||||||
@ -59,13 +59,15 @@ def iterateIDs(client, id, path, quality, album=False):
|
|||||||
|
|
||||||
if album:
|
if album:
|
||||||
meta = client.get_album_meta(id)
|
meta = client.get_album_meta(id)
|
||||||
print("\nDownloading: {}\n".format(meta["title"]))
|
|
||||||
|
print("\nDownloading: {0} {1}\n".format(meta["title"], '(' + meta["version"] + ')' if meta["version"] is not None else ' '))
|
||||||
dirT = (
|
dirT = (
|
||||||
meta["artist"]["name"],
|
meta["artist"]["name"],
|
||||||
meta["title"],
|
meta["title"],
|
||||||
|
' ' + meta["version"] if meta["version"] is not None else '',
|
||||||
meta["release_date_original"].split("-")[0],
|
meta["release_date_original"].split("-")[0],
|
||||||
)
|
)
|
||||||
sanitized_title = sanitize_filename("{} - {} [{}]".format(*dirT))
|
sanitized_title = sanitize_filename("{} - {}{} [{}]".format(*dirT)) #aa-{}
|
||||||
dirn = path + sanitized_title
|
dirn = path + sanitized_title
|
||||||
mkDir(dirn)
|
mkDir(dirn)
|
||||||
getCover(meta["image"]["large"], dirn)
|
getCover(meta["image"]["large"], dirn)
|
||||||
@ -90,13 +92,14 @@ def iterateIDs(client, id, path, quality, album=False):
|
|||||||
|
|
||||||
if "sample" not in parse:
|
if "sample" not in parse:
|
||||||
meta = client.get_track_meta(id)
|
meta = client.get_track_meta(id)
|
||||||
print("\nDownloading: {}\n".format(meta["title"]))
|
print("\nDownloading: {0} {1}\n".format(meta["title"], '(' + meta["version"] + ')' if meta["version"] is not None else ' '))
|
||||||
dirT = (
|
dirT = (
|
||||||
meta["album"]["artist"]["name"],
|
meta["album"]["artist"]["name"],
|
||||||
meta["title"],
|
meta["album"]["title"],
|
||||||
|
' ' + meta["album"]["version"] if meta["album"]["version"] is not None else '',
|
||||||
meta["album"]["release_date_original"].split("-")[0],
|
meta["album"]["release_date_original"].split("-")[0],
|
||||||
)
|
)
|
||||||
sanitized_title = sanitize_filename("{} - {} [{}]".format(*dirT))
|
sanitized_title = sanitize_filename("{} - {}{} [{}]".format(*dirT))
|
||||||
dirn = path + sanitized_title
|
dirn = path + sanitized_title
|
||||||
mkDir(dirn)
|
mkDir(dirn)
|
||||||
getCover(meta["album"]["image"]["large"], dirn)
|
getCover(meta["album"]["image"]["large"], dirn)
|
||||||
|
@ -4,11 +4,25 @@ from mutagen.flac import FLAC
|
|||||||
from mutagen.mp3 import EasyMP3
|
from mutagen.mp3 import EasyMP3
|
||||||
from pathvalidate import sanitize_filename
|
from pathvalidate import sanitize_filename
|
||||||
|
|
||||||
|
|
||||||
def tag_flac(file, path, d, album, istrack=True):
|
def tag_flac(file, path, d, album, istrack=True):
|
||||||
audio = FLAC(file)
|
audio = FLAC(file)
|
||||||
|
try:
|
||||||
|
d["version"]
|
||||||
|
except KeyError:
|
||||||
|
audio["TITLE"] = d["title"]
|
||||||
|
dversion_exist = 0
|
||||||
|
else:
|
||||||
|
if d["version"] is None:
|
||||||
audio["TITLE"] = d["title"]# TRACK TITLE
|
audio["TITLE"] = d["title"]# TRACK TITLE
|
||||||
|
dversion_exist = 0
|
||||||
|
else:
|
||||||
|
audio["TITLE"] = d["title"] + ' ' + '(' + d["version"] + ')'
|
||||||
|
dversion_exist = 1
|
||||||
|
# if d["version"] is None:
|
||||||
|
# audio["TITLE"] = d["title"]# TRACK TITLE
|
||||||
|
# else:
|
||||||
|
# audio["TITLE"] = d["title"] + ' ' + '(' + d["version"] + ')'
|
||||||
|
|
||||||
audio["TRACKNUMBER"] = str(d["track_number"]) # TRACK NUMBER
|
audio["TRACKNUMBER"] = str(d["track_number"]) # TRACK NUMBER
|
||||||
try:
|
try:
|
||||||
audio["COMPOSER"] = d["composer"]["name"] # COMPOSER
|
audio["COMPOSER"] = d["composer"]["name"] # COMPOSER
|
||||||
@ -24,19 +38,36 @@ def tag_flac(file, path, d, album, istrack=True):
|
|||||||
audio["ARTIST"] = album["artist"]["name"]
|
audio["ARTIST"] = album["artist"]["name"]
|
||||||
|
|
||||||
if istrack:
|
if istrack:
|
||||||
|
if dversion_exist == 0:
|
||||||
audio["GENRE"] = ", ".join(d["album"]["genres_list"]) # GENRE
|
audio["GENRE"] = ", ".join(d["album"]["genres_list"]) # GENRE
|
||||||
audio["ALBUMARTIST"] = d["album"]["artist"]["name"] # ALBUM ARTIST
|
audio["ALBUMARTIST"] = d["album"]["artist"]["name"] # ALBUM ARTIST
|
||||||
audio["TRACKTOTAL"] = str(d["album"]["tracks_count"]) # TRACK TOTAL
|
audio["TRACKTOTAL"] = str(d["album"]["tracks_count"]) # TRACK TOTAL
|
||||||
audio["ALBUM"] = d["album"]["title"] # ALBUM TITLE
|
audio["ALBUM"] = d["album"]["title"] # ALBUM TITLE
|
||||||
audio["YEAR"] = d["album"]["release_date_original"].split("-")[0]
|
audio["YEAR"] = d["album"]["release_date_original"].split("-")[0]
|
||||||
else:
|
else:
|
||||||
|
audio["GENRE"] = ", ".join(d["album"]["genres_list"]) # GENRE
|
||||||
|
audio["ALBUMARTIST"] = d["album"]["artist"]["name"] # ALBUM ARTIST
|
||||||
|
audio["TRACKTOTAL"] = str(d["album"]["tracks_count"]) # TRACK TOTAL
|
||||||
|
audio["ALBUM"] = d["album"]["title"] + ' ' + '(' + d["album"]["version"] + ')' # ALBUM TITLE
|
||||||
|
audio["YEAR"] = d["album"]["release_date_original"].split("-")[0]
|
||||||
|
else:
|
||||||
|
if dversion_exist == 0:
|
||||||
audio["GENRE"] = ", ".join(album["genres_list"]) # GENRE
|
audio["GENRE"] = ", ".join(album["genres_list"]) # GENRE
|
||||||
audio["ALBUMARTIST"] = album["artist"]["name"] # ALBUM ARTIST
|
audio["ALBUMARTIST"] = album["artist"]["name"] # ALBUM ARTIST
|
||||||
audio["TRACKTOTAL"] = str(album["tracks_count"]) # TRACK TOTAL
|
audio["TRACKTOTAL"] = str(album["tracks_count"]) # TRACK TOTAL
|
||||||
audio["ALBUM"] = album["title"] # ALBUM TITLE
|
audio["ALBUM"] = album["title"] # ALBUM TITLE
|
||||||
audio["YEAR"] = album["release_date_original"].split("-")[0] # YEAR
|
audio["YEAR"] = album["release_date_original"].split("-")[0] # YEAR
|
||||||
|
else:
|
||||||
|
audio["GENRE"] = ", ".join(album["genres_list"]) # GENRE
|
||||||
|
audio["ALBUMARTIST"] = album["artist"]["name"] # ALBUM ARTIST
|
||||||
|
audio["TRACKTOTAL"] = str(album["tracks_count"]) # TRACK TOTAL
|
||||||
|
audio["ALBUM"] = album["title"] + ' ' + '(' + album["version"] + ')' # ALBUM TITLE
|
||||||
|
audio["YEAR"] = album["release_date_original"].split("-")[0] # YEAR
|
||||||
|
|
||||||
audio.save()
|
audio.save()
|
||||||
|
if dversion_exist == 1:
|
||||||
|
title = sanitize_filename(d["title"] + ' ' + '(' + d["version"] + ')')
|
||||||
|
else:
|
||||||
title = sanitize_filename(d["title"])
|
title = sanitize_filename(d["title"])
|
||||||
try:
|
try:
|
||||||
os.rename(file, "{}/{:02}. {}.flac".format(path, d["track_number"], title))
|
os.rename(file, "{}/{:02}. {}.flac".format(path, d["track_number"], title))
|
||||||
@ -44,10 +75,21 @@ def tag_flac(file, path, d, album, istrack=True):
|
|||||||
print("File already exists. Skipping...")
|
print("File already exists. Skipping...")
|
||||||
|
|
||||||
|
|
||||||
def tag_mp3(file, path, d, album, istrack=True):
|
def tag_mp3(file, path, d, album, istrack=True): #needs to be fixed
|
||||||
audio = EasyMP3(file)
|
audio = EasyMP3(file)
|
||||||
|
try:
|
||||||
|
d["version"]
|
||||||
|
except KeyError:
|
||||||
|
audio["TITLE"] = d["title"]
|
||||||
|
dversion_exist = 0
|
||||||
|
else:
|
||||||
|
if d["version"] is None:
|
||||||
|
audio["TITLE"] = d["title"]# TRACK TITLE
|
||||||
|
dversion_exist = 0
|
||||||
|
else:
|
||||||
|
audio["TITLE"] = d["title"] + ' ' + '(' + d["version"] + ')'
|
||||||
|
dversion_exist = 1
|
||||||
|
|
||||||
audio["title"] = d["title"]
|
|
||||||
audio["tracknumber"] = str(d["track_number"])
|
audio["tracknumber"] = str(d["track_number"])
|
||||||
try:
|
try:
|
||||||
audio["composer"] = d["composer"]["name"]
|
audio["composer"] = d["composer"]["name"]
|
||||||
@ -60,12 +102,28 @@ def tag_mp3(file, path, d, album, istrack=True):
|
|||||||
audio["artist"] = d["album"]["artist"]["name"] # TRACK ARTIST
|
audio["artist"] = d["album"]["artist"]["name"] # TRACK ARTIST
|
||||||
else:
|
else:
|
||||||
audio["artist"] = album["artist"]["name"]
|
audio["artist"] = album["artist"]["name"]
|
||||||
|
|
||||||
if istrack:
|
if istrack:
|
||||||
|
if dversion_exist == 1:
|
||||||
|
audio["genre"] = ", ".join(d["album"]["genres_list"]) # GENRE
|
||||||
|
audio["albumartist"] = d["album"]["artist"]["name"] # ALBUM ARTIST
|
||||||
|
audio["album"] = d["album"]["title"] + ' ' + '(' + d["album"]["version"] + ')' # ALBUM TITLE
|
||||||
|
audio["date"] = d["album"]["release_date_original"].split("-")[0]
|
||||||
|
else:
|
||||||
audio["genre"] = ", ".join(d["album"]["genres_list"]) # GENRE
|
audio["genre"] = ", ".join(d["album"]["genres_list"]) # GENRE
|
||||||
audio["albumartist"] = d["album"]["artist"]["name"] # ALBUM ARTIST
|
audio["albumartist"] = d["album"]["artist"]["name"] # ALBUM ARTIST
|
||||||
audio["album"] = d["album"]["title"] # ALBUM TITLE
|
audio["album"] = d["album"]["title"] # ALBUM TITLE
|
||||||
audio["date"] = d["album"]["release_date_original"].split("-")[0]
|
audio["date"] = d["album"]["release_date_original"].split("-")[0]
|
||||||
|
else:
|
||||||
|
if album["version"] is not None:
|
||||||
|
audio["GENRE"] = ", ".join(album["genres_list"]) # GENRE
|
||||||
|
audio["albumartist"] = album["artist"]["name"] # ALBUM ARTIST
|
||||||
|
try:
|
||||||
|
album["version"]
|
||||||
|
except KeyError:
|
||||||
|
audio["album"] = album["title"]
|
||||||
|
else:
|
||||||
|
audio["album"] = album["title"] + ' ' + '(' + album["version"] + ')' # ALBUM TITLE
|
||||||
|
audio["date"] = album["release_date_original"].split("-")[0] # YEAR
|
||||||
else:
|
else:
|
||||||
audio["GENRE"] = ", ".join(album["genres_list"]) # GENRE
|
audio["GENRE"] = ", ".join(album["genres_list"]) # GENRE
|
||||||
audio["albumartist"] = album["artist"]["name"] # ALBUM ARTIST
|
audio["albumartist"] = album["artist"]["name"] # ALBUM ARTIST
|
||||||
@ -73,6 +131,9 @@ def tag_mp3(file, path, d, album, istrack=True):
|
|||||||
audio["date"] = album["release_date_original"].split("-")[0] # YEAR
|
audio["date"] = album["release_date_original"].split("-")[0] # YEAR
|
||||||
|
|
||||||
audio.save()
|
audio.save()
|
||||||
|
if dversion_exist == 1:
|
||||||
|
title = sanitize_filename(d["title"] + ' ' + '(' + d["version"] + ')')
|
||||||
|
else:
|
||||||
title = sanitize_filename(d["title"])
|
title = sanitize_filename(d["title"])
|
||||||
try:
|
try:
|
||||||
os.rename(file, "{}/{:02}. {}.mp3".format(path, d["track_number"], title))
|
os.rename(file, "{}/{:02}. {}.mp3".format(path, d["track_number"], title))
|
||||||
|
Loading…
Reference in New Issue
Block a user