mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-29 14:35:29 -04:00
Add support for qobuz auth tokens
This commit is contained in:
parent
12db8e001a
commit
41c0c3e3a0
6 changed files with 75 additions and 39 deletions
17
rip/cli.py
17
rip/cli.py
|
@ -479,11 +479,18 @@ class ConfigCommand(Command):
|
|||
import getpass
|
||||
import hashlib
|
||||
|
||||
self._config.file["qobuz"]["email"] = self.ask("Qobuz email:")
|
||||
self._config.file["qobuz"]["password"] = hashlib.md5(
|
||||
getpass.getpass("Qobuz password (won't show on screen): ").encode()
|
||||
).hexdigest()
|
||||
self._config.save()
|
||||
self._config.file["qobuz"]["use_auth_token"] = self.confirm("Use Qobuz auth token to authenticate?", default=False)
|
||||
|
||||
if self._config.file["qobuz"]["use_auth_token"]:
|
||||
self._config.file["qobuz"]["email_or_userid"] = self.ask("Qobuz user id:")
|
||||
self._config.file["qobuz"]["password_or_token"] = getpass.getpass("Qobuz auth token (won't show on screen): ")
|
||||
self._config.save()
|
||||
else:
|
||||
self._config.file["qobuz"]["email_or_userid"] = self.ask("Qobuz email:")
|
||||
self._config.file["qobuz"]["password_or_token"] = hashlib.md5(
|
||||
getpass.getpass("Qobuz password (won't show on screen): ").encode()
|
||||
).hexdigest()
|
||||
self._config.save()
|
||||
|
||||
if self.option("music-app"):
|
||||
self._conf_music_app()
|
||||
|
|
|
@ -172,8 +172,9 @@ class Config:
|
|||
def qobuz_creds(self):
|
||||
"""Return a QobuzClient compatible dict of credentials."""
|
||||
return {
|
||||
"email": self.file["qobuz"]["email"],
|
||||
"pwd": self.file["qobuz"]["password"],
|
||||
"use_auth_token": self.file["qobuz"]["use_auth_token"],
|
||||
"email_or_userid": self.file["qobuz"]["email_or_userid"],
|
||||
"password_or_token": self.file["qobuz"]["password_or_token"],
|
||||
"app_id": self.file["qobuz"]["app_id"],
|
||||
"secrets": self.file["qobuz"]["secrets"],
|
||||
}
|
||||
|
|
|
@ -20,9 +20,12 @@ quality = 3
|
|||
# This will download booklet pdfs that are included with some albums
|
||||
download_booklets = true
|
||||
|
||||
email = ""
|
||||
# This is an md5 hash of the plaintext password
|
||||
password = ""
|
||||
# Authenticate to Qobuz using auth token? Value can be true/false only
|
||||
use_auth_token = false
|
||||
# Enter your userid if the above use_auth_token is set to true, else enter your email
|
||||
email_or_userid = ""
|
||||
# Enter your auth token if the above use_auth_token is set to true, else enter the md5 hash of your plaintext password
|
||||
password_or_token = ""
|
||||
# Do not change
|
||||
app_id = ""
|
||||
# Do not change
|
||||
|
@ -157,7 +160,6 @@ restrict_characters = false
|
|||
# Setting this to false may cause downloads to fail on some systems
|
||||
truncate = true
|
||||
|
||||
|
||||
# Last.fm playlists are downloaded by searching for the titles of the tracks
|
||||
[lastfm]
|
||||
# The source on which to search for the tracks.
|
||||
|
|
44
rip/core.py
44
rip/core.py
|
@ -878,21 +878,37 @@ class RipCore(list):
|
|||
:type source: str
|
||||
"""
|
||||
if source == "qobuz":
|
||||
secho("Enter Qobuz email:", fg="green")
|
||||
self.config.file[source]["email"] = input()
|
||||
secho(
|
||||
"Enter Qobuz password (will not show on screen):",
|
||||
fg="green",
|
||||
)
|
||||
self.config.file[source]["password"] = md5(
|
||||
getpass(prompt="").encode("utf-8")
|
||||
).hexdigest()
|
||||
secho("Use Qobuz auth token to authenticate? (yes/no)", fg="green")
|
||||
use_auth_token = re.match("(?i)^y", input()) is not None
|
||||
|
||||
self.config.file[source]["use_auth_token"] = use_auth_token
|
||||
|
||||
if use_auth_token:
|
||||
secho("Enter Qobuz user id:", fg="green")
|
||||
self.config.file[source]["email_or_userid"] = input()
|
||||
|
||||
self.config.save()
|
||||
secho(
|
||||
f'Credentials saved to config file at "{self.config._path}"',
|
||||
fg="green",
|
||||
)
|
||||
secho("Enter Qobuz token (will not show on screen):", fg="green")
|
||||
self.config.file[source]["password_or_token"] = getpass(prompt="")
|
||||
|
||||
self.config.save()
|
||||
secho(
|
||||
f'Credentials saved to config file at "{self.config._path}"',
|
||||
fg="green",
|
||||
)
|
||||
else:
|
||||
secho("Enter Qobuz email:", fg="green")
|
||||
self.config.file[source]["email_or_userid"] = input()
|
||||
|
||||
secho("Enter Qobuz password (will not show on screen):", fg="green")
|
||||
self.config.file[source]["password_or_token"] = md5(
|
||||
getpass(prompt="").encode("utf-8")
|
||||
).hexdigest()
|
||||
|
||||
self.config.save()
|
||||
secho(
|
||||
f'Credentials saved to config file at "{self.config._path}"',
|
||||
fg="green",
|
||||
)
|
||||
elif source == "deezer":
|
||||
secho(
|
||||
"If you're not sure how to find the ARL cookie, see the instructions at ",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue