質問

書い申Pythonによる動画をユーザーのプレイリストイベントを開催しています。そこに、一つ一つの原因Youtubeを始動側の私です。

がバッチ処理形式のAPIを提出す50の要求を一度よく見からのドキュメントの提出方法は、一括処理します。に関する情報で、XMLコンテンツが送信されます。

なんかを提出しバッチ処理すか?

役に立ちましたか?

解決

このようになりますが文書化され、gdata ーション-クライアントのwiki: http://code.google.com/p/gdata-python-client/wiki/UsingBatchOperations.の例はこのページではベースおよびスプレッドシート、YouTubeではかなり簡単に技術のYouTube APIに含まれています。まいましたように、必要するとのことです。.phpがv2で増えたファイルAPIとなります。

他のヒント

私は物事を成し遂げるためにこの方法を管理してます:

query = "<feed xmlns=\"http://www.w3.org/2005/Atom\""
query += " xmlns:media=\"http://search.yahoo.com/mrss/\""
query += " xmlns:batch=\"http://schemas.google.com/gdata/batch\""
query += " xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">"
query += "<batch:operation type=\"query\"/>"

# Assume ids contain list of YouTube video IDs
for vid in ids:
   query += ("<entry><id>http://gdata.youtube.com/feeds/api/videos/%s</id></entry>" % vid)
query += "</feed>"

uri = 'http://gdata.youtube.com/feeds/api/videos/batch'

feed = client.Post( query, uri, converter=gdata.youtube.YouTubeVideoFeedFromString )

結果のフィードは、標準のユーチューブのAPIフィードとして反復することができます。 の:欠落している動画の特別なケアや他の <状態バッチ>が、 -esは注意する必要があります:

if len(feed.entry):
   for entry in feed.entry:
      skip = False
      for x in entry.extension_elements:
         if x.tag == "status" and x.namespace == "http://schemas.google.com/gdata/batch" and x.attributes["code"] != "200":
                if x.attributes["code"] == "404":
               skip = True
            # Likewize you can check for entry's 403 e.g. Quota Exceeded etc
      ... # Your entry processing goes here
scroll top