Exemple #1
0
def download_hottt(count=1000):
    """ Download images for the top 1000 hottt artists, and each of their 15 most similar artists.
        Warning, downloading all these images takes a long time.
    """
    hottest = top_hottt(results=count)
    for i, a in enumerate(hottest):
        print "Processing artist %d of %d" % (i, count)
        get_images(a)
        sims = []
        try:
            sims = a.similar
        except Exception, e:
            print "Couldn't get similars for %s: %s. Sleeping 2." % (str(a), str(e))
            time.sleep(2) # Tired? take a break.
        
        for s in sims:
            get_images(s)
Exemple #2
0
weezer = weezer_results[0]
weezer_blogs = weezer.blogs
print 'Blogs about weezer:', [blog.get('url') for blog in weezer_blogs]


#Get an artist by name:

from pyechonest import artist
a = artist.Artist('lady gaga')
print a.id


#Get the top hottt artists:

from pyechonest import artist
for hottt_artist in artist.top_hottt():
print hottt_artist.name, hottt_artist.hotttnesss

#Search for songs:

from pyechonest import song
rkp_results = song.search(artist='radiohead', title='karma police')
karma_police = rkp_results[0]
print karma_police.artist_location
print 'tempo:',karma_police.audio_summary['tempo'],'duration:',karma_police.audio_summary['duration']


#Get a song's audio_url and analysis_url:

from pyechonest import song
ss_results = song.search(artist='the national', title='slow show', buckets=['id:7digital-US', 'tracks'], limit=True)
Exemple #3
0
import re
import requests
from pyechonest import artist
from names import male_names, female_names

def clean_tags(string):
    string = string.replace('<td>', '')
    string = string.replace('</td>', '')
    string = string.replace('<br />', '')
    string = string.replace('</a>', '')
    if '<a href' in string:
        string = re.search(r'<a href=.+?>(.+)', string, re.S).group(1)
    return string.strip()


for a in artist.top_hottt(start=20, results=10):
    # check their wiki page:  if they're a band, get members
    # if they're not, do pronoun search

    if a.urls.get('wikipedia_url', None):
        wiki_url = a.urls['wikipedia_url']
        res = requests.get(wiki_url)
        body = res.text
        infobox = re.search(r'<table class="infobox.+?</table>', body, re.S).group()
        if 'Members' not in infobox:
            print a, " has one member."
            # do the search from pronouns.py here


        else:
            print a, " has multiple members."
# Uncomment to set the API key explicitly. Otherwise Pyechonest will
# look in the ECHO_NEST_API_KEY environment variable for the key.
#from pyechonest import config
#config.ECHO_NEST_API_KEY='YOUR API KEY'

from pyechonest import artist

hottt_artists = artist.top_hottt(results=3)

similar_artists = artist.similar(names=[hottt_artist.name for hottt_artist in hottt_artists])

for similar_artist in similar_artists:
    similar_to = [] 
    for hottt_artist in hottt_artists:
        if similar_artist in hottt_artist.similar:
            similar_to.append(hottt_artist.name)

    print '%-30s %16s   %s' % (similar_artist.name[0:30], 
                               similar_artist.hotttnesss, 
                               '...is in the top 15 similars of: ' + ', '.join(similar_to))
Exemple #5
0
# Uncomment to set the API key explicitly. Otherwise Pyechonest will
# look in the ECHO_NEST_API_KEY environment variable for the key.
#from pyechonest import config
#config.ECHO_NEST_API_KEY='YOUR API KEY'

from pyechonest import artist

hottt_artists = artist.top_hottt(results=3)

similar_artists = artist.similar(
    names=[hottt_artist.name for hottt_artist in hottt_artists])

for similar_artist in similar_artists:
    similar_to = []
    for hottt_artist in hottt_artists:
        if similar_artist in hottt_artist.similar:
            similar_to.append(hottt_artist.name)

    print '%-30s %16s   %s' % (
        similar_artist.name[0:30], similar_artist.hotttnesss,
        '...is in the top 15 similars of: ' + ', '.join(similar_to))
# Uncomment to set the API key explicitly. Otherwise Pyechonest will
# look in the ECHO_NEST_API_KEY environment variable for the key.
#from pyechonest import config
#config.ECHO_NEST_API_KEY='YOUR API KEY'

from pyechonest import artist

hottt_artists = artist.top_hottt()

for hottt_artist in hottt_artists:
    print hottt_artist.name, hottt_artist.hotttnesss
Exemple #7
0
def getHotArtists():
    return artist.top_hottt()
Exemple #8
0
import re
import requests
from pyechonest import artist

for a in artist.top_hottt(start=0, results=1):
    discogs_id = a.get_foreign_id('discogs').split(':')[2]
    url = 'http://api.discogs.com/artists/%s/releases' % discogs_id
    r = requests.get(url)
    for release in r.json()['releases']:
        format = release.get('format', '')
        if 'single' in format.lower():
            print release['title'], release['thumb']

def test_get_hottest_artists():
    hot = artist.top_hottt()
    assert len(hot) > 0