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 -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
|
||||
|
@ -31,11 +31,18 @@ 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")
|
||||
|
||||
|
||||
def getCover(i, dirn):
|
||||
req_tqdm(i, dirn + "/cover.jpg", "Downloading cover art")
|
||||
|
||||
@ -60,11 +67,16 @@ 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-{}
|
||||
@ -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:
|
||||
@ -16,7 +17,7 @@ def tag_flac(file, path, d, album, istrack=True):
|
||||
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
|
||||
@ -48,7 +49,9 @@ 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"] + ' ' + '(' + 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"] + ')')
|
||||
title = sanitize_filename(d["title"] + " " + "(" + d["version"] + ")")
|
||||
else:
|
||||
title = sanitize_filename(d["title"])
|
||||
try:
|
||||
@ -87,7 +92,7 @@ def tag_mp3(file, path, d, album, istrack=True): #needs to be fixed
|
||||
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:
|
||||
|
@ -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)
|
||||
|
@ -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