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
|
import spytify
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
@ -6,11 +8,23 @@ from mopidy.backends.base import BaseBackend
|
|||||||
class SpotifyBackend(BaseBackend):
|
class SpotifyBackend(BaseBackend):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(SpotifyBackend, self).__init__(*args, **kwargs)
|
super(SpotifyBackend, self).__init__(*args, **kwargs)
|
||||||
self.spotify = spytify.Spytify(
|
self.spotify = spytify.Spytify(self.username, self.password)
|
||||||
settings.SPOTIFY_USERNAME.encode('utf-8'),
|
|
||||||
settings.SPOTIFY_PASSWORD.encode('utf-8'))
|
|
||||||
self._playlist_load_cache = None
|
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):
|
def playlist_load(self, name):
|
||||||
if not self._playlist_load_cache:
|
if not self._playlist_load_cache:
|
||||||
for playlist in self.spotify.stored_playlists:
|
for playlist in self.spotify.stored_playlists:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user