PageRenderTime 33ms CodeModel.GetById 2ms app.highlight 26ms RepoModel.GetById 1ms app.codeStats 0ms

/gdata/youtube/data.py

http://radioappz.googlecode.com/
Python | 477 lines | 436 code | 20 blank | 21 comment | 0 complexity | 34b472c2eae2b392335a55545a489198 MD5 | raw file
  1#!/usr/bin/python
  2#
  3# Copyright (C) 2009 Google Inc.
  4#
  5# Licensed under the Apache License, Version 2.0 (the "License");
  6# you may not use this file except in compliance with the License.
  7# You may obtain a copy of the License at
  8#
  9#      http://www.apache.org/licenses/LICENSE-2.0
 10#
 11# Unless required by applicable law or agreed to in writing, software
 12# distributed under the License is distributed on an "AS IS" BASIS,
 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14# See the License for the specific language governing permissions and
 15# limitations under the License.
 16
 17
 18"""Contains the data classes of the YouTube Data API"""
 19
 20
 21__author__ = 'j.s@google.com (Jeff Scudder)'
 22
 23
 24import atom.core
 25import atom.data
 26import gdata.data
 27import gdata.geo.data
 28import gdata.media.data
 29import gdata.opensearch.data
 30import gdata.youtube.data
 31
 32
 33YT_TEMPLATE = '{http://gdata.youtube.com/schemas/2007/}%s'
 34
 35
 36class ComplaintEntry(gdata.data.GDEntry):
 37  """Describes a complaint about a video"""
 38
 39
 40class ComplaintFeed(gdata.data.GDFeed):
 41  """Describes complaints about a video"""
 42  entry = [ComplaintEntry]
 43
 44
 45class RatingEntry(gdata.data.GDEntry):
 46  """A rating about a video"""
 47  rating = gdata.data.Rating
 48
 49
 50class RatingFeed(gdata.data.GDFeed):
 51  """Describes ratings for a video"""
 52  entry = [RatingEntry]
 53
 54
 55class YouTubeMediaContent(gdata.media.data.MediaContent):
 56  """Describes a you tube media content"""
 57  _qname = gdata.media.data.MEDIA_TEMPLATE % 'content'
 58  format = 'format'
 59
 60
 61class YtAge(atom.core.XmlElement):
 62  """User's age"""
 63  _qname = YT_TEMPLATE % 'age'
 64
 65
 66class YtBooks(atom.core.XmlElement):
 67  """User's favorite books"""
 68  _qname = YT_TEMPLATE % 'books'
 69
 70
 71class YtCompany(atom.core.XmlElement):
 72  """User's company"""
 73  _qname = YT_TEMPLATE % 'company'
 74
 75
 76class YtDescription(atom.core.XmlElement):
 77  """Description"""
 78  _qname = YT_TEMPLATE % 'description'
 79
 80
 81class YtDuration(atom.core.XmlElement):
 82  """Video duration"""
 83  _qname = YT_TEMPLATE % 'duration'
 84  seconds = 'seconds'
 85
 86
 87class YtFirstName(atom.core.XmlElement):
 88  """User's first name"""
 89  _qname = YT_TEMPLATE % 'firstName'
 90
 91
 92class YtGender(atom.core.XmlElement):
 93  """User's gender"""
 94  _qname = YT_TEMPLATE % 'gender'
 95
 96
 97class YtHobbies(atom.core.XmlElement):
 98  """User's hobbies"""
 99  _qname = YT_TEMPLATE % 'hobbies'
