Beispiel #1
0
 def get_json(self):
     playlist_key = chirp_playlist_key()
     recent_tracks = list(PlaylistTrack.all().filter("playlist =", playlist_key).order("-established").fetch(6))
     return {
         "now_playing": self.track_as_data(recent_tracks.pop(0)),
         # Last 5 played tracks:
         "recently_played": [self.track_as_data(t) for t in recent_tracks],
     }
Beispiel #2
0
def filter_tracks_by_date_range(from_date, to_date):
    fd = datetime(from_date.year, from_date.month, from_date.day, 0, 0, 0)
    td = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59)
    playlist = chirp_playlist_key()
    pl = PlaylistTrack.all().filter("playlist =", playlist)
    pl = pl.filter("established >=", fd)
    pl = pl.filter("established <=", td)
    pl = pl.order("-established")
    return pl
    def test_chirp_playlist_key(self):
        playlist_key = chirp_playlist_key()

        track = PlaylistTrack(
            selector=create_dj(),
            playlist=playlist_key,
            freeform_artist_name="Stevie Wonder",
            freeform_album_title="Talking Book",
            freeform_track_title='You Are The Sunshine Of My Life',
            freeform_label='Warner Bros.',
        )
        track.put()

        trk = PlaylistTrack.all().filter('playlist =', playlist_key)
        self.assertEqual(trk[0].artist_name, 'Stevie Wonder')
        playlist_key = chirp_playlist_key()  # from cache
        trk = PlaylistTrack.all().filter('playlist =', playlist_key)
        self.assertEqual(trk[0].artist_name, 'Stevie Wonder')
Beispiel #4
0
def filter_tracks_by_date_range(from_date, to_date):
    fd = datetime(from_date.year, from_date.month, from_date.day, 0, 0, 0)
    td = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59)
    playlist = chirp_playlist_key()
    pl = PlaylistTrack.all().filter('playlist =', playlist)
    pl = pl.filter('established >=', fd)
    pl = pl.filter('established <=', td)
    pl = pl.order('-established')
    return pl
Beispiel #5
0
    def test_chirp_playlist_key(self):
        playlist_key = chirp_playlist_key()

        track = PlaylistTrack(
            selector=create_dj(),
            playlist=playlist_key,
            freeform_artist_name="Stevie Wonder",
            freeform_album_title="Talking Book",
            freeform_track_title='You Are The Sunshine Of My Life',
            freeform_label='Warner Bros.',
        )
        track.put()

        trk = PlaylistTrack.all().filter('playlist =', playlist_key)
        self.assertEqual(trk[0].artist_name, 'Stevie Wonder')
        playlist_key = chirp_playlist_key()  # from cache
        trk = PlaylistTrack.all().filter('playlist =', playlist_key)
        self.assertEqual(trk[0].artist_name, 'Stevie Wonder')
Beispiel #6
0
 def get_json(self):
     playlist_key = chirp_playlist_key()
     recent_tracks = list(PlaylistTrack.all().filter(
         'playlist =', playlist_key).order('-established').fetch(6))
     return {
         'now_playing': self.track_as_data(recent_tracks.pop(0)),
         # Last 5 played tracks:
         'recently_played': [self.track_as_data(t) for t in recent_tracks]
     }
def filter_playlist_events_by_date_range(from_date, to_date):
    fd = datetime(from_date.year, from_date.month, from_date.day, 0, 0, 0)
    td = datetime(to_date.year, to_date.month, to_date.day, 23, 59, 59)
    playlist = chirp_playlist_key()
    pl = PlaylistEvent.all().filter('playlist =', playlist)
    pl = pl.filter('established >=', fd)
    pl = pl.filter('established <=', td)
    pl = pl.order('-established')
    return pl
Beispiel #8
0
 def get_json(self):
     playlist_key = chirp_playlist_key()
     recent_tracks = list(PlaylistTrack.all()
                             .filter('playlist =', playlist_key)
                             .order('-established')
                             .fetch(6))
     return {
         'now_playing': self.track_as_data(recent_tracks.pop(0)),
         # Last 5 played tracks:
         'recently_played': [self.track_as_data(t) for t in recent_tracks]
     }
 def __init__(self, data=None, current_user=None, playlist=None):
     self.current_user = current_user
     self.playlist = playlist or chirp_playlist_key()
     super(PlaylistTrackForm, self).__init__(data=data)
Beispiel #10
0
 def __init__(self, data=None, current_user=None, playlist=None):
     self.current_user = current_user
     self.playlist = playlist or chirp_playlist_key()
     super(PlaylistTrackForm, self).__init__(data=data)