mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-11-22 11:05:25 +01:00
Reverse config.py; formatting
This commit is contained in:
parent
7bb366ae72
commit
5eaabfc55b
23
README.md
23
README.md
@ -27,20 +27,19 @@ pip3 install -r requirements.txt --user
|
|||||||
pip3 install windows-curses
|
pip3 install windows-curses
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
```
|
```
|
||||||
#### Add your credentials to a `.env` file
|
#### Add your credentials to `config.py` file
|
||||||
```none
|
```python
|
||||||
QOBUZ_EMAIL=your@email.com
|
email = "your@email.com"
|
||||||
QOBUZ_PW=your_password
|
password = "your_password"
|
||||||
```
|
```
|
||||||
|
|
||||||
NB: The .env file should be in the root folder, where main.py and config.py are located.
|
In addition to your credentials, you can also use the `config.py` file to
|
||||||
|
change other default values:
|
||||||
In addition to your credentials, you can also use the `.env` file to
|
```python
|
||||||
change other default values by means of the following environment variables:
|
default_folder = "Qobuz Downloads"
|
||||||
|
default_limit = 10
|
||||||
- `QOBUZ_FOLDER` (location of the download folder)
|
default_quality = 6
|
||||||
- `QOBUZ_LIMIT` (results limit)
|
```
|
||||||
- `QOBUZ_QUALITY` (default quality for url input mode)
|
|
||||||
|
|
||||||
#### Run qobuz-dl
|
#### Run qobuz-dl
|
||||||
##### Linux / MAC OS
|
##### Linux / MAC OS
|
||||||
|
13
config.py
13
config.py
@ -1,16 +1,15 @@
|
|||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
|
||||||
load_dotenv()
|
|
||||||
# Qobuz credentials (Don't remove the quotes!)
|
# Qobuz credentials (Don't remove the quotes!)
|
||||||
email = os.getenv('QOBUZ_EMAIL')
|
email = "your@email.com"
|
||||||
password = os.getenv('QOBUZ_PW')
|
password = "your_password"
|
||||||
|
|
||||||
# Default folder where the releases are downloaded
|
# Default folder where the releases are downloaded
|
||||||
default_folder = os.getenv('QOBUZ_FOLDER', "Qobuz Downloads")
|
default_folder = "Qobuz Downloads"
|
||||||
|
|
||||||
# Default per type results limit
|
# Default per type results limit
|
||||||
default_limit = os.getenv('QOBUZ_LIMIT', 10)
|
default_limit = 10
|
||||||
|
|
||||||
# Default quality for url input mode. This will be ignored in interactive mode
|
# Default quality for url input mode. This will be ignored in interactive mode
|
||||||
# (5, 6, 7, 27) [320, LOSSLESS, 24B <96KHZ, 24B >96KHZ]
|
# (5, 6, 7, 27) [320, LOSSLESS, 24B <96KHZ, 24B >96KHZ]
|
||||||
default_quality = os.getenv('QOBUZ_QUALITY', 6)
|
default_quality = 6
|
||||||
|
8
main.py
8
main.py
@ -110,12 +110,12 @@ def interactive(Qz, path, limit, tracks=True):
|
|||||||
while True:
|
while True:
|
||||||
query = input("\nEnter your search: [Ctrl + c to quit]\n- ")
|
query = input("\nEnter your search: [Ctrl + c to quit]\n- ")
|
||||||
print("Searching...")
|
print("Searching...")
|
||||||
if len(query.strip())==0:
|
if len(query.strip()) == 0:
|
||||||
break
|
break
|
||||||
start = Search(Qz, query, limit)
|
start = Search(Qz, query, limit)
|
||||||
start.getResults(tracks)
|
start.getResults(tracks)
|
||||||
if len(start.Total)==0:
|
if len(start.Total) == 0:
|
||||||
break
|
break
|
||||||
Types.append(start.Types)
|
Types.append(start.Types)
|
||||||
IDs.append(start.IDs)
|
IDs.append(start.IDs)
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ def interactive(Qz, path, limit, tracks=True):
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
if len(Albums)>0:
|
if len(Albums) > 0:
|
||||||
desc = (
|
desc = (
|
||||||
"Select [intro] the quality (the quality will be automat"
|
"Select [intro] the quality (the quality will be automat"
|
||||||
"ically\ndowngraded if the selected is not found)"
|
"ically\ndowngraded if the selected is not found)"
|
||||||
|
@ -31,10 +31,17 @@ def mkDir(dirn):
|
|||||||
|
|
||||||
|
|
||||||
def getDesc(u, mt):
|
def getDesc(u, mt):
|
||||||
return "{}{} [{}/{}]".format(mt["title"],' (' + mt["version"] + ')' if mt["version"] is not None else '', 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")
|
||||||
|
|
||||||
|
|
||||||
def getCover(i, dirn):
|
def getCover(i, dirn):
|
||||||
req_tqdm(i, dirn + "/cover.jpg", "Downloading cover art")
|
req_tqdm(i, dirn + "/cover.jpg", "Downloading cover art")
|
||||||
@ -60,14 +67,19 @@ 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: {0} {1}\n".format(meta["title"], '(' + meta["version"] + ')' if meta["version"] is not None else ' '))
|
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["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)) #aa-{}
|
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)
|
||||||
@ -92,11 +104,18 @@ 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: {0} {1}\n".format(meta["title"], '(' + meta["version"] + ')' if meta["version"] is not None else ' '))
|
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["album"]["title"],
|
meta["album"]["title"],
|
||||||
' ' + meta["album"]["version"] if meta["album"]["version"] is not None else '',
|
" " + 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))
|
||||||
|
@ -4,6 +4,7 @@ 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:
|
try:
|
||||||
@ -13,15 +14,15 @@ def tag_flac(file, path, d, album, istrack=True):
|
|||||||
dversion_exist = 0
|
dversion_exist = 0
|
||||||
else:
|
else:
|
||||||
if d["version"] is None:
|
if d["version"] is None:
|
||||||
audio["TITLE"] = d["title"]# TRACK TITLE
|
audio["TITLE"] = d["title"] # TRACK TITLE
|
||||||
dversion_exist = 0
|
dversion_exist = 0
|
||||||
else:
|
else:
|
||||||
audio["TITLE"] = d["title"] + ' ' + '(' + d["version"] + ')'
|
audio["TITLE"] = d["title"] + " " + "(" + d["version"] + ")"
|
||||||
dversion_exist = 1
|
dversion_exist = 1
|
||||||
# if d["version"] is None:
|
# if d["version"] is None:
|
||||||
# audio["TITLE"] = d["title"]# TRACK TITLE
|
# audio["TITLE"] = d["title"]# TRACK TITLE
|
||||||
# else:
|
# else:
|
||||||
# audio["TITLE"] = d["title"] + ' ' + '(' + d["version"] + ')'
|
# audio["TITLE"] = d["title"] + ' ' + '(' + d["version"] + ')'
|
||||||
|
|
||||||
audio["TRACKNUMBER"] = str(d["track_number"]) # TRACK NUMBER
|
audio["TRACKNUMBER"] = str(d["track_number"]) # TRACK NUMBER
|
||||||
try:
|
try:
|
||||||
@ -42,13 +43,15 @@ def tag_flac(file, path, d, album, istrack=True):
|
|||||||
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["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"] + ' ' + '(' + d["album"]["version"] + ')' # ALBUM TITLE
|
audio["ALBUM"] = (
|
||||||
|
d["album"]["title"] + " " + "(" + d["album"]["version"] + ")"
|
||||||
|
) # ALBUM TITLE
|
||||||
audio["YEAR"] = d["album"]["release_date_original"].split("-")[0]
|
audio["YEAR"] = d["album"]["release_date_original"].split("-")[0]
|
||||||
else:
|
else:
|
||||||
if dversion_exist == 0:
|
if dversion_exist == 0:
|
||||||
@ -61,12 +64,14 @@ def tag_flac(file, path, d, album, istrack=True):
|
|||||||
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["version"] + ')' # ALBUM TITLE
|
audio["ALBUM"] = (
|
||||||
|
album["title"] + " " + "(" + album["version"] + ")"
|
||||||
|
) # ALBUM TITLE
|
||||||
audio["YEAR"] = album["release_date_original"].split("-")[0] # YEAR
|
audio["YEAR"] = album["release_date_original"].split("-")[0] # YEAR
|
||||||
|
|
||||||
audio.save()
|
audio.save()
|
||||||
if dversion_exist == 1:
|
if dversion_exist == 1:
|
||||||
title = sanitize_filename(d["title"] + ' ' + '(' + d["version"] + ')')
|
title = sanitize_filename(d["title"] + " " + "(" + d["version"] + ")")
|
||||||
else:
|
else:
|
||||||
title = sanitize_filename(d["title"])
|
title = sanitize_filename(d["title"])
|
||||||
try:
|
try:
|
||||||
@ -75,19 +80,19 @@ 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): #needs to be fixed
|
def tag_mp3(file, path, d, album, istrack=True): # needs to be fixed
|
||||||
audio = EasyMP3(file)
|
audio = EasyMP3(file)
|
||||||
try:
|
try:
|
||||||
d["version"]
|
d["version"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
audio["TITLE"] = d["title"]
|
audio["TITLE"] = d["title"]
|
||||||
dversion_exist = 0
|
dversion_exist = 0
|
||||||
else:
|
else:
|
||||||
if d["version"] is None:
|
if d["version"] is None:
|
||||||
audio["TITLE"] = d["title"]# TRACK TITLE
|
audio["TITLE"] = d["title"] # TRACK TITLE
|
||||||
dversion_exist = 0
|
dversion_exist = 0
|
||||||
else:
|
else:
|
||||||
audio["TITLE"] = d["title"] + ' ' + '(' + d["version"] + ')'
|
audio["TITLE"] = d["title"] + " " + "(" + d["version"] + ")"
|
||||||
dversion_exist = 1
|
dversion_exist = 1
|
||||||
|
|
||||||
audio["tracknumber"] = str(d["track_number"])
|
audio["tracknumber"] = str(d["track_number"])
|
||||||
@ -106,7 +111,9 @@ def tag_mp3(file, path, d, album, istrack=True): #needs to be fixed
|
|||||||
if dversion_exist == 1:
|
if dversion_exist == 1:
|
||||||
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"] + ' ' + '(' + d["album"]["version"] + ')' # ALBUM TITLE
|
audio["album"] = (
|
||||||
|
d["album"]["title"] + " " + "(" + d["album"]["version"] + ")"
|
||||||
|
) # ALBUM TITLE
|
||||||
audio["date"] = d["album"]["release_date_original"].split("-")[0]
|
audio["date"] = d["album"]["release_date_original"].split("-")[0]
|
||||||
else:
|
else:
|
||||||
audio["genre"] = ", ".join(d["album"]["genres_list"]) # GENRE
|
audio["genre"] = ", ".join(d["album"]["genres_list"]) # GENRE
|
||||||
@ -122,7 +129,9 @@ def tag_mp3(file, path, d, album, istrack=True): #needs to be fixed
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
audio["album"] = album["title"]
|
audio["album"] = album["title"]
|
||||||
else:
|
else:
|
||||||
audio["album"] = album["title"] + ' ' + '(' + album["version"] + ')' # ALBUM TITLE
|
audio["album"] = (
|
||||||
|
album["title"] + " " + "(" + album["version"] + ")"
|
||||||
|
) # ALBUM TITLE
|
||||||
audio["date"] = album["release_date_original"].split("-")[0] # YEAR
|
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
|
||||||
@ -132,7 +141,7 @@ def tag_mp3(file, path, d, album, istrack=True): #needs to be fixed
|
|||||||
|
|
||||||
audio.save()
|
audio.save()
|
||||||
if dversion_exist == 1:
|
if dversion_exist == 1:
|
||||||
title = sanitize_filename(d["title"] + ' ' + '(' + d["version"] + ')')
|
title = sanitize_filename(d["title"] + " " + "(" + d["version"] + ")")
|
||||||
else:
|
else:
|
||||||
title = sanitize_filename(d["title"])
|
title = sanitize_filename(d["title"])
|
||||||
try:
|
try:
|
||||||
|
@ -91,7 +91,7 @@ class Client:
|
|||||||
"intent": "stream",
|
"intent": "stream",
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
params=kwargs
|
params = kwargs
|
||||||
r = self.session.get(self.base + epoint, params=params)
|
r = self.session.get(self.base + epoint, params=params)
|
||||||
# Do ref header.
|
# Do ref header.
|
||||||
if epoint == "user/login":
|
if epoint == "user/login":
|
||||||
@ -157,13 +157,19 @@ class Client:
|
|||||||
return self.api_call("track/search", query=query, limit=limit)
|
return self.api_call("track/search", query=query, limit=limit)
|
||||||
|
|
||||||
def get_favorite_albums(self, offset, limit):
|
def get_favorite_albums(self, offset, limit):
|
||||||
return self.api_call("favorite/getUserFavorites", type="albums", offset=offset, limit=limit)
|
return self.api_call(
|
||||||
|
"favorite/getUserFavorites", type="albums", offset=offset, limit=limit
|
||||||
|
)
|
||||||
|
|
||||||
def get_favorite_tracks(self, offset, limit):
|
def get_favorite_tracks(self, offset, limit):
|
||||||
return self.api_call("favorite/getUserFavorites", type="tracks", offset=offset, limit=limit)
|
return self.api_call(
|
||||||
|
"favorite/getUserFavorites", type="tracks", offset=offset, limit=limit
|
||||||
|
)
|
||||||
|
|
||||||
def get_favorite_artists(self, offset, limit):
|
def get_favorite_artists(self, offset, limit):
|
||||||
return self.api_call("favorite/getUserFavorites", type="artists", offset=offset, limit=limit)
|
return self.api_call(
|
||||||
|
"favorite/getUserFavorites", type="artists", offset=offset, limit=limit
|
||||||
|
)
|
||||||
|
|
||||||
def get_user_playlists(self, limit):
|
def get_user_playlists(self, limit):
|
||||||
return self.api_call("playlist/getUserPlaylists", limit=limit)
|
return self.api_call("playlist/getUserPlaylists", limit=limit)
|
||||||
|
@ -28,23 +28,23 @@ 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:
|
try:
|
||||||
items = (
|
items = (
|
||||||
i["performer"]["name"],
|
i["performer"]["name"],
|
||||||
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",
|
||||||
)
|
)
|
||||||
self.Total.append("[TRACK] {} - {} - {} [{}]".format(*items))
|
self.Total.append("[TRACK] {} - {} - {} [{}]".format(*items))
|
||||||
self.appendInfo(i, False)
|
self.appendInfo(i, False)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
items = (
|
items = (
|
||||||
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",
|
||||||
)
|
)
|
||||||
self.Total.append("[TRACK] {} [{}]".format(*items))
|
self.Total.append("[TRACK] {} [{}]".format(*items))
|
||||||
self.appendInfo(i, False)
|
self.appendInfo(i, False)
|
||||||
|
|
||||||
def getResults(self, tracks=False):
|
def getResults(self, tracks=False):
|
||||||
self.itResults(self.Albums)
|
self.itResults(self.Albums)
|
||||||
|
@ -3,4 +3,3 @@ requests==2.24.0
|
|||||||
mutagen==1.45.1
|
mutagen==1.45.1
|
||||||
tqdm==4.48.2
|
tqdm==4.48.2
|
||||||
pick==0.6.7
|
pick==0.6.7
|
||||||
python-dotenv==0.15.0
|
|
||||||
|
Loading…
Reference in New Issue
Block a user