From 5a962adcb73d3327daa7f2a6123f1bf1aad6f099 Mon Sep 17 00:00:00 2001 From: Paul Lamere Date: Sun, 17 Sep 2017 08:13:17 -0400 Subject: [PATCH] Fixiing spotify radio --- server/components.py | 18 +++++++++++++----- server/plugs.py | 11 ++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/server/components.py b/server/components.py index 9c15d07..d3673bb 100644 --- a/server/components.py +++ b/server/components.py @@ -793,13 +793,21 @@ "help" : """ This component generates a stream of tracks by the given artist or similar artists """, - "title" : "$seed_artist_name_or_uri radio", + "title" : "$name radio", + "help" : """ This component will generate a stream of track by + the given artist and similar artists. You can specify the artist + either by name or by URI. If both are given, the URI is used.""", + "params": { - "seed_artist_name_or_uri": { - "display" : "artist", + "name": { "type" : "string", - "optional" : False, - "description": "the seed artist (as a name or artist uri)", + "optional" : True, + "description": "the name of the artist", + }, + "uri": { + "type" : "uri", + "optional" : True, + "description": "the uri of the artist", }, } }, diff --git a/server/plugs.py b/server/plugs.py index 6b6a5cc..b67d1a9 100644 --- a/server/plugs.py +++ b/server/plugs.py @@ -1303,9 +1303,10 @@ class SpotifyArtistRadio(object): :param seed_artist_name_or_uri the name or uri of the seed artist ''' - def __init__(self, seed_artist_name_or_uri): + def __init__(self, name, uri): self.name = 'Artist Radio' - self.seed_artist_name_or_uri = seed_artist_name_or_uri + self.artist_name = name + self.artist_uri = uri self.buffer = None def next_track(self): @@ -1314,10 +1315,10 @@ def next_track(self): try: sp = get_spotify() - if is_uri(self.seed_artist_name_or_uri): - seed_uri = self.seed_artist_name_or_uri + if self.artist_uri: + seed_uri = self.artist_uri else: - seed_uri = get_artist_uri(self.seed_artist_name_or_uri) + seed_uri = spotify_plugs._find_artist_by_name(sp, self.artist_name) if seed_uri: results = sp.recommendations(seed_artists=[seed_uri], limit=100)