100
101
102class YtHometown(atom.core.XmlElement):
103  """User's hometown"""
104  _qname = YT_TEMPLATE % 'hometown'
105
106
107class YtLastName(atom.core.XmlElement):
108  """User's last name"""
109  _qname = YT_TEMPLATE % 'lastName'
110
111
112class YtLocation(atom.core.XmlElement):
113  """Location"""
114  _qname = YT_TEMPLATE % 'location'
115
116
117class YtMovies(atom.core.XmlElement):
118  """User's favorite movies"""
119  _qname = YT_TEMPLATE % 'movies'
120
121
122class YtMusic(atom.core.XmlElement):
123  """User's favorite music"""
124  _qname = YT_TEMPLATE % 'music'
125
126
127class YtNoEmbed(atom.core.XmlElement):
128  """Disables embedding for the video"""
129  _qname = YT_TEMPLATE % 'noembed'
130
131
132class YtOccupation(atom.core.XmlElement):
133  """User's occupation"""
134  _qname = YT_TEMPLATE % 'occupation'
135
136
137class YtPlaylistId(atom.core.XmlElement):
138  """Playlist id"""
139  _qname = YT_TEMPLATE % 'playlistId'
140
141
142class YtPosition(atom.core.XmlElement):
143  """Video position on the playlist"""
144  _qname = YT_TEMPLATE % 'position'
145
146
147class YtPrivate(atom.core.XmlElement):
148  """Flags the entry as private"""
149  _qname = YT_TEMPLATE % 'private'
150
151
152class YtQueryString(atom.core.XmlElement):
153  """Keywords or query string associated with a subscription"""
154  _qname = YT_TEMPLATE % 'queryString'
155
156
157class YtRacy(atom.core.XmlElement):
158  """Mature content"""
159  _qname = YT_TEMPLATE % 'racy'
160
161
162class YtRecorded(atom.core.XmlElement):
163  """Date when the video was recorded"""
164  _qname = YT_TEMPLATE % 'recorded'
165
166
167class YtRelationship(atom.core.XmlElement):
168  """User's relationship status"""
169  _qname = YT_TEMPLATE % 'relationship'
170
171
172class YtSchool(atom.core.XmlElement):
173  """User's school"""
174  _qname = YT_TEMPLATE % 'school'
175
176
177class YtStatistics(atom.core.XmlElement):
178  """Video and user statistics"""
179  _qname = YT_TEMPLATE % 'statistics'
180  favorite_count = 'favoriteCount'
181  video_watch_count = 'videoWatchCount'
182  view_count = 'viewCount'
183  last_web_access = 'lastWebAccess'
184  subscriber_count = 'subscriberCount'
185
186
187class YtStatus(atom.core.XmlElement):
188  """Status of a contact"""
189  _qname = YT_TEMPLATE % 'status'
190
191
192class YtUserProfileStatistics(YtStatistics):
193  """User statistics"""
194  _qname = YT_TEMPLATE % 'statistics'
195
196
197class YtUsername(atom.core.XmlElement):
198  """Youtube username"""
199  _qname = YT_TEMPLATE % 'username'
200
201
202class FriendEntry(gdata.data.BatchEntry):
203  """Describes a contact in friend list"""
204  username = YtUsername
205  status = YtStatus
206  email = gdata.data.Email
207
208
209class FriendFeed(gdata.data.BatchFeed):
210  """Describes user's friends"""
211  entry = [FriendEntry]
212
213
214class YtVideoStatistics(YtStatistics):
215  """Video statistics"""
216  _qname = YT_TEMPLATE % 'statistics'
217
218
219class ChannelEntry(gdata.data.GDEntry):
220  """Describes a video channel"""
221
222
223class ChannelFeed(gdata.data.GDFeed):
224  """Describes channels"""
225  entry = [ChannelEntry]
226
227
228class FavoriteEntry(gdata.data.BatchEntry):
229  """Describes a favorite video"""
230
231
232class FavoriteFeed(gdata.data.BatchFeed):
233  """Describes favorite videos"""
234  entry = [FavoriteEntry]
235
236
237class YouTubeMediaCredit(gdata.media.data.MediaCredit):
238  """Describes a you tube media credit"""
239  _qname = gdata.media.data.MEDIA_TEMPLATE % 'credit'
240  type = 'type'
241
242
243class YouTubeMediaRating(gdata.media.data.MediaRating):
244  """Describes a you tube media rating"""
245  _qname = gdata.media.data.MEDIA_TEMPLATE % 'rating'
246  country = 'country'
247
248
249class YtAboutMe(atom.core.XmlElement):
250  """User's self description"""
251  _qname = YT_TEMPLATE % 'aboutMe'
252
253
254class UserProfileEntry(gdata.data.BatchEntry):
255  """Describes an user's profile"""
256  relationship = YtRelationship
257  description = YtDescription
258  location = YtLocation
259  statistics = YtUserProfileStatistics
260  school = YtSchool
261  music = YtMusic
262  first_name = YtFirstName
263  gender = YtGender
264  occupation = YtOccupation
265  hometown = YtHometown
266  company = YtCompany
267  movies = YtMovies
268  books = YtBooks
269  username = YtUsername
270  about_me = YtAboutMe
271  last_name = YtLastName
272  age = YtAge
273  thumbnail = gdata.media.data.MediaThumbnail
274  hobbies = YtHobbies
275
276
277class UserProfileFeed(gdata.data.BatchFeed):
278  """Describes a feed of user's profile"""
279  entry = [UserProfileEntry]
280
281
282class YtAspectRatio(atom.core.XmlElement):
283  """The aspect ratio of a media file"""
284  _qname = YT_TEMPLATE % 'aspectRatio'
285
286
287class YtBasePublicationState(atom.core.XmlElement):
288  """Status of an unpublished entry"""
289  _qname = YT_TEMPLATE % 'state'
290  help_url = 'helpUrl'
291
292
293class YtPublicationState(YtBasePublicationState):
294  """Status of an unpublished video"""
295  _qname = YT_TEMPLATE % 'state'
296  name = 'name'
297  reason_code = 'reasonCode'
298
299
300class YouTubeAppControl(atom.data.Control):
301  """Describes a you tube app control"""
302  _qname = (atom.data.APP_TEMPLATE_V1 % 'control',
303      atom.data.APP_TEMPLATE_V2 % 'control')
304  state = YtPublicationState
305
306
307class YtCaptionPublicationState(YtBasePublicationState):
308  """Status of an unpublished caption track"""
309  _qname = YT_TEMPLATE % 'state'
310  reason_code = 'reasonCode'
311  name = 'name'
312
313
314class YouTubeCaptionAppControl(atom.data.Control):
315  """Describes a you tube caption app control"""
316  _qname = atom.data.APP_TEMPLATE_V2 % 'control'
317  state = YtCaptionPublicationState
318
319
320class CaptionTrackEntry(gdata.data.GDEntry):
321  """Describes a caption track"""
322
323
324class CaptionTrackFeed(gdata.data.GDFeed):
325  """Describes caption tracks"""
326  entry = [CaptionTrackEntry]
327
328
329class YtCountHint(atom.core.XmlElement):
330  """Hint as to how many entries the linked feed contains"""
331  _qname = YT_TEMPLATE % 'countHint'
332
333
334class PlaylistLinkEntry(gdata.data.BatchEntry):
335  """Describes a playlist"""
336  description = YtDescription
337  playlist_id = YtPlaylistId
338  count_hint = YtCountHint
339  private = YtPrivate
340
341
342class PlaylistLinkFeed(gdata.data.BatchFeed):
343  """Describes list of playlists"""
344  entry = [PlaylistLinkEntry]
345
346
347class YtModerationStatus(atom.core.XmlElement):
348  """Moderation status"""
349  _qname = YT_TEMPLATE % 'moderationStatus'
350
351
352class YtPlaylistTitle(atom.core.XmlElement):
353  """Playlist title"""
354  _qname = YT_TEMPLATE % 'playlistTitle'
355
356
357class SubscriptionEntry(gdata.data.BatchEntry):
358  """Describes user's channel subscritpions"""
359  count_hint = YtCountHint
360  playlist_title = YtPlaylistTitle
361  thumbnail = gdata.media.data.MediaThumbnail
362  username = YtUsername
363  query_string = YtQueryString
364  playlist_id = YtPlaylistId
365
366
367class SubscriptionFeed(gdata.data.BatchFeed):
368  """Describes list of user's video subscriptions"""
369  entry = [SubscriptionEntry]
370
371
372class YtSpam(atom.core.XmlElement):
373  """Indicates that the entry probably contains spam"""
374  _qname = YT_TEMPLATE % 'spam'
375
376
377class CommentEntry(gdata.data.BatchEntry):
378  """Describes a comment for a video"""
379  spam = YtSpam
380
381
382class CommentFeed(gdata.data.BatchFeed):
383  """Describes comments for a video"""
384  entry = [CommentEntry]
385
386
387class YtUploaded(atom.core.XmlElement):
388  """Date/Time at which the video was uploaded"""
389  _qname = YT_TEMPLATE % 'uploaded'
390
391
392class YtVideoId(atom.core.XmlElement):
393  """Video id"""
394  _qname = YT_TEMPLATE % 'videoid'
395
396
397class YouTubeMediaGroup(gdata.media.data.MediaGroup):
398  """Describes a you tube media group"""
399  _qname = gdata.media.data.MEDIA_TEMPLATE % 'group'
400  videoid = YtVideoId
401  private = YtPrivate
402  duration = YtDuration
403  aspect_ratio = YtAspectRatio
404  uploaded = YtUploaded
405
406
407class VideoEntryBase(gdata.data.GDEntry):
408  """Elements that describe or contain videos"""
409  group = YouTubeMediaGroup
410  statistics = YtVideoStatistics
411  racy = YtRacy
412  recorded = YtRecorded
413  where = gdata.geo.data.GeoRssWhere
414  rating = gdata.data.Rating
415  noembed = YtNoEmbed
416  location = YtLocation
417  comments = gdata.data.Comments
418
419
420class PlaylistEntry(gdata.data.BatchEntry):
421  """Describes a video in a playlist"""
422  description = YtDescription
423  position = YtPosition
424
425
426class PlaylistFeed(gdata.data.BatchFeed):
427  """Describes videos in a playlist"""
428  private = YtPrivate
429  group = YouTubeMediaGroup
430  playlist_id = YtPlaylistId
431  entry = [PlaylistEntry]
432
433
434class VideoEntry(gdata.data.BatchEntry):
435  """Describes a video"""
436
437
438class VideoFeed(gdata.data.BatchFeed):
439  """Describes a video feed"""
440  entry = [VideoEntry]
441
442
443class VideoMessageEntry(gdata.data.BatchEntry):
444  """Describes a video message"""
445  description = YtDescription
446
447
448class VideoMessageFeed(gdata.data.BatchFeed):
449  """Describes videos in a videoMessage"""
450  entry = [VideoMessageEntry]
451
452
453class UserEventEntry(gdata.data.GDEntry):
454  """Describes a user event"""
455  playlist_id = YtPlaylistId
456  videoid = YtVideoId
457  username = YtUsername
458  query_string = YtQueryString
459  rating = gdata.data.Rating
460
461
462class UserEventFeed(gdata.data.GDFeed):
463  """Describes list of events"""
464  entry = [UserEventEntry]
465
466
467class VideoModerationEntry(gdata.data.GDEntry):
468  """Describes video moderation"""
469  moderation_status = YtModerationStatus
470  videoid = YtVideoId
471
472
473class VideoModerationFeed(gdata.data.GDFeed):
474  """Describes a video moderation feed"""
475  entry = [VideoModerationEntry]
476
477