Esempio n. 1
0
    def register_concerts(self, tracks=False):
        """Retrieves a json list of concerts from archive.org for a
        given Artist (one which is already registered with our
        database) and registers the artist's concerts with our
        db. Additionally registers the tracks of each of these
        concerts if tracks=True.

        usage:
        >>> from api.music import Artist
        >>> a = Artist.get(tag="ExplosionsintheSky")
        >>> a.register_concerts()
        """
        concerts = Crawler.concerts(self.tag)
        for concert in concerts:
            name = concert['title']
            tag = concert['identifier']
            print(concert)
            try:
                c = Concert(tag=tag, name=name, artist_id=self.id)
                c.create()
                self.concerts.append(c)
                self.save()
            except:
                pass

            if tracks:
                c.register_tracks()