mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-12-22 23:34:40 +01:00
Change config method
This commit is contained in:
parent
5295777f49
commit
700adc6e1f
12
README.md
12
README.md
@ -27,12 +27,10 @@ pip3 install -r requirements.txt --user
|
||||
pip3 install windows-curses
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
#### Add your credentials to `config.json`
|
||||
```json
|
||||
{
|
||||
"email": "",
|
||||
"password": ""
|
||||
}
|
||||
#### Add your credentials to `config.py`
|
||||
```python
|
||||
email = "your@email.com"
|
||||
password = "your_password"
|
||||
```
|
||||
#### Run Qobuz-DL
|
||||
##### Linux / MAC OS
|
||||
@ -53,7 +51,7 @@ optional arguments:
|
||||
-i run Qo-Dl-curses on URL input mode
|
||||
-q int quality (5, 6, 7, 27) (default: 6) [320, LOSSLESS, 24B <96KHZ, 24B >96KHZ]
|
||||
-l int limit of search results by type (default: 10)
|
||||
-d PATH custom directory for downloads
|
||||
-d PATH custom directory for downloads (default: 'Qobuz Downloads')
|
||||
```
|
||||
## A note about Qo-DL
|
||||
`Qobuz-DL` is inspired in the discontinued Qo-DL-Reborn. This program uses two modules from Qo-DL: `qopy` and `spoofer`, both written by Sorrow446 and DashLt.
|
||||
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"email": "",
|
||||
"password": ""
|
||||
}
|
13
config.py
Normal file
13
config.py
Normal file
@ -0,0 +1,13 @@
|
||||
# Qobuz credentials (Don't remove the quotes!)
|
||||
email = "your@email.com"
|
||||
password = "your_password"
|
||||
|
||||
# Default folder where the releases are downloaded
|
||||
default_folder = "Qobuz Downloads"
|
||||
|
||||
# Default per type results limit
|
||||
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 = 6
|
60
main.py
60
main.py
@ -1,14 +1,12 @@
|
||||
import argparse
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from pick import pick
|
||||
|
||||
from qo_utils import qopy
|
||||
from qo_utils import downloader
|
||||
import config
|
||||
from qo_utils import downloader, qopy
|
||||
from qo_utils.search import Search
|
||||
|
||||
|
||||
@ -16,33 +14,33 @@ def getArgs():
|
||||
parser = argparse.ArgumentParser(prog="python3 main.py")
|
||||
parser.add_argument("-a", action="store_true", help="enable albums-only search")
|
||||
parser.add_argument(
|
||||
"-i", action="store_true", help="run Qo-Dl-curses on URL input mode"
|
||||
"-i",
|
||||
metavar="Album/track URL",
|
||||
help="run Qobuz-Dl on URL input mode (download by url)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-q", metavar="int", default=6, help="quality (5, 6, 7, 27) (default: 6)"
|
||||
"-q",
|
||||
metavar="int",
|
||||
default=config.default_quality,
|
||||
help="quality for url input mode (5, 6, 7, 27) (default: 6)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
metavar="int",
|
||||
default=10,
|
||||
default=config.default_limit,
|
||||
help="limit of search results by type (default: 10)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
metavar="PATH",
|
||||
default="Qobuz Downloads",
|
||||
help="custom directory for downloads",
|
||||
default=config.default_folder,
|
||||
help="custom directory for downloads (default: '{}')".format(
|
||||
config.default_folder
|
||||
),
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def getSession():
|
||||
print("Logging...")
|
||||
with open("config.json") as f:
|
||||
config = json.load(f)
|
||||
return qopy.Client(config["email"], config["password"])
|
||||
|
||||
|
||||
def musicDir(dir):
|
||||
fix = os.path.normpath(dir)
|
||||
if not os.path.isdir(fix):
|
||||
@ -64,19 +62,16 @@ def searchSelected(Qz, path, albums, ids, types, quality):
|
||||
quality = q[quality[1]]
|
||||
for alb, id_, type_ in zip(albums, ids, types):
|
||||
for al in alb:
|
||||
if type_[al[1]]:
|
||||
downloader.iterateIDs(Qz, id_[al[1]], path, quality, True)
|
||||
else:
|
||||
downloader.iterateIDs(Qz, id_[al[1]], path, quality, False)
|
||||
downloader.iterateIDs(
|
||||
Qz, id_[al[1]], path, quality, True if type_[al[1]] else False
|
||||
)
|
||||
|
||||
|
||||
def fromUrl(Qz, path, link, quality):
|
||||
if "/track/" in link:
|
||||
id = get_id(link)
|
||||
downloader.iterateIDs(Qz, id, path, quality, False)
|
||||
else:
|
||||
id = get_id(link)
|
||||
downloader.iterateIDs(Qz, id, path, quality, True)
|
||||
id = get_id(link)
|
||||
downloader.iterateIDs(
|
||||
Qz, id, path, str(quality), False if "/track/" in link else True
|
||||
)
|
||||
|
||||
|
||||
def interactive(Qz, path, limit, tracks=True):
|
||||
@ -118,23 +113,14 @@ def interactive(Qz, path, limit, tracks=True):
|
||||
sys.exit("\nBye")
|
||||
|
||||
|
||||
def inputMode(Qz, path, quality):
|
||||
while True:
|
||||
try:
|
||||
link = input("\nAlbum/track URL: [Ctrl + c to quit]\n- ")
|
||||
fromUrl(Qz, path, link, quality)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit("\nBye")
|
||||
|
||||
|
||||
def main():
|
||||
arguments = getArgs()
|
||||
directory = musicDir(arguments.d) + "/"
|
||||
Qz = getSession()
|
||||
Qz = qopy.Client(config.email, config.password)
|
||||
if not arguments.i:
|
||||
interactive(Qz, directory, arguments.l, not arguments.a)
|
||||
else:
|
||||
inputMode(Qz, directory, arguments.q)
|
||||
fromUrl(Qz, directory, arguments.i, arguments.q)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -8,12 +8,8 @@ import time
|
||||
import requests
|
||||
|
||||
from qo_utils import spoofbuz
|
||||
from qo_utils.exceptions import (
|
||||
AuthenticationError,
|
||||
IneligibleError,
|
||||
InvalidAppIdError,
|
||||
InvalidAppSecretError,
|
||||
)
|
||||
from qo_utils.exceptions import (AuthenticationError, IneligibleError,
|
||||
InvalidAppIdError, InvalidAppSecretError)
|
||||
|
||||
|
||||
class Client:
|
||||
|
Loading…
Reference in New Issue
Block a user