Esempio n. 1
0
    def what(self):
        jsfiles = ["jquery"]
        rendered0 = sh.sourced_js(jsfiles, True)
        c.jsfiles = rendered0
        c.whatUser = "******"
        c.albumnames = []
        c.artistnames = []

        uname = sh.unameFromCookie(request.cookies["authkit"])

        import dbs.requests.request as r

        params = {"action": "getArtists"}
        c.artistnames = r.requestWithParams(uname, "what", params, True)
        params = {"action": "getAlbums"}
        c.albumnames = r.requestWithParams(uname, "what", params, True)

        return self.serveMako("what")
Esempio n. 2
0
    def fetch2(self):
        uname = sh.unameFromCookie(request.cookies['authkit'])
        
        p = request.params
        sources = self.parseSources(p)
        filters = self.parseFilters(p)
        action = p['action']
        
        data_arr = []
        for s in sources:
            req = None
            if s== 'remote': db = 'mbrainz'
            elif s == 'local': db = 'music'
            elif s == 'what': db = 'what'
            else: raise Exception('data source unhandled')
            db_params = {'action':action,'src':s}
            for key, item in filters.iteritems():
                db_params[key]=item
            #memcaching disabled (since, true)
            req = db_req.requestWithParams(uname,db,db_params,True)
            if not req: continue
            for r in req: r['source'] = s
            data_arr.extend(req)

        if len(data_arr) == 0:
            return None
        dt = data_arr[0]['datatype']
        if ( dt =='artist' or dt =='track'):
            mbstr = dt + "_mbid"
            data_arr = mergeDict(data_arr, mbstr)

        has_year = False
        for i in data_arr: 
            if i.has_key('year'): 
                has_year = 'True';
                break;
        #if has_year: data_arr = mergeDict(data_arr,'year')

        createAllStrs(data_arr,['set_to_merge']);
        getSBSortData(data_arr)
        return sjson.dumps(data_arr)