mpd: 'private' fields start with an _
This commit is contained in:
parent
5af26a226e
commit
f2000d6e6d
@ -232,9 +232,9 @@ class MpdContext(object):
|
||||
#: The subsytems that we want to be notified about in idle mode.
|
||||
subscriptions = None
|
||||
|
||||
playlist_uri_from_name = None
|
||||
_playlist_uri_from_name = None
|
||||
|
||||
playlist_name_from_uri = None
|
||||
_playlist_name_from_uri = None
|
||||
|
||||
def __init__(self, dispatcher, session=None, core=None):
|
||||
self.dispatcher = dispatcher
|
||||
@ -242,14 +242,14 @@ class MpdContext(object):
|
||||
self.core = core
|
||||
self.events = set()
|
||||
self.subscriptions = set()
|
||||
self.playlist_uri_from_name = {}
|
||||
self.playlist_name_from_uri = {}
|
||||
self._playlist_uri_from_name = {}
|
||||
self._playlist_name_from_uri = {}
|
||||
self.refresh_playlists_mapping()
|
||||
|
||||
def create_unique_name(self, playlist_name):
|
||||
name = playlist_name
|
||||
i = 1
|
||||
while name in self.playlist_uri_from_name:
|
||||
while name in self._playlist_uri_from_name:
|
||||
name = '%s [%d]' % (playlist_name, i)
|
||||
i += 1
|
||||
return name
|
||||
@ -260,11 +260,11 @@ class MpdContext(object):
|
||||
MPD
|
||||
"""
|
||||
if self.core is not None:
|
||||
self.playlist_uri_from_name.clear()
|
||||
self.playlist_name_from_uri.clear()
|
||||
self._playlist_uri_from_name.clear()
|
||||
self._playlist_name_from_uri.clear()
|
||||
for playlist in self.core.playlists.playlists.get():
|
||||
if not playlist.name:
|
||||
continue
|
||||
name = self.create_unique_name(playlist.name)
|
||||
self.playlist_uri_from_name[name] = playlist.uri
|
||||
self.playlist_name_from_uri[playlist.uri] = name
|
||||
self._playlist_uri_from_name[name] = playlist.uri
|
||||
self._playlist_name_from_uri[playlist.uri] = name
|
||||
|
||||
@ -381,11 +381,11 @@ def searchaddpl(context, playlist_name, mpd_query):
|
||||
return
|
||||
results = context.core.library.search(**query).get()
|
||||
|
||||
if len(context.playlist_uri_from_name) == 0:
|
||||
if len(context._playlist_uri_from_name) == 0:
|
||||
context.refresh_playlists_mapping()
|
||||
|
||||
if playlist_name in context.playlist_uri_from_name:
|
||||
uri = context.playlist_uri_from_name[playlist_name]
|
||||
if playlist_name in context._playlist_uri_from_name:
|
||||
uri = context._playlist_uri_from_name[playlist_name]
|
||||
playlist = context.core.playlists.lookup(uri).get()
|
||||
else:
|
||||
playlist = context.core.playlists.create(playlist_name).get()
|
||||
|
||||
@ -80,10 +80,10 @@ def listplaylists(context):
|
||||
for playlist in context.core.playlists.playlists.get():
|
||||
if not playlist.name:
|
||||
continue
|
||||
if playlist.uri not in context.playlist_name_from_uri:
|
||||
if playlist.uri not in context._playlist_name_from_uri:
|
||||
# the maps are not synced, we refresh them
|
||||
context.refresh_playlists_mapping()
|
||||
name = context.playlist_name_from_uri[playlist.uri]
|
||||
name = context._playlist_name_from_uri[playlist.uri]
|
||||
result.append(('playlist', name))
|
||||
last_modified = (
|
||||
playlist.last_modified or dt.datetime.utcnow()).isoformat()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user