mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-11-22 11:05:25 +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 windows-curses
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
```
|
```
|
||||||
#### Add your credentials to `config.json`
|
#### Add your credentials to `config.py`
|
||||||
```json
|
```python
|
||||||
{
|
email = "your@email.com"
|
||||||
"email": "",
|
password = "your_password"
|
||||||
"password": ""
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
#### Run Qobuz-DL
|
#### Run Qobuz-DL
|
||||||
##### Linux / MAC OS
|
##### Linux / MAC OS
|
||||||
@ -53,7 +51,7 @@ optional arguments:
|
|||||||
-i run Qo-Dl-curses on URL input mode
|
-i run Qo-Dl-curses on URL input mode
|
||||||
-q int quality (5, 6, 7, 27) (default: 6) [320, LOSSLESS, 24B <96KHZ, 24B >96KHZ]
|
-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)
|
-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
|
## 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.
|
`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 argparse
|
||||||
import itertools
|
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pick import pick
|
from pick import pick
|
||||||
|
|
||||||
from qo_utils import qopy
|
import config
|
||||||
from qo_utils import downloader
|
from qo_utils import downloader, qopy
|
||||||
from qo_utils.search import Search
|
from qo_utils.search import Search
|
||||||
|
|
||||||
|
|
||||||
@ -16,33 +14,33 @@ def getArgs():
|
|||||||
parser = argparse.ArgumentParser(prog="python3 main.py")
|
parser = argparse.ArgumentParser(prog="python3 main.py")
|
||||||
parser.add_argument("-a", action="store_true", help="enable albums-only search")
|
parser.add_argument("-a", action="store_true", help="enable albums-only search")
|
||||||
parser.add_argument(
|
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(
|
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(
|
parser.add_argument(
|
||||||
"-l",
|
"-l",
|
||||||
metavar="int",
|
metavar="int",
|
||||||
default=10,
|
default=config.default_limit,
|
||||||
help="limit of search results by type (default: 10)",
|
help="limit of search results by type (default: 10)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-d",
|
"-d",
|
||||||
metavar="PATH",
|
metavar="PATH",
|
||||||
default="Qobuz Downloads",
|
default=config.default_folder,
|
||||||
help="custom directory for downloads",
|
help="custom directory for downloads (default: '{}')".format(
|
||||||
|
config.default_folder
|
||||||
|
),
|
||||||
)
|
)
|
||||||
return parser.parse_args()
|
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):
|
def musicDir(dir):
|
||||||
fix = os.path.normpath(dir)
|
fix = os.path.normpath(dir)
|
||||||
if not os.path.isdir(fix):
|
if not os.path.isdir(fix):
|
||||||
@ -64,19 +62,16 @@ def searchSelected(Qz, path, albums, ids, types, quality):
|
|||||||
quality = q[quality[1]]
|
quality = q[quality[1]]
|
||||||
for alb, id_, type_ in zip(albums, ids, types):
|
for alb, id_, type_ in zip(albums, ids, types):
|
||||||
for al in alb:
|
for al in alb:
|
||||||
if type_[al[1]]:
|
downloader.iterateIDs(
|
||||||
downloader.iterateIDs(Qz, id_[al[1]], path, quality, True)
|
Qz, id_[al[1]], path, quality, True if type_[al[1]] else False
|
||||||
else:
|
)
|
||||||
downloader.iterateIDs(Qz, id_[al[1]], path, quality, False)
|
|
||||||
|
|
||||||
|
|
||||||
def fromUrl(Qz, path, link, quality):
|
def fromUrl(Qz, path, link, quality):
|
||||||
if "/track/" in link:
|
id = get_id(link)
|
||||||
id = get_id(link)
|
downloader.iterateIDs(
|
||||||
downloader.iterateIDs(Qz, id, path, quality, False)
|
Qz, id, path, str(quality), False if "/track/" in link else True
|
||||||
else:
|
)
|
||||||
id = get_id(link)
|
|
||||||
downloader.iterateIDs(Qz, id, path, quality, True)
|
|
||||||
|
|
||||||
|
|
||||||
def interactive(Qz, path, limit, tracks=True):
|
def interactive(Qz, path, limit, tracks=True):
|
||||||
@ -118,23 +113,14 @@ def interactive(Qz, path, limit, tracks=True):
|
|||||||
sys.exit("\nBye")
|
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():
|
def main():
|
||||||
arguments = getArgs()
|
arguments = getArgs()
|
||||||
directory = musicDir(arguments.d) + "/"
|
directory = musicDir(arguments.d) + "/"
|
||||||
Qz = getSession()
|
Qz = qopy.Client(config.email, config.password)
|
||||||
if not arguments.i:
|
if not arguments.i:
|
||||||
interactive(Qz, directory, arguments.l, not arguments.a)
|
interactive(Qz, directory, arguments.l, not arguments.a)
|
||||||
else:
|
else:
|
||||||
inputMode(Qz, directory, arguments.q)
|
fromUrl(Qz, directory, arguments.i, arguments.q)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -8,12 +8,8 @@ import time
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from qo_utils import spoofbuz
|
from qo_utils import spoofbuz
|
||||||
from qo_utils.exceptions import (
|
from qo_utils.exceptions import (AuthenticationError, IneligibleError,
|
||||||
AuthenticationError,
|
InvalidAppIdError, InvalidAppSecretError)
|
||||||
IneligibleError,
|
|
||||||
InvalidAppIdError,
|
|
||||||
InvalidAppSecretError,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
|
Loading…
Reference in New Issue
Block a user