Set active backend in settings

This commit is contained in:
Stein Magnus Jodal 2010-01-27 16:17:00 +01:00
parent 77af150756
commit f1aee4033c
2 changed files with 12 additions and 1 deletions

View File

@ -13,7 +13,7 @@ from mopidy.backends.libspotify import LibspotifyBackend
def main():
_setup_logging(2)
backend = LibspotifyBackend()
backend = _get_backend(config.BACKEND)
MpdServer(backend=backend)
asyncore.loop()
@ -29,6 +29,14 @@ def _setup_logging(verbosity_level):
level=level,
)
def _get_backend(name):
module_name = name[:name.rindex('.')]
class_name = name[name.rindex('.') + 1:]
module = __import__(module_name, globals(), locals(), [class_name], -1)
class_object = getattr(module, class_name)
instance = class_object()
return instance
if __name__ == '__main__':
try:
main()

View File

@ -4,6 +4,9 @@ MPD_LINE_TERMINATOR = u'\n'
MPD_SERVER_HOSTNAME = u'localhost'
MPD_SERVER_PORT = 6600
BACKEND=u'mopidy.backends.despotify.DespotifyBackend'
#BACKEND=u'mopidy.backends.libspotify.LibspotifyBackend'
SPOTIFY_USERNAME = u''
SPOTIFY_PASSWORD = u''