mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-12-22 23:34:40 +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 -r requirements.txt
|
||||
```
|
||||
#### Add your credentials to a `.env` file
|
||||
```none
|
||||
QOBUZ_EMAIL=your@email.com
|
||||
QOBUZ_PW=your_password
|
||||
#### Add your credentials to `config.py` file
|
||||
```python
|
||||
email = "your@email.com"
|
||||
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 `.env` file to
|
||||
change other default values by means of the following environment variables:
|
||||
|
||||
- `QOBUZ_FOLDER` (location of the download folder)
|
||||
- `QOBUZ_LIMIT` (results limit)
|
||||
- `QOBUZ_QUALITY` (default quality for url input mode)
|
||||
In addition to your credentials, you can also use the `config.py` file to
|
||||
change other default values:
|
||||
```python
|
||||
default_folder = "Qobuz Downloads"
|
||||
default_limit = 10
|
||||
default_quality = 6
|
||||
```
|
||||
|
||||
#### Run qobuz-dl
|
||||
##### Linux / MAC OS
|
||||
|
13
config.py
13
config.py
@ -1,16 +1,15 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
# Qobuz credentials (Don't remove the quotes!)
|
||||
email = os.getenv('QOBUZ_EMAIL')
|
||||
password = os.getenv('QOBUZ_PW')
|
||||
email = "your@email.com"
|
||||
password = "your_password"
|
||||
|
||||
# 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_limit = os.getenv('QOBUZ_LIMIT', 10)
|
||||
default_limit = 10
|
||||
|
||||
# Default quality for url input mode. This will be ignored in interactive mode
|
||||
# (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:
|
||||
query = input("\nEnter your search: [Ctrl + c to quit]\n- ")
|
||||
print("Searching...")
|
||||
if len(query.strip())==0:
|
||||
if len(query.strip()) == 0:
|
||||
break
|
||||
start = Search(Qz, query, limit)
|
||||
start.getResults(tracks)
|
||||
if len(start.Total)==0:
|
||||
break
|
||||
if len(start.Total) == 0:
|
||||
break
|
||||
Types.append(start.Types)
|
||||
IDs.append(start.IDs)
|
||||
|
||||
@ -138,7 +138,7 @@ def interactive(Qz, path, limit, tracks=True):
|
||||
else:
|
||||
break
|
||||
|
||||
if len(Albums)>0:
|
||||
if len(Albums) > 0:
|
||||
desc = (
|
||||
"Select [intro] the quality (the quality will be automat"
|
||||
"ically\ndowngraded if the selected is not found)"
|
||||
|
@ -31,10 +31,17 @@ def mkDir(dirn):
|
||||
|
||||
|
||||
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):
|
||||
req_tqdm(i, dirn + "/booklet.pdf", "Downloading booklet")
|
||||
req_tqdm(i, dirn + "/booklet.pdf", "Downloading booklet")
|
||||
|
||||
|
||||
def getCover(i, dirn):
|
||||
req_tqdm(i, dirn + "/cover.jpg", "Downloading cover art")
|
||||
@ -60,14 +67,19 @@ def iterateIDs(client, id, path, quality, album=False):
|
||||
if album:
|
||||
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 = (
|
||||
meta["artist"]["name"],
|
||||
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],
|
||||
)
|
||||
sanitized_title = sanitize_filename("{} - {}{} [{}]".format(*dirT)) #aa-{}
|
||||
sanitized_title = sanitize_filename("{} - {}{} [{}]".format(*dirT)) # aa-{}
|
||||
dirn = path + sanitized_title
|
||||
mkDir(dirn)
|
||||
getCover(meta["image"]["large"], dirn)
|
||||
@ -92,11 +104,18 @@ def iterateIDs(client, id, path, quality, album=False):
|
||||
|
||||
if "sample" not in parse:
|
||||
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 = (
|
||||
meta["album"]["artist"]["name"],
|
||||
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],
|
||||
)
|
||||
sanitized_title = sanitize_filename("{} - {}{} [{}]".format(*dirT))
|
||||
|
@ -4,6 +4,7 @@ from mutagen.flac import FLAC
|
||||
from mutagen.mp3 import EasyMP3
|
||||
from pathvalidate import sanitize_filename
|
||||
|
||||
|
||||
def tag_flac(file, path, d, album, istrack=True):
|
||||
audio = FLAC(file)
|
||||
try:
|
||||
@ -13,15 +14,15 @@ def tag_flac(file, path, d, album, istrack=True):
|
||||
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"] + ')'
|
||||
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"] + ')'
|
||||
# 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
|
||||
try:
|
||||
@ -42,13 +43,15 @@ def tag_flac(file, path, d, album, istrack=True):
|
||||
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"] # ALBUM TITLE
|
||||
audio["ALBUM"] = d["album"]["title"] # ALBUM TITLE
|
||||
audio["YEAR"] = d["album"]["release_date_original"].split("-")[0]
|
||||
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["ALBUM"] = (
|
||||
d["album"]["title"] + " " + "(" + d["album"]["version"] + ")"
|
||||
) # ALBUM TITLE
|
||||
audio["YEAR"] = d["album"]["release_date_original"].split("-")[0]
|
||||
else:
|
||||
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["ALBUMARTIST"] = album["artist"]["name"] # ALBUM ARTIST
|
||||
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.save()
|
||||
if dversion_exist == 1:
|
||||
title = sanitize_filename(d["title"] + ' ' + '(' + d["version"] + ')')
|
||||
if dversion_exist == 1:
|
||||
title = sanitize_filename(d["title"] + " " + "(" + d["version"] + ")")
|
||||
else:
|
||||
title = sanitize_filename(d["title"])
|
||||
try:
|
||||
@ -75,19 +80,19 @@ def tag_flac(file, path, d, album, istrack=True):
|
||||
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)
|
||||
try:
|
||||
d["version"]
|
||||
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"] + ')'
|
||||
audio["TITLE"] = d["title"] + " " + "(" + d["version"] + ")"
|
||||
dversion_exist = 1
|
||||
|
||||
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:
|
||||
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["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
|
||||
@ -122,7 +129,9 @@ def tag_mp3(file, path, d, album, istrack=True): #needs to be fixed
|
||||
except KeyError:
|
||||
audio["album"] = album["title"]
|
||||
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
|
||||
else:
|
||||
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()
|
||||
if dversion_exist == 1:
|
||||
title = sanitize_filename(d["title"] + ' ' + '(' + d["version"] + ')')
|
||||
title = sanitize_filename(d["title"] + " " + "(" + d["version"] + ")")
|
||||
else:
|
||||
title = sanitize_filename(d["title"])
|
||||
try:
|
||||
|
@ -91,7 +91,7 @@ class Client:
|
||||
"intent": "stream",
|
||||
}
|
||||
else:
|
||||
params=kwargs
|
||||
params = kwargs
|
||||
r = self.session.get(self.base + epoint, params=params)
|
||||
# Do ref header.
|
||||
if epoint == "user/login":
|
||||
@ -157,13 +157,19 @@ class Client:
|
||||
return self.api_call("track/search", query=query, limit=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):
|
||||
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):
|
||||
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):
|
||||
return self.api_call("playlist/getUserPlaylists", limit=limit)
|
||||
|
@ -28,23 +28,23 @@ class Search:
|
||||
self.Total.append("[RELEASE] {} - {} - {} [{}]".format(*items))
|
||||
self.appendInfo(i, True)
|
||||
except KeyError:
|
||||
try:
|
||||
items = (
|
||||
i["performer"]["name"],
|
||||
i["title"],
|
||||
self.seconds(i["duration"]),
|
||||
"HI-RES" if i["hires"] else "Lossless",
|
||||
)
|
||||
self.Total.append("[TRACK] {} - {} - {} [{}]".format(*items))
|
||||
self.appendInfo(i, False)
|
||||
except KeyError:
|
||||
items = (
|
||||
i["title"],
|
||||
self.seconds(i["duration"]),
|
||||
"HI-RES" if i["hires"] else "Lossless",
|
||||
)
|
||||
self.Total.append("[TRACK] {} [{}]".format(*items))
|
||||
self.appendInfo(i, False)
|
||||
try:
|
||||
items = (
|
||||
i["performer"]["name"],
|
||||
i["title"],
|
||||
self.seconds(i["duration"]),
|
||||
"HI-RES" if i["hires"] else "Lossless",
|
||||
)
|
||||
self.Total.append("[TRACK] {} - {} - {} [{}]".format(*items))
|
||||
self.appendInfo(i, False)
|
||||
except KeyError:
|
||||
items = (
|
||||
i["title"],
|
||||
self.seconds(i["duration"]),
|
||||
"HI-RES" if i["hires"] else "Lossless",
|
||||
)
|
||||
self.Total.append("[TRACK] {} [{}]".format(*items))
|
||||
self.appendInfo(i, False)
|
||||
|
||||
def getResults(self, tracks=False):
|
||||
self.itResults(self.Albums)
|
||||
|
@ -3,4 +3,3 @@ requests==2.24.0
|
||||
mutagen==1.45.1
|
||||
tqdm==4.48.2
|
||||
pick==0.6.7
|
||||
python-dotenv==0.15.0
|
||||
|
Loading…
Reference in New Issue
Block a user