Example #1
0
def requestWithUserAndParams(user, params):

    import sb_helpers as sh
    import what.whathelpers as wh
    wp = wh.whatPlug(user)
    try:
        action = params['action'][0]
    except KeyError as e:
        return ['No action found for params']
    
    req = None

    if action =='artists':
        req = []
        soup = wp.wrap()
        artists = soup.artist.all()
        for art in artists:
            i = art.id
            gids =map(lambda x: x.gid, soup.artist_gids.filter_by(artist=i).all())
            for g in gids:
                req.append({'artist_mbid':g,'name':art.name})
            
    elif action =='albums':
        soup = wp.wrap()
        req = map(lambda x: x.name, id.release.all())
    else:
        raise Exception('unimplemented action: '+action)

    for r in req: r['datatype'] =sh.dtFromAction(action)
    for r in req: r['action'] = action
    return req
Example #2
0
    def getAllArtists(self):
        wp = wh.whatPlug(self.user)

        req = []
        soup = wp.wrap()
        artist_mbids = soup.artist_gids.all()
        for amb in artist_mbids:
            art = soup.artist.filter_by(id = amb.artist).first()
            name = art.name
            req.append({'artist_mbid':amb.gid,'name':name})
        return req
Example #3
0
 def getAllAlbums(self):
     req = []
     wp = wh.whatPlug(self.user)
     soup = wp.wrap()        
     releases = soup.release.all()
     for r in releases:
         mbids =  soup.release_gids.filter_by(release = r.id).all()
         if len(mbids) == 0:
             req.append({'name':r.name})
         else:
             for m in mbids:
                 req.append({'name':r.name,'album_mbid':m.gid})
     return req
Example #4
0
def unregister():
    print "Unregister what.cd for which SB user?"
    sb_user = raw_input('username: '******'what',sb_user):
        print "Plugin is not registered for user: "******"...exiting"
        exit(1)

    plug = whatPlug(sb_user)
    dbfile = plug.whatDBFile()
    cookiefile = plug.whatCookieFile()
    if os.path.isfile(cookiefile):
        os.remove(cookiefile)
    os.remove(dbfile)
    wc.unconfigure(sb_user)
    pc.unregister('what',sb_user)
Example #5
0
    def getMBIDArtistAlbums(self,gid):
        wp = wh.whatPlug(self.user)

        req = []
        soup = wp.wrap()
        gid_matches = soup.artist_gids.filter_by(gid = gid).all()
        for g in gid_matches:
            i = g.artist
            releases = soup.artist_release.filter_by(artist = i).all()
            for r in releases:
                rval = soup.release.filter_by(id = r.release).first()
                print rval.name

                name = rval.name
                mbids =  soup.release_gids.filter_by(release = rval.id).all()
                if len(mbids) == 0:
                    req.append({'artist_mbid':gid,'name':name})
                else:
                    for m in mbids:
                        req.append({'artist_mbid':gid,'name':name,'album_mbid':m.gid})
        return req