bgneal@60
|
1 """
|
bgneal@60
|
2 Models for the videos app.
|
bgneal@60
|
3
|
bgneal@60
|
4 """
|
bgneal@60
|
5 from django.db import models
|
bgneal@60
|
6
|
bgneal@60
|
7
|
bgneal@60
|
8 # The whole purpose of this application is to shuffle the videos in
|
bgneal@60
|
9 # a YouTube playlist.
|
bgneal@60
|
10 #
|
bgneal@60
|
11 # We'd like to embed a video player to show videos from all the bands that
|
bgneal@60
|
12 # participated in the compilation. So we create a YouTube playlist with a long
|
bgneal@60
|
13 # list of videos. YouTube no longer offers a way to shuffle the playlist via
|
bgneal@60
|
14 # the embed code. Instead we will use the YouTube Javascript API to accomplish
|
bgneal@60
|
15 # this. However, the Javascript API works off of video IDs. So we now need
|
bgneal@60
|
16 # a way to obtain all the video IDs from a YouTube playlist. This model
|
bgneal@60
|
17 # stores the playlist URL and an admin function can be run to retrieve the
|
bgneal@60
|
18 # video ID list via the Python GData YouTube API. The video list is also
|
bgneal@60
|
19 # stored in this model. The view function can then read the video ID list,
|
bgneal@60
|
20 # randomize it, and give it to the template to build the appropriate
|
bgneal@60
|
21 # Javascript.
|
bgneal@60
|
22
|
bgneal@60
|
23 class Playlist(models.Model):
|
bgneal@60
|
24 """
|
bgneal@60
|
25 This model stores a YouTube playlist URL and a list of video IDs that
|
bgneal@60
|
26 make up the playlist.
|
bgneal@60
|
27
|
bgneal@60
|
28 """
|
bgneal@60
|
29 playlist_title = models.CharField(max_length=128, blank=True)
|
bgneal@60
|
30 playlist_url = models.URLField()
|
bgneal@60
|
31 video_list = models.TextField(blank=True)
|
bgneal@60
|
32 sync_date = models.DateTimeField(null=True, blank=True)
|
bgneal@60
|
33
|
bgneal@60
|
34 def __unicode__(self):
|
bgneal@60
|
35 if self.playlist_title:
|
bgneal@60
|
36 return self.playlist_title
|
bgneal@60
|
37
|
bgneal@60
|
38 return u"(Please sync with YouTube to retrieve the videos)"
|