mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-11-22 19:15: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
|
||||||
|
@ -31,11 +31,18 @@ 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,11 +67,16 @@ 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-{}
|
||||||
@ -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:
|
||||||
@ -16,7 +17,7 @@ def tag_flac(file, path, d, album, istrack=True):
|
|||||||
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
|
||||||
@ -48,7 +49,9 @@ 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"] + ' ' + '(' + 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:
|
||||||
@ -87,7 +92,7 @@ def tag_mp3(file, path, d, album, istrack=True): #needs to be fixed
|
|||||||
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:
|
||||||
|
@ -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)
|
||||||
|
@ -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