Rename libspotify backend to simply 'spotify', as suggested by adamcik and knutz3n half a year ago

This commit is contained in:
Stein Magnus Jodal 2011-01-10 16:45:44 +01:00
parent 8503fe7b9e
commit 099544d915
13 changed files with 67 additions and 61 deletions

View File

@ -37,5 +37,5 @@ Backend provider implementations
================================
* :mod:`mopidy.backends.dummy`
* :mod:`mopidy.backends.libspotify`
* :mod:`mopidy.backends.spotify`
* :mod:`mopidy.backends.local`

View File

@ -21,6 +21,10 @@ No description yet.
- Support high bitrate (320k) audio. See
:attr:`mopidy.settings.SPOTIFY_HIGH_BITRATE` for details.
- Rename :mod:`mopidy.backends.libspotify` to :mod:`mopidy.backends.spotify`.
If you have set :attr:`mopidy.settings.BACKENDS` explicitly, you may need
to update the setting's value.
- Catch and log error caused by playlist folder boundaries being threated as
normal playlists. More permanent fix requires support for checking playlist
types in pyspotify.

View File

@ -31,7 +31,7 @@ Otherwise, make sure you got the required dependencies installed.
- Dependencies for at least one Mopidy backend:
- The default backend, :mod:`mopidy.backends.libspotify`, requires libspotify
- The default backend, :mod:`mopidy.backends.spotify`, requires libspotify
and pyspotify. See :doc:`libspotify`.
- The local backend, :mod:`mopidy.backends.local`, requires no additional

View File

@ -1,7 +0,0 @@
*******************************************************
:mod:`mopidy.backends.libspotify` -- Libspotify backend
*******************************************************
.. automodule:: mopidy.backends.libspotify
:synopsis: Spotify backend using the libspotify library
:members:

View File

@ -0,0 +1,7 @@
*************************************************
:mod:`mopidy.backends.spotify` -- Spotify backend
*************************************************
.. automodule:: mopidy.backends.spotify
:synopsis: Backend for the Spotify music streaming service
:members:

View File

