Skip to content

Commit

Permalink
Fixiing spotify radio
Browse files Browse the repository at this point in the history
  • Loading branch information
plamere committed Sep 17, 2017
1 parent b8abcda commit 5a962ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
18 changes: 13 additions & 5 deletions server/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}
},
Expand Down
11 changes: 6 additions & 5 deletions server/plugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit 5a962ad

Please sign in to comment.