Example #1
0
    def GET(self, songuri):
        track = None
        if songuri:
            print songuri
            try:
                track = spotimeta.lookup(str(songuri))
            except:
                return render.index(GetCurrentTrack(), web.songqueue)
            track['result']['href'] = songuri
            
            

            try:
                uris = session.get('urilist',[])
                if songuri in uris:
                    return render.add(track['result'],True)
                else:
                    # check if song already there -> upvote
                    self.AddToList(track['result'])  
                    web.songqueue.sort(key = lambda x: x['count']*-1)
                    session.urilist.append(songuri)   
                    return render.add(track['result'],False)
            except AttributeError:
                # check if song already there -> upvote
                self.AddToList(track['result'])  
                web.songqueue.sort(key = lambda x: x['count']*-1)
                session.urilist = []
                session.urilist.append(songuri)  
                return render.add(track['result'],False)
        else:
            return render.index(GetCurrentTrack(), web.songqueue)
Example #2
0
def input(URL):
    track = spotimeta.lookup(URL)
    song = re.sub(
        r'Explicit|Dirty|Theme|LP|\'|Version|-|\(.{1,}\)|Soundtrack|Clean|Edited|Album',
        '', track['result']['name'])
    artist = re.sub(r'The|,', '', track['result']['artist']['name'])
    return artist, song
Example #3
0
 def from_uri(cls,uri):
   query = cls.objects.filter(uri=uri)
   if query.count() < 1:
     track = cls(uri=uri)
   else:
     track = query[0]
   lk = spotimeta.lookup(uri)
   print lk
   track.name = lk['result']['name']
   track.artist = lk['result']['artist']['name']
   return track
Example #4
0
def spotify_url(match):
    type = match.group(2)
    spotify_id = match.group(3)
    url = gateway.format(type, spotify_id)
    data = spotimeta.lookup(url)
    if type == "track":
        return u"Spotify Track: {} by {} from the album {}".format(data["result"]["name"], data["result"]["artist"]["name"], data["result"]["album"]["name"])
    elif type == "artist":
        return u"Spotify Artist: {}".format(data["result"]["name"])
    elif type == "album":
        return u"Spotify Album: {} - {}".format(data["result"]["artist"]["name"], data["result"]["name"])
Example #5
0
def spotify_url(match):
    type = match.group(2)
    spotify_id = match.group(3)
    url = gateway.format(type, spotify_id)
    data = spotimeta.lookup(url)
    if type == "track":
        return u"Spotify Track: {} by {} from the album {}".format(
            data["result"]["name"], data["result"]["artist"]["name"],
            data["result"]["album"]["name"])
    elif type == "artist":
        return u"Spotify Artist: {}".format(data["result"]["name"])
    elif type == "album":
        return u"Spotify Album: {} - {}".format(
            data["result"]["artist"]["name"], data["result"]["name"])
Example #6
0
def hi(bot, trigger):
    #bot.say("It works, stupid ...: (" + trigger + ")")

    arr = trigger.split()
    for alt in arr:
       if unicode(alt).startswith(u'spotify'):
           spotifyUri = alt
    try:
        result = spotimeta.lookup(spotifyUri)
        nick = trigger.nick
        media = spotifyUri.split(":")[1]
        if media == 'album' or media == 'track':
            artist = result["result"]["artist"]["name"]
            track = result["result"]["name"]
            bot.say(nick + ' wants you to listen to the ' + media + " " + artist + " - " + track)
        else:
            bot.say(nick + ' wants you to listen to the artist ' + result["result"]["name"])
    except Exception:
        pass
Example #7
0
def input(URL):
    track=spotimeta.lookup(URL)
    song=re.sub(r'Explicit|Dirty|Theme|LP|\'|Version|-|\(.{1,}\)|Soundtrack|Clean|Edited|Album','', track['result']['name'])
    artist=re.sub(r'The|,','',track['result']['artist']['name'])
    return artist, song