示例#1
0
文件: cli.py 项目: plamere/SixDegrees
 def asearch(self, name):
     aids = db.artist_search(name)
     if len(aids) > 0:
         return aids[0]['id']
     else:
         print "no match for", name
         return None
示例#2
0
 def search(self, query=None, _=None):
     log_api_call('search')
     results = get_results()
     artists = db.artist_search(query)
     results['artists'] = artists
     results['query'] = query
     return seal_results(results)
示例#3
0
文件: cli.py 项目: plamere/SixDegrees
    def do_artist(self, line):
        ''' searches for artists '''

        artists = db.artist_search(line)
        for artist in artists:
            print "%s %s" % (artist['id'], artist['name'])
示例#4
0
db.init(quick=False)

while len(names) < total:
    print len(names), "found, hotttnesss is", max_hotttnesss
    for start in xrange(0, batch_size, page_size):
        response = en.get(
            "artist/search",
            start=start,
            sort="hotttnesss-desc",
            results=page_size,
            max_hotttnesss=max_hotttnesss,
            bucket="hotttnesss",
        )
        for a in response["artists"]:
            name = a["name"]
            results = db.artist_search(name)
            if len(results) > 0:
                names.add(name)
                print len(names), name
            else:
                print "           not found", name
            last_hotttnesss = a["hotttnesss"]
    max_hotttnesss = last_hotttnesss


lnames = list(names)
lnames.sort()

out = open("artist_names.js", "w")
print >> out, json.dumps(lnames)
out.close()
示例#5
0
def asearch(q):
    if len(q) > 0:
        aids = db.artist_search(q)
        if len(aids) > 0:
            return aids[0]
    return None