Exit if SPOTIFY_{USERNAME,PASSWORD} is not set
This commit is contained in:
parent
256e5e685a
commit
671ccd8e82
@ -1,3 +1,5 @@
|
||||
import sys
|
||||
|
||||
import spytify
|
||||
|
||||
from mopidy import settings
|
||||
@ -6,11 +8,23 @@ from mopidy.backends.base import BaseBackend
|
||||
class SpotifyBackend(BaseBackend):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SpotifyBackend, self).__init__(*args, **kwargs)
|
||||
self.spotify = spytify.Spytify(
|
||||
settings.SPOTIFY_USERNAME.encode('utf-8'),
|
||||
settings.SPOTIFY_PASSWORD.encode('utf-8'))
|
||||
self.spotify = spytify.Spytify(self.username, self.password)
|
||||
self._playlist_load_cache = None
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
username = settings.SPOTIFY_USERNAME.encode('utf-8')
|
||||
if not username:
|
||||
sys.exit('Setting SPOTIFY_USERNAME is not set.')
|
||||
return username
|
||||
|
||||
@property
|
||||
def password(self):
|
||||
password = settings.SPOTIFY_PASSWORD.encode('utf-8')
|
||||
if not password:
|
||||
sys.exit('Setting SPOTIFY_PASSWORD is not set.')
|
||||
return password
|
||||
|
||||
def playlist_load(self, name):
|
||||
if not self._playlist_load_cache:
|
||||
for playlist in self.spotify.stored_playlists:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user