Esempio n. 1
0
 def sync_album(self, album_title):
     album_by_title = Album.objects.filter(title=album_title)
     if not album_by_title:
         new_album = Album()
         new_album.title = album_title
         new_album.save()
         return new_album 
     return album_by_title[0]
Esempio n. 2
0
 def create(self, validated_date):
     tracks_data = validated_date.get("tracks")
     a = Album()
     a.title = validated_date.pop("title")
     a.year = validated_date.pop("year")
     a.publisher = validated_date.pop("publisher")
     a.description = validated_date.pop("description")
     a.save()
     if tracks_data != None:
         for track_id in tracks_data:
             m = Music.objects.get(pk=track_id)
             m.album = a
             m.save()
     return a
Esempio n. 3
0
 def setUp(self):
   song = Song()
   song.title = "Basket Case"
   song.file_path = "burgle/data/pandora/Basket Case.mp3"
   artist = Artist()
   artist.name = 'Green Day'
   artist.save()
   song.artist = artist
   album = Album()
   album.title = 'Dookie'
   album.save()
   song.album = album
   song.station_id = int('21312')
   song.save()
   genre = Genre()
   genre.name = 'Rock'
   genre.save()
   song.genres.add(genre) 
Esempio n. 4
0
 def setUp(self):
   seed = str(random.randint(1, 100000))
   song = Song()
   song.title = 'Basket Case'
   pandora_url = 'http://audio-dc6-t1-1.pandora.com/access/6394738923373318898?version=4&lid=55475035&token=ltvKtTCJqaVK0%2FRsqx6FVl92LrWl3riBZtqhXMaoAQGBaZ5CflwAEnJO%2B7CSl%2FFyxIkYLmsL31krBpS3lnPj0PBX0UkSU0BFmh6BBO2wsUwUWvwFu2hyUHpWaJLcL7eJtEl08SKzQswNULEPr3V0R5JD64rB0ANyYc4YeDVSMs9m%2Fo5PITxWQlermntRbN1B2cGg4mi%2BOxQEHWnbwwoRKeQG6c0mv1qHasdMQXJrXc%2FxoUJM7az1yklTPW8LUnmaRho%2BxYBWhmJ5XBjMQtBt89moJVNfi9Cx08fUBf2GU369d63N1HACf86Nt1rcKRgS6NhaBngwjBPeJY0XBR76JesF%2BBQJHUKR'
   song.audio_url = pandora_url
   artist = Artist()
   artist.name = 'Green Day'
   artist.save()
   song.artist = artist
   album = Album()
   album.title = 'TestAlbum-' + str(seed)
   album.save()
   song.album = album
   song.station_id = int(seed)
   song.save()
   genre = Genre()
   genre.name = 'Rock'
   genre.save()
   song.genres.add(genre) 
Esempio n. 5
0
 def setUp(self):
   for i in range(10):
     seed = str(random.randint(1, 100000))
     song = Song()
     song.title = 'Demo'
     song.audio_url = 'test/music/demo.mp3'
     artist = Artist()
     artist.name = 'TestArtist-' + seed
     artist.save()
     song.artist = artist
     album = Album()
     album.title = 'TestAlbum-' + seed
     album.save()
     song.album = album
     song.station_id = int(seed)
     song.save()
     genre = Genre()
     genre.name = 'TestGenre-' + seed
     genre.save()
     song.genres.add(genre) 
     self.test_songs.append(song)