def append_photourl(sno, us): songs = systemdb.query(sno) photourl='' if len(songs)>0: song = songs[0] if len(song['photourl'])>0: photourl=song['photourl'] return '{0}\t{1}\t{2}'.format( us.encode('utf-8'), photourl, sno)
def playlist_get( access_token, uid='me'): snolist= session.playlist_get( access_token, uid) allses=[] for sno in snolist: ses = systemdb.query( sno) if len(ses)==0: continue newse = fix_song_entry( ses[0]) allses.append( newse) return json.dumps( allses, True, False, indent=4)
def qsong(): print 'querystring=', request.query_string for f in systemdb.fieldnames: qval = request.GET.get( f , '').strip() if qval: break if qval==None: #raise HTTPError(code=403) return 'Error: no such field' qval=urllib.unquote(qval) ses = systemdb.query( qval, field=f) if len(ses)==0: return 'Error: not found' #raise HTTPError(code=403) newses = [ fix_song_entry(se) for se in ses] return json.dumps( newses, True, False, indent=4)