Example #1
0
 def add_song(self, artist, title):
     songs = song.search(artist=artist, title=title, results=5, sort="song_hotttnesss-desc")
     self.track_list = []
     for s in songs:
         tr = setlist.get_best_audio_track(s.id, "spotify-WW", pysong=s)
         if tr:
             self.track_list.append(tr)
     
     body = 'Which one of these tracks do you like?<br>'
     body += '<form action = "add_track" method = "get"><input type = "text" style="width:150" name = "track_id" placeholder = "Track ID"'
     body += '<input type = "submit"></form>'
     body += self._make_track_table(self.track_list)
     return HEAD.replace("BODY_HERE", body)
Example #2
0
def main(infile, outfile):
    song_ids = open(infile).read().split('\n')[:-1]

    results = []
    for s in song_ids:
        print(s), ":",
        result = setlist.get_best_audio_track(s, 'spotify-WW')
        if result:
            results.append(result)
            print(result)
        else:
            print "No audio tracks found."

    song_db = open(outfile, 'w')
    json.dump(results, song_db)
    song_db.close()