コード例 #1
0
 def post(self, playlist_id):
     yt_service_for_owner = youtubeutils.create_youtube_service(
         self.owner_oauth_token)
     response = yt_service_for_owner.DeletePlaylistVideoEntry(
         self.playlist_uri, self.playlist_entry_id)
     assert response
     youtubeutils.write_playlist(self, yt_service_for_owner, playlist_id,
                                 channelutils.notify_playlist_listeners)
コード例 #2
0
 def post(self, playlist_id):
     position = int(self.request.get("position"))
     yt_service_for_owner = youtubeutils.create_youtube_service(
         self.owner_oauth_token)
     response = yt_service_for_owner.UpdatePlaylistVideoEntryMetaData(
         self.playlist_uri, self.playlist_entry_id, None, None, position)
     assert response
     youtubeutils.write_playlist(self, yt_service_for_owner, playlist_id,
                                 channelutils.notify_playlist_listeners)
コード例 #3
0
 def post(self, playlist_id):
   position = int(self.request.get("position"))
   yt_service_for_owner = youtubeutils.create_youtube_service(
     self.owner_oauth_token)
   response = yt_service_for_owner.UpdatePlaylistVideoEntryMetaData(
     self.playlist_uri, self.playlist_entry_id, None, None, position)
   assert response
   youtubeutils.write_playlist(self, yt_service_for_owner, playlist_id,
                               channelutils.notify_playlist_listeners)
コード例 #4
0
 def post(self, playlist_id):
   video_id = self.request.get("video_id")
   position = self.request.get("position", None)
   playlist_url = youtubeutils.PLAYLIST_URL_PREFIX + playlist_id
   yt_service_for_owner = youtubeutils.create_youtube_service(
     self.owner_oauth_token)
   response = youtubeutils.add_video_to_playlist(yt_service_for_owner,
                                                 playlist_url, video_id,
                                                 position)
   assert response
   youtubeutils.write_playlist(self, yt_service_for_owner, playlist_id,
                               channelutils.notify_playlist_listeners)
コード例 #5
0
 def post(self, playlist_id):
     video_id = self.request.get("video_id")
     position = self.request.get("position", None)
     playlist_url = youtubeutils.PLAYLIST_URL_PREFIX + playlist_id
     yt_service_for_owner = youtubeutils.create_youtube_service(
         self.owner_oauth_token)
     response = youtubeutils.add_video_to_playlist(yt_service_for_owner,
                                                   playlist_url, video_id,
                                                   position)
     assert response
     youtubeutils.write_playlist(self, yt_service_for_owner, playlist_id,
                                 channelutils.notify_playlist_listeners)
コード例 #6
0
 def get(self):
   yt_service = youtubeutils.create_youtube_service(
     self.oauth2_decorator.credentials.access_token)
   (feed, entries) = youtubeutils.fetch_feed_and_entries(
     yt_service.GetYouTubePlaylistFeed, username="******")
   playlists_from_datastore = model.PlaylistMetadata.gql(
     "WHERE owner = :1", users.get_current_user())
   playlist_ids = set(i.playlist_id for i in playlists_from_datastore)
   playlists = []
   for entry in entries:
     id_from_uri = youtubeutils.get_id_from_uri(entry)
     if id_from_uri in playlist_ids:
       playlists.append(dict(id=id_from_uri, title=entry.title.text,
                             num_videos=entry.feed_link[0].count_hint))
   webutils.render_to_response(self, "playlists.html",
                               dict(playlists=playlists))
コード例 #7
0
 def get(self):
     yt_service = youtubeutils.create_youtube_service(
         self.oauth2_decorator.credentials.access_token)
     (feed, entries) = youtubeutils.fetch_feed_and_entries(
         yt_service.GetYouTubePlaylistFeed, username="******")
     playlists_from_datastore = model.PlaylistMetadata.gql(
         "WHERE owner = :1", users.get_current_user())
     playlist_ids = set(i.playlist_id for i in playlists_from_datastore)
     playlists = []
     for entry in entries:
         id_from_uri = youtubeutils.get_id_from_uri(entry)
         if id_from_uri in playlist_ids:
             playlists.append(
                 dict(id=id_from_uri,
                      title=entry.title.text,
                      num_videos=entry.feed_link[0].count_hint))
     webutils.render_to_response(self, "playlists.html",
                                 dict(playlists=playlists))
コード例 #8
0
 def post(self):
   errors = webutils.require_params(self, PLAYLIST_PARAMS)
   if errors:
     return self.get(dict(errors=errors))
   yt_service = youtubeutils.create_youtube_service(
     self.oauth2_decorator.credentials.access_token)
   try:
     # Make the playlist public so that the other partygoers have access to
     # watch it.
     playlist = yt_service.AddPlaylist(self.request.get("name"),
                                       self.request.get("description"), False)
   except RequestError, e:
     if e.args[0]["status"] != 400:
       raise
     error = "Could not create playlist: %s" % e.args[0]["body"]
     reason = e.args[0]["reason"].strip()
     if reason:
       error += ": %s" % reason
     return self.get(dict(errors=[error]))