@ -4,54 +4,55 @@ from mopidy import settings
from mopidy.backends.base import (Backend, CurrentPlaylistController,
LibraryController, PlaybackController, StoredPlaylistsController)
logger = logging.getLogger('mopidy.backends.libspotify')
logger = logging.getLogger('mopidy.backends.spotify')
ENCODING = 'utf-8'
class LibspotifyBackend(Backend):
class SpotifyBackend(Backend):
"""
A `Spotify <http://www.spotify.com/>`_ backend which uses the official
`libspotify <http://developer.spotify.com/en/libspotify/overview/>`_
library and the `pyspotify <http://github.com/winjer/pyspotify/>`_ Python
bindings for libspotify.
**Issues:**
http://github.com/mopidy/mopidy/issues/labels/backend-libspotify
**Settings:**
- :attr:`mopidy.settings.SPOTIFY_CACHE_PATH`
- :attr:`mopidy.settings.SPOTIFY_USERNAME`
- :attr:`mopidy.settings.SPOTIFY_PASSWORD`
A backend for playing music from the `Spotify <http://www.spotify.com/>`_
music streaming service. The backend uses the official `libspotify
<http://developer.spotify.com/en/libspotify/overview/>`_ library and the
`pyspotify <http://github.com/winjer/pyspotify/>`_ Python bindings for
libspotify.
.. note::
This product uses SPOTIFY(R) CORE but is not endorsed, certified or
otherwise approved in any way by Spotify. Spotify is the registered
trade mark of the Spotify Group.
**Issues:**
http://github.com/mopidy/mopidy/issues/labels/backend-spotify
**Settings:**
- :attr:`mopidy.settings.SPOTIFY_CACHE_PATH`
- :attr:`mopidy.settings.SPOTIFY_USERNAME`
- :attr:`mopidy.settings.SPOTIFY_PASSWORD`
"""
# Imports inside methods are to prevent loading of __init__.py to fail on
# missing spotify dependencies.
def __init__(self, *args, **kwargs):
from .library import LibspotifyLibraryProvider
from .playback import LibspotifyPlaybackProvider
from .stored_playlists import LibspotifyStoredPlaylistsProvider
from .library import SpotifyLibraryProvider
from .playback import SpotifyPlaybackProvider
from .stored_playlists import SpotifyStoredPlaylistsProvider
super(LibspotifyBackend, self).__init__(*args, **kwargs)
super(SpotifyBackend, self).__init__(*args, **kwargs)
self.current_playlist = CurrentPlaylistController(backend=self)
library_provider = LibspotifyLibraryProvider(backend=self)
library_provider = SpotifyLibraryProvider(backend=self)
self.library = LibraryController(backend=self,
provider=library_provider)
playback_provider = LibspotifyPlaybackProvider(backend=self)
playback_provider = SpotifyPlaybackProvider(backend=self)
self.playback = PlaybackController(backend=self,
provider=playback_provider)
stored_playlists_provider = LibspotifyStoredPlaylistsProvider(
stored_playlists_provider = SpotifyStoredPlaylistsProvider(
backend=self)
self.stored_playlists = StoredPlaylistsController(backend=self,
provider=stored_playlists_provider)
@ -61,11 +62,11 @@ class LibspotifyBackend(Backend):
self.spotify = self._connect()
def _connect(self):
from .session_manager import LibspotifySessionManager
from .session_manager import SpotifySessionManager
logger.info(u'Mopidy uses SPOTIFY(R) CORE')
logger.debug(u'Connecting to Spotify')
spotify = LibspotifySessionManager(
spotify = SpotifySessionManager(
settings.SPOTIFY_USERNAME, settings.SPOTIFY_PASSWORD,
core_queue=self.core_queue,
output=self.output)

View File

@ -4,13 +4,13 @@ import multiprocessing
from spotify import Link, SpotifyError
from mopidy.backends.base import BaseLibraryProvider
from mopidy.backends.libspotify import ENCODING
from mopidy.backends.libspotify.translator import LibspotifyTranslator
from mopidy.backends.spotify import ENCODING
from mopidy.backends.spotify.translator import SpotifyTranslator
from mopidy.models import Playlist
logger = logging.getLogger('mopidy.backends.libspotify.library')
logger = logging.getLogger('mopidy.backends.spotify.library')
class LibspotifyLibraryProvider(BaseLibraryProvider):
class SpotifyLibraryProvider(BaseLibraryProvider):
def find_exact(self, **query):
return self.search(**query)
@ -20,7 +20,7 @@ class LibspotifyLibraryProvider(BaseLibraryProvider):
# TODO Block until metadata_updated callback is called. Before that
# the track will be unloaded, unless it's already in the stored
# playlists.
return LibspotifyTranslator.to_mopidy_track(spotify_track)
return SpotifyTranslator.to_mopidy_track(spotify_track)
except SpotifyError as e:
logger.warning(u'Failed to lookup: %s', uri, e)
return None

View File

@ -4,9 +4,9 @@ from spotify import Link, SpotifyError
from mopidy.backends.base import BasePlaybackProvider
logger = logging.getLogger('mopidy.backends.libspotify.playback')
logger = logging.getLogger('mopidy.backends.spotify.playback')
class LibspotifyPlaybackProvider(BasePlaybackProvider):
class SpotifyPlaybackProvider(BasePlaybackProvider):
def pause(self):
return self.backend.output.set_state('PAUSED')

View File

@ -2,28 +2,29 @@ import logging
import os
import threading
from spotify.manager import SpotifySessionManager
import spotify.manager
from mopidy import get_version, settings
from mopidy.backends.libspotify.translator import LibspotifyTranslator
from mopidy.backends.spotify.translator import SpotifyTranslator
from mopidy.models import Playlist
from mopidy.utils.process import BaseThread
logger = logging.getLogger('mopidy.backends.libspotify.session_manager')
logger = logging.getLogger('mopidy.backends.spotify.session_manager')
# pylint: disable = R0901
# LibspotifySessionManager: Too many ancestors (9/7)
# SpotifySessionManager: Too many ancestors (9/7)
class LibspotifySessionManager(SpotifySessionManager, BaseThread):
class SpotifySessionManager(spotify.manager.SpotifySessionManager, BaseThread):
cache_location = settings.SPOTIFY_CACHE_PATH
settings_location = settings.SPOTIFY_CACHE_PATH
appkey_file = os.path.join(os.path.dirname(__file__), 'spotify_appkey.key')
user_agent = 'Mopidy %s' % get_version()
def __init__(self, username, password, core_queue, output):
SpotifySessionManager.__init__(self, username, password)
spotify.manager.SpotifySessionManager.__init__(
self, username, password)
BaseThread.__init__(self, core_queue)
self.name = 'LibspotifySMThread'
self.name = 'SpotifySMThread'
self.output = output
self.connected = threading.Event()
self.session = None
@ -53,7 +54,7 @@ class LibspotifySessionManager(SpotifySessionManager, BaseThread):
playlists = []
for spotify_playlist in session.playlist_container():
playlists.append(
LibspotifyTranslator.to_mopidy_playlist(spotify_playlist))
SpotifyTranslator.to_mopidy_playlist(spotify_playlist))
playlists = filter(None, playlists)
self.core_queue.put({
'command': 'set_stored_playlists',
@ -111,7 +112,7 @@ class LibspotifySessionManager(SpotifySessionManager, BaseThread):
def callback(results, userdata=None):
# TODO Include results from results.albums(), etc. too
playlist = Playlist(tracks=[
LibspotifyTranslator.to_mopidy_track(t)
SpotifyTranslator.to_mopidy_track(t)
for t in results.tracks()])
connection.send(playlist)
self.connected.wait()

View File

@ -1,6 +1,6 @@
from mopidy.backends.base import BaseStoredPlaylistsProvider
class LibspotifyStoredPlaylistsProvider(BaseStoredPlaylistsProvider):
class SpotifyStoredPlaylistsProvider(BaseStoredPlaylistsProvider):
def create(self, name):
pass # TODO

View File

@ -4,12 +4,12 @@ import logging
from spotify import Link, SpotifyError
from mopidy import settings
from mopidy.backends.libspotify import ENCODING
from mopidy.backends.spotify import ENCODING
from mopidy.models import Artist, Album, Track, Playlist
logger = logging.getLogger('mopidy.backends.libspotify.translator')
logger = logging.getLogger('mopidy.backends.spotify.translator')
class LibspotifyTranslator(object):
class SpotifyTranslator(object):
@classmethod
def to_mopidy_artist(cls, spotify_artist):
if not spotify_artist.is_loaded():

View File

@ -12,12 +12,12 @@ Available settings and their default values.
#:
#: Default::
#:
#: BACKENDS = (u'mopidy.backends.libspotify.LibspotifyBackend',)
#: BACKENDS = (u'mopidy.backends.spotify.SpotifyBackend',)
#:
#: .. note::
#: Currently only the first backend in the list is used.
BACKENDS = (
u'mopidy.backends.libspotify.LibspotifyBackend',
u'mopidy.backends.spotify.SpotifyBackend',
)
#: The log format used for informational logging.
@ -169,24 +169,24 @@ MPD_SERVER_HOSTNAME = u'127.0.0.1'
#: Default: 6600
MPD_SERVER_PORT = 6600
#: Path to the libspotify cache.
#: Path to the Spotify cache.
#:
#: Used by :mod:`mopidy.backends.libspotify`.
SPOTIFY_CACHE_PATH = u'~/.mopidy/libspotify_cache'
#: Used by :mod:`mopidy.backends.spotify`.
SPOTIFY_CACHE_PATH = u'~/.mopidy/spotify_cache'
#: Your Spotify Premium username.
#:
#: Used by :mod:`mopidy.backends.libspotify`.
#: Used by :mod:`mopidy.backends.spotify`.
SPOTIFY_USERNAME = u''
#: Your Spotify Premium password.
#:
#: Used by :mod:`mopidy.backends.libspotify`.
#: Used by :mod:`mopidy.backends.spotify`.
SPOTIFY_PASSWORD = u''
#: Do you prefer high bitrate (320k)?
#:
#: Used by :mod:`mopidy.backends.libspotify`.
#: Used by :mod:`mopidy.backends.spotify`.
#
#: Default::
#: