Exemplo n.º 1
0
def search_albums(artist_name):
	albums = []
	result = pygn.get_discography(clientID=clientID, userID=userID, artist=artist_name)
	newjson = json.dumps(result, sort_keys=True, indent=4)
	ddata = eval(newjson)
	for item in ddata:
		albums.append(item["album_title"])
	return albums
Exemplo n.º 2
0
def search_albums(artist_name):
	albums = []
	print '\nGetting artist discography for'+str(artist_name)+"\n"
	result = pygn.get_discography(clientID=clientID, userID=userID, artist=artist_name)
	newjson = json.dumps(result, sort_keys=True, indent=4)
	ddata = eval(newjson)
	for item in ddata:
		# if item["album_artist_name"] == artist_name:
		albums.append(item["album_title"])
	return albums
Exemplo n.º 3
0
    def get_discography(self, artists):
        """
        :param artists: list of artists to get discography for
            :type: list

        :rtype: set
        """
        api = GracenoteAPI()
        userID = pickle.load(open('userID.p', 'rb'))

        tracklist = set()
        artist_discography_list = []
        list_of_songs_with_artists = []
        in_game_songs = []
        for band in artists:
            in_game_songs.append(self.check_songs_in_game(band))
            artist_discography_list.append(
                pygn.get_discography(api.clientID, userID, band, 1, 30))

        for artist_discog in artist_discography_list:
            for release in artist_discog:
                if release['album_artist_name'].lower() in artists:
                    for track in release['tracks']:
                        songs_with_artist = (release['album_artist_name'],
                                             track['track_title'])
                        list_of_songs_with_artists.append(songs_with_artist)

        for pair in list_of_songs_with_artists:
            tracklist.add(pair)

        for t in tracklist.copy():
            for song in in_game_songs:
                for title in song:
                    if title in t[1]:
                        tracklist.discard(t)

        return tracklist
Exemplo n.º 4
0
print '\nSearch for artist "Kings of Convenience"\n'
result = pygn.search(clientID=clientID,
                     userID=userID,
                     artist='Kings of Convenience')
print json.dumps(result, sort_keys=True, indent=4)

print '\nSearch for album "Prism" by "Katy Perry"\n'
result = pygn.search(clientID=clientID,
                     userID=userID,
                     artist='Katy Perry',
                     album='Prism')
print json.dumps(result, sort_keys=True, indent=4)

print '\nSearch for track "Drop" by "Cornelius"\n'
result = pygn.search(clientID=clientID,
                     userID=userID,
                     artist='Cornelius',
                     track='Drop')
print json.dumps(result, sort_keys=True, indent=4)

#print '\nSearching by album TOC\n'
#result = pygn.search(clientID=clientID, userID=userID, toc='150 20512 30837 50912 64107 78357 90537 110742 126817 144657 153490 160700 175270 186830 201800 218010 237282 244062 262600 272929')
#print json.dumps(result, sort_keys=True, indent=4)

print '\nGetting artist discography for "Daft Punk"\n'
result = pygn.get_discography(clientID=clientID,
                              userID=userID,
                              artist='Daft Punk')
print json.dumps(result, sort_keys=True, indent=4)

print userID
Exemplo n.º 5
0
Arquivo: test.py Projeto: Beirdo/pygn
print(json.dumps(result, sort_keys=True, indent=4))

print('\nSearch for album "Prism" by "Katy Perry"\n')
result = pygn.search(clientID=clientID, userID=userID, artist='Katy Perry', album='Prism')
print(json.dumps(result, sort_keys=True, indent=4))

print('\nSearch for track "Drop" by "Cornelius"\n')
result = pygn.search(clientID=clientID, userID=userID, artist='Cornelius', track='Drop')
print(json.dumps(result, sort_keys=True, indent=4))

print('\nSearching by album TOC\n')
result = pygn.search(clientID=clientID, userID=userID, toc='150 20512 30837 50912 64107 78357 90537 110742 126817 144657 153490 160700 175270 186830 201800 218010 237282 244062 262600 272929')
print(json.dumps(result, sort_keys=True, indent=4))

print('\nGetting artist discography for "Daft Punk"\n')
result = pygn.get_discography(clientID=clientID, userID=userID, artist='Daft Punk')
print(json.dumps(result, sort_keys=True, indent=4))


# Example how to create a radio playlist by mood peaceful
result = pygn.createRadio(clientID, userID, mood='65322', popularity ='1000', similarity = '1000')
print(json.dumps(result, sort_keys=True, indent=4))

# Example how to create a radio playlist by genre classical music
result = pygn.createRadio(clientID, userID, genre='36061', popularity ='1000', similarity = '1000')
print(json.dumps(result, sort_keys=True, indent=4))

# Example how to create a radio playlist by era 1970
result = pygn.createRadio(clientID, userID, era='29486', popularity ='1000', similarity = '1000')
print(json.dumps(result, sort_keys=True, indent=4))