Fix old Spotify playlists URI format

This commit is contained in:
Fabio Manganiello 2019-01-03 10:37:11 +01:00
parent 9328566235
commit 240abb627d

View file

@ -217,6 +217,7 @@ class MusicMpdPlugin(MusicPlugin):
if isinstance(resource, list): if isinstance(resource, list):
for r in resource: for r in resource:
r = self._parse_resource(r)
try: try:
self._exec('add', r) self._exec('add', r)
except Exception as e: except Exception as e:
@ -224,7 +225,16 @@ class MusicMpdPlugin(MusicPlugin):
return self.status().output return self.status().output
return self._exec('add', resource) r = self._parse_resource(resource)
return self._exec('add', r)
@classmethod
def _parse_resource(cls, resource):
if resource and resource.startswith('spotify:playlist:'):
# Old Spotify URI format, convert it to new
m = re.match('^spotify:playlist:(.*)$', resource)
resource = 'spotify:user:spotify:playlist:' + m.group(1)
return resource
@action @action
def load(self, playlist): def load(self, playlist):