def getCurrentSongsAndWriteToFile(): results = getBurstingPhrases() #socio_results_list = [] #song_results_list = [] for each_item in results: for each_key in each_item.keys(): if (each_key == "phrase"): phrase = each_item["phrase"] # Pass Sociocast results and Bit.ly phrase into Rovi to get # song results song_results=get_rovi_data("musicsearch", phrase)["searchResponse"]["results"] if song_results==None: continue songs=[] for s in song_results: try: title=s["song"]["title"] artist=s["song"]["primaryArtists"][0]["name"] except TypeError: continue songs.append({"title":title,"artist":artist}) each_item["songs"]=songs fout=open("./static/js/phrases.json",'w') json.dump(results,fout) fout.close()
def get_phrases(): results = getBurstingPhrases() socio_results_list = [] song_results_list = [] for each_item in results: for each_key in each_item.keys(): if (each_key == "phrase"): phrase = each_item["phrase"] # Pass Sociocast results and Bit.ly phrase into Rovi to get # song results song_results_list.append(get_rovi_data("musicsearch", phrase)) elif (each_key == "top_link"): # Pass top URL into sociocast to get classifications sociocast_url = each_item["top_link"]["aggregate_url"] socio_results_list.append(get_content_profile(sociocast_url)) # Could combine titles into unique tokens and remove # stop words for additional search keywords # elif (each_key == "titles"): # url_response = each_item["titles"] response = make_response(json.dumps(song_results_list)) response.headers.add("Access-Control-Allow-Origin", "*") return response
def get_phrases(): results = getBurstingPhrases() socio_results_list = [] song_results_list = [] for each_item in results: for each_key in each_item.keys(): if each_key == "phrase": phrase = each_item["phrase"] # Pass Sociocast results and Bit.ly phrase into Rovi to get # song results song_results_list.append(get_rovi_data("musicsearch", phrase)) elif each_key == "top_link": # Pass top URL into sociocast to get classifications sociocast_url = each_item["top_link"]["aggregate_url"] socio_results_list.append(get_content_profile(sociocast_url)) # Could combine titles into unique tokens and remove # stop words for additional search keywords # elif (each_key == "titles"): # url_response = each_item["titles"] response = make_response(json.dumps(song_results_list)) response.headers.add("Access-Control-Allow-Origin", "*") return response