mirror of
https://github.com/Footsiefat/zspotify
synced 2021-12-21 22:06:14 +01:00
Added CREDENTIALS_LOCATION config value
This commit is contained in:
parent
0adaa20d59
commit
ad43153d4c
@ -19,6 +19,7 @@ DOWNLOAD_REAL_TIME = 'DOWNLOAD_REAL_TIME'
|
||||
LANGUAGE = 'LANGUAGE'
|
||||
BITRATE = 'BITRATE'
|
||||
SONG_ARCHIVE = 'SONG_ARCHIVE'
|
||||
CREDENTIALS_LOCATION = 'CREDENTIALS_LOCATION'
|
||||
|
||||
CONFIG_VALUES = {
|
||||
ROOT_PATH: { 'default': '../ZSpotify Music/', 'type': str, 'arg': '--root-path' },
|
||||
@ -35,6 +36,7 @@ CONFIG_VALUES = {
|
||||
LANGUAGE: { 'default': 'en', 'type': str, 'arg': '--language' },
|
||||
BITRATE: { 'default': '', 'type': str, 'arg': '--bitrate' },
|
||||
SONG_ARCHIVE: { 'default': '.song_archive', 'type': str, 'arg': '--song-archive' },
|
||||
CREDENTIALS_LOCATION: { 'default': 'credentials.json', 'type': str, 'arg': '--credentials-location' },
|
||||
}
|
||||
|
||||
|
||||
@ -77,8 +79,6 @@ class Config:
|
||||
if key.lower() in vars(args) and vars(args)[key.lower()] is not None:
|
||||
cls.Values[key] = cls.parse_arg_value(key, vars(args)[key.lower()])
|
||||
|
||||
print(cls.Values, ' ', '\n')
|
||||
|
||||
@classmethod
|
||||
def get_default_json(cls) -> Any:
|
||||
r = {}
|
||||
@ -161,3 +161,7 @@ class Config:
|
||||
@classmethod
|
||||
def get_song_archive(cls) -> str:
|
||||
return cls.get(SONG_ARCHIVE)
|
||||
|
||||
@classmethod
|
||||
def get_credentials_location(cls) -> str:
|
||||
return cls.get(CREDENTIALS_LOCATION)
|
||||
|
@ -80,8 +80,6 @@ USER_LIBRARY_READ = 'user-library-read'
|
||||
|
||||
WINDOWS_SYSTEM = 'Windows'
|
||||
|
||||
CREDENTIALS_JSON = 'credentials.json'
|
||||
|
||||
CODEC_MAP = {
|
||||
'aac': 'aac',
|
||||
'fdk_aac': 'libfdk_aac',
|
||||
|
@ -16,10 +16,9 @@ import requests
|
||||
from librespot.audio.decoders import VorbisOnlyAudioQuality
|
||||
from librespot.core import Session
|
||||
|
||||
from const import CREDENTIALS_JSON, TYPE, \
|
||||
from const import TYPE, \
|
||||
PREMIUM, USER_READ_EMAIL, AUTHORIZATION, OFFSET, LIMIT, \
|
||||
PLAYLIST_READ_PRIVATE, USER_LIBRARY_READ
|
||||
from utils import MusicFormat
|
||||
from config import Config
|
||||
|
||||
|
||||
@ -36,9 +35,11 @@ class ZSpotify:
|
||||
def login(cls):
|
||||
""" Authenticates with Spotify and saves credentials to a file """
|
||||
|
||||
if os.path.isfile(CREDENTIALS_JSON):
|
||||
cred_location = os.path.join(os.getcwd(), Config.get_credentials_location())
|
||||
|
||||
if os.path.isfile(cred_location):
|
||||
try:
|
||||
cls.SESSION = Session.Builder().stored_file().create()
|
||||
cls.SESSION = Session.Builder().stored_file(cred_location).create()
|
||||
return
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user