def album_from_style(genreid): params = [] params.append(('filter', "subgenreid:" + genreid)) params.append(('size', 1)) results = get_filterbrowse_christmas(params) albumid = results[0]["id"] return show_album(albumid)
def filterbrowse_theme(descid): params = [] params.append(('filter', "themeid:" + descid)) results = get_filterbrowse_christmas(params) return render_template('filterbrowse.html', results=results)
def generate_cache(): # dragons - this function is untested. # determine the total size of the result and calculate # pages # (max response size is 100) page_size = 100 result_size = get_filterbrowse_christmas_pages() num_pages = result_size / page_size print " ******************************* " print "Starting the caching process." print "Page Size: " + str(page_size) print "Number of Results " + str(result_size) print "Pages Needed " + str(num_pages) print " ******************************* " # set num_pages below if you'd like an abbreviated result. #num_pages = 2 for page in range(num_pages): cache = {} params = [] params.append(('size', str(page_size))) #params.append(('include', 'styles,moods')) params.append(('offset', str(page*100))) result = get_filterbrowse_christmas(params) for album in result: cache[album["id"]] = album if page > 0: f = open("song_dump.json", "r") full_cache = json.load(f) f.close() else: full_cache = {} full_cache = (full_cache.items() + cache.items()) print "Writing page " + str(page) f = open("song_dump.json", "w") json.dump(cache, f, indent=4) f.close() time.sleep(10)
from rovi import get_stylemap, get_genremap, get_filterbrowse_christmas import json import time f = open("styles.json", "r") style_hash = json.load(f) f.close() top_desc_to_albums = {} albums = {} for id, name in style_hash.iteritems(): params = [] params.append(("filter", "subgenreid:" + id)) params.append(("size", 25)) filterresponse = get_filterbrowse_christmas(params) topitems = [] for result in filterresponse: topitems.append(result["id"]) albums[result["id"]] = result["album"]["title"] if topitems != []: top_desc_to_albums[id] = topitems f = open("topitemmap.json", "w") json.dump(top_desc_to_albums, f, indent=4) f.close() f = open("albumdump.json", "w") json.dump(albums, f, indent=4) f.close()