示例#1
0
    def makeMBIDs(self):
        import tagger.matcher as matcher
        s = self.soup()
        name = s.artist.filter_by(id = self.id).first().name
        gids =  map(lambda x: x['gid'], matcher.matchArtistString(name))
        
        matches = s.artist_gids.filter_by(artist = self.id).all()
        for m in matches:
            s.delete(m)

        for g in gids: s.artist_gids.insert(artist=self.id,gid=g)
        s.commit()
        return map( lambda x: x.gid, s.artist_gids.all())
示例#2
0
    def makeMBIDsForArtist(self,artid):
        import tagger.matcher as matcher
        w = self.wrap()
        name = w.queryToDict("select name from artist where id = :artid",
                             {'artid':artid})[0]['name']
        print name
        gids = map(lambda x: x['gid'], matcher.matchArtistString(name))

        w.query("""
delete from artist_gids
where artist = :artid
;""",
                {'artid':artid})
        for g in gids:
                       w.query("""
insert into artist_gids(artist, gid)
values(:artid,:gid)
;""",
                               {'artid':artid,'gid':g})
                   
        w.commit()
        w.close()