Esempio n. 1
0
    def handle(self, *args, **options):
        musicbrainz = MusicBrainz()

        results = []
        for artist in Artist.objects.all():
            time.sleep(1.1)  # Rate limit for APIs
            genres = musicbrainz.get_artist_genres(artist.mbid)
            if len(genres) > 0:
                result = [artist.mbid] + list(genres)
                print "Adding: ", result
                results.append(result)

        with open(settings.BASE_DIR + "/data/artists_genres.csv", "wb") as genresFile:
            csvWriter = csv.writer(genresFile, delimiter=",")
            for row in results:
                csvWriter.writerow(row)
Esempio n. 2
0
    def handle(self, *args, **options):
        musicbrainz = MusicBrainz()

        results = []
        for artist in Artist.objects.all():
            time.sleep(1.1)  # Rate limit for APIs
            genres = musicbrainz.get_artist_genres(artist.mbid)
            if len(genres) > 0:
                result = [artist.mbid] + list(genres)
                print "Adding: ", result
                results.append(result)

        with open(settings.BASE_DIR + '/data/artists_genres.csv',
                  'wb') as genresFile:
            csvWriter = csv.writer(genresFile, delimiter=',')
            for row in results:
                csvWriter.writerow(row)
Esempio n. 3
0
    def handle(self, *args, **options):
        lastfm = LastFM()
        musicbrainz = MusicBrainz()

        results = []
        for country in Country.objects.all():
            for artist in lastfm.artists_by_country(country):
                time.sleep(1.1) # Rate limit for APIs
                musicbrainz_id = artist.get_mbid()
                if not musicbrainz.is_artist_from_country(musicbrainz_id, country.iso_code):
                    continue
                result = [country.iso_code, smart_str(artist.name), musicbrainz_id]
                print "Adding: ", result
                results.append(result)

        with open(settings.BASE_DIR + '/data/artists.csv', 'wb') as artistsFile:
            csvWriter = csv.writer(artistsFile, delimiter=',')
            for row in results:
                csvWriter.writerow(row)