def get_artists_by_tag(tag): n = '500' value = cache.get_value(tag, n, lastfm='tag') if value == None: value = [] try: params = { 'method': 'tag.gettopartists', 'tag': tag, 'api_key': api_key, 'format': 'json', 'limit': n } json_data = requests.get(api_url, params=params).json() for a in json_data['topartists']['artist']: try: value.append({'artist': a['name']}) except: pass cache.save_value(tag, n, value, lastfm='tag') except: pass artists = [] for a in value: artists.append(a) if len(artists) == int(common.limit_tag()): break return artists
def get_similar_artists(artist): n = '100' value = cache.get_value(artist, n, lastfm=True) if value == None: value = [] try: params = { 'method': 'artist.getsimilar', 'artist': artist, 'autocorrect': '1', 'limit': n, 'api_key': api_key, 'format': 'json' } json_data = requests.get(api_url, params=params).json() for item in json_data['similarartists']['artist']: value.append(item['name']) cache.save_value(artist, n, value, lastfm=True) except: pass similar_artists = [] for s in value: similar_artists.append(s) if len(similar_artists) == int(common.limit_artists()): break return similar_artists
def get_artist_genre(artist): genre_list = cache.get_value(artist, 'genre', lastfm='tag') if genre_list == None: genre_list = [] try: params = { 'method': 'artist.gettoptags', 'artist': artist, 'api_key': api_key, 'format': 'json' } json_data = requests.get(api_url, params=params).json() for tag in json_data['toptags']['tag']: genre = tag['name'] list = [ 'german', 'deutsch', 'seen live', 'made in germany', 'japanese', 'anime', 'vocalists', 'songwriter' ] if not any(x in genre.lower() for x in list): genre_list.append(genre) if len(genre_list) == 5: break cache.save_value(artist, 'genre', genre_list, lastfm='tag') except: pass return genre_list
def videos_thread(site,artist,result): start_time = time.time() video_list = [] video_list = cache.get_value(site,artist) #video_list = None if video_list == None: video_list = common.import_site(site).get_videos(artist) if not video_list == False: cache.save_value(site,artist,video_list) result.append(video_list) complete_time = time.time() - start_time common.log('[mvmixPlayer] site: %s - time: %s' % (site,str(complete_time))) return result
def get_artist_genre(artist): genre_list = cache.get_value(artist,'genre',lastfm='tag') if genre_list == None: genre_list = [] try: params = {'method':'artist.gettoptags', 'artist':artist, 'api_key':api_key, 'format':'json'} json_data = requests.get(api_url, params=params).json() for tag in json_data['toptags']['tag']: genre = tag['name'] list = ['german','deutsch','seen live','made in germany','japanese','anime','vocalists','songwriter'] if not any(x in genre.lower() for x in list): genre_list.append(genre) if len(genre_list) == 5: break cache.save_value(artist,'genre',genre_list,lastfm='tag') except: pass return genre_list
def get_similar_artists(artist): n = '100' value = cache.get_value(artist,n,lastfm=True) if value == None: value = [] try: params = {'method':'artist.getsimilar', 'artist':artist, 'autocorrect':'1', 'limit':n, 'api_key':api_key, 'format':'json'} json_data = requests.get(api_url, params=params).json() for item in json_data['similarartists']['artist']: value.append(item['name']) cache.save_value(artist,n,value,lastfm=True) except: pass similar_artists = [] for s in value: similar_artists.append(s) if len(similar_artists) == int(common.limit_artists()): break return similar_artists
def get_artist_genre(artist): genre_list = cache.get_value(artist, 'genre', lastfm='tag') if genre_list == None: genre_list = [] try: params = { 'method': 'artist.gettoptags', 'artist': artist, 'api_key': api_key, 'format': 'json' } json_data = requests.get(api_url, params=params).json() for tag in json_data['toptags']['tag']: genre_list.append(tag['name']) if len(genre_list) == 5: break cache.save_value(artist, 'genre', genre_list, lastfm='tag') except: pass return genre_list
def get_artists_by_tag(tag): n = '500' value = cache.get_value(tag,n,lastfm='tag') if value == None: value = [] try: params = {'method':'tag.gettopartists', 'tag':tag, 'api_key':api_key, 'format':'json', 'limit':n} json_data = requests.get(api_url, params=params).json() for a in json_data['topartists']['artist']: try: value.append({'artist':a['name']}) except: pass cache.save_value(tag,n,value,lastfm='tag') except: pass artists = [] for a in value: artists.append(a) if len(artists) == int(common.limit_tag()): break return artists