コード例 #9
0
 def post(self):
     errors = webutils.require_params(self, PLAYLIST_PARAMS)
     if errors:
         return self.get(dict(errors=errors))
     yt_service = youtubeutils.create_youtube_service(
         self.oauth2_decorator.credentials.access_token)
     try:
         # Make the playlist public so that the other partygoers have access to
         # watch it.
         playlist = yt_service.AddPlaylist(self.request.get("name"),
                                           self.request.get("description"),
                                           False)
     except RequestError, e:
         if e.args[0]["status"] != 400:
             raise
         error = "Could not create playlist: %s" % e.args[0]["body"]
         reason = e.args[0]["reason"].strip()
         if reason:
             error += ": %s" % reason
         return self.get(dict(errors=[error]))
コード例 #10
0
 def get(self):
   """Return an HTML fragment of YT search results."""
   q = self.request.get("q")
   yt_service = youtubeutils.create_youtube_service()
   query = gdata.youtube.service.YouTubeVideoQuery()
   query.vq = q
   results_feed = yt_service.YouTubeQuery(query)
   video_list = [
     dict(id=youtubeutils.get_id_from_uri(i),
          title=i.media.title.text,
          description=i.media.description.text,
          duration=youtubeutils.parse_duration_seconds(
            i.media.duration.seconds),
          thumbnail=i.media.thumbnail[1].url,
          embeddable=youtubeutils.is_embeddable(i.media.content))
     for i in results_feed.entry
   ]
   template_params = {"button_name": "Add", "class_name": "search-item",
                      "video_list": video_list}
   webutils.render_to_response(self, "video_list.html", template_params)
コード例 #11
0
    def get(self, playlist_id):
        friend_list = friendlistutils.render_friend_list(playlist_id, self.people)
        template_params = {"button_name": "Remove", "class_name": "playlist-item", "friend_list": friend_list}
        yt_service_for_owner = youtubeutils.create_youtube_service(self.owner_oauth_token)
        (playlist, entries) = youtubeutils.fetch_feed_and_entries(
            yt_service_for_owner.GetYouTubePlaylistVideoFeed, playlist_id=playlist_id
        )

        edit_playlist_url = "%s/playlists/edit/%s?%s" % (
            self.request.host_url,
            self.playlist_metadata.playlist_id,
            urllib.urlencode({"uuid": self.playlist_metadata.uuid}),
        )
        welcome_page_url = re.sub(r"/edit/", r"/welcome/", edit_playlist_url, 1)

        template_params["title"] = playlist.title.text
        template_params["description"] = playlist.subtitle.text
        template_params["quoted_playlist_id"] = simplejson.dumps(playlist_id)
        template_params["playlist_id"] = playlist_id
        template_params["video_list"] = youtubeutils.prepare_playlist(entries)
        template_params["quoted_edit_url"] = simplejson.dumps(edit_playlist_url)
        template_params["quoted_uuid"] = simplejson.dumps(self.playlist_metadata.uuid)
        template_params["welcome_page_url"] = welcome_page_url
        webutils.render_to_response(self, "edit_playlist.html", template_params)
コード例 #12
0
  def get(self, playlist_id):
    friend_list = friendlistutils.render_friend_list(playlist_id, self.people)
    template_params = {"button_name": "Remove", "class_name": "playlist-item",
                       "friend_list": friend_list}
    yt_service_for_owner = youtubeutils.create_youtube_service(
      self.owner_oauth_token)
    (playlist, entries) = youtubeutils.fetch_feed_and_entries(
      yt_service_for_owner.GetYouTubePlaylistVideoFeed, playlist_id=playlist_id)

    edit_playlist_url = "%s/playlists/edit/%s?%s" % (
      self.request.host_url, self.playlist_metadata.playlist_id,
      urllib.urlencode({"uuid": self.playlist_metadata.uuid}))
    welcome_page_url = re.sub(r"/edit/", r"/welcome/", edit_playlist_url, 1)
    
    template_params["title"] = playlist.title.text
    template_params["description"] = playlist.subtitle.text
    template_params["quoted_playlist_id"] = simplejson.dumps(playlist_id)
    template_params["playlist_id"] = playlist_id
    template_params["video_list"] = youtubeutils.prepare_playlist(entries)
    template_params["quoted_edit_url"] = simplejson.dumps(edit_playlist_url)
    template_params["quoted_uuid"] = simplejson.dumps(
      self.playlist_metadata.uuid)
    template_params["welcome_page_url"] = welcome_page_url
    webutils.render_to_response(self, "edit_playlist.html", template_params)