From 240abb627d523f7610d372c37e77c10871af6076 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 3 Jan 2019 10:37:11 +0100 Subject: [PATCH] Fix old Spotify playlists URI format --- platypush/plugins/music/mpd/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/music/mpd/__init__.py b/platypush/plugins/music/mpd/__init__.py index 4180d0594..d07c9f0fa 100644 --- a/platypush/plugins/music/mpd/__init__.py +++ b/platypush/plugins/music/mpd/__init__.py @@ -217,6 +217,7 @@ class MusicMpdPlugin(MusicPlugin): if isinstance(resource, list): for r in resource: + r = self._parse_resource(r) try: self._exec('add', r) except Exception as e: @@ -224,7 +225,16 @@ class MusicMpdPlugin(MusicPlugin): 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 def load(self, playlist):