diff --git a/mopidy/frontends/lastfm/__init__.py b/mopidy/frontends/lastfm/__init__.py new file mode 100644 index 00000000..aac27848 --- /dev/null +++ b/mopidy/frontends/lastfm/__init__.py @@ -0,0 +1,55 @@ +from __future__ import unicode_literals + +import mopidy +from mopidy import ext +from mopidy.exceptions import ExtensionError + + +__doc__ = """ +Frontend which scrobbles the music you play to your `Last.fm +`_ profile. + +.. note:: + + This frontend requires a free user account at Last.fm. + +**Dependencies:** + +.. literalinclude:: ../../../requirements/lastfm.txt + +**Settings:** + +- :attr:`mopidy.settings.LASTFM_USERNAME` +- :attr:`mopidy.settings.LASTFM_PASSWORD` + +**Usage:** + +Make sure :attr:`mopidy.settings.FRONTENDS` includes +``mopidy.frontends.lastfm.LastfmFrontend``. By default, the setting includes +the Last.fm frontend. +""" + + +# TODO Move import into method when FRONTENDS setting is removed +from .actor import LastfmFrontend + + +class Extension(ext.Extension): + + name = 'Mopidy-Lastfm' + version = mopidy.__version__ + + def get_default_config(self): + return '[lastfm]' + + def validate_config(self, config): + pass + + def validate_environment(self): + try: + import pylast # noqa + except ImportError as e: + raise ExtensionError('pylast library not found', e) + + def get_frontend_classes(self): + return [LastfmFrontend] diff --git a/mopidy/frontends/lastfm.py b/mopidy/frontends/lastfm/actor.py similarity index 87% rename from mopidy/frontends/lastfm.py rename to mopidy/frontends/lastfm/actor.py index 61dc306c..60a909e0 100644 --- a/mopidy/frontends/lastfm.py +++ b/mopidy/frontends/lastfm/actor.py @@ -1,27 +1,3 @@ -""" -Frontend which scrobbles the music you play to your `Last.fm -`_ profile. - -.. note:: - - This frontend requires a free user account at Last.fm. - -**Dependencies:** - -.. literalinclude:: ../../../requirements/lastfm.txt - -**Settings:** - -- :attr:`mopidy.settings.LASTFM_USERNAME` -- :attr:`mopidy.settings.LASTFM_PASSWORD` - -**Usage:** - -Make sure :attr:`mopidy.settings.FRONTENDS` includes -``mopidy.frontends.lastfm.LastfmFrontend``. By default, the setting includes -the Last.fm frontend. -""" - from __future__ import unicode_literals import logging diff --git a/setup.py b/setup.py index db2b1932..cff6ce23 100644 --- a/setup.py +++ b/setup.py @@ -46,6 +46,7 @@ setup( ], b'mopidy.extension': [ 'http = mopidy.frontends.http:Extension', + 'lastfm = mopidy.frontends.lastfm:Extension', 'local = mopidy.backends.local:Extension', 'mpd = mopidy.frontends.mpd:Extension', 'mpris = mopidy.frontends.mpris:Extension',