More robust Spotify URI parsing that discards optional arguments (e.g. si=) passed to the URL

This commit is contained in:
Fabio Manganiello 2019-01-30 09:04:15 +01:00
parent 7a80cd08ce
commit ee0040fba6

View file

@ -257,6 +257,9 @@ class MusicMpdPlugin(MusicPlugin):
@classmethod @classmethod
def _parse_resource(cls, resource): def _parse_resource(cls, resource):
m = re.search('^https://open.spotify.com/([^?]+)', resource)
if m: resource = 'spotify:{}'.format(m.group(1).replace('/', ':'))
if resource and resource.startswith('spotify:playlist:'): if resource and resource.startswith('spotify:playlist:'):
# Old Spotify URI format, convert it to new # Old Spotify URI format, convert it to new
m = re.match('^spotify:playlist:(.*)$', resource) m = re.match('^spotify:playlist:(.*)$', resource)