Monday 15 August 2011

YouTube API v2 /feeds/api/videos/VIDEOID fails after 200+ requests: 400 Bad Request -


About 7,000 videos have been published to me and 500 of them need to be 'unlisted'. First of all, I want to run a list of those videos and want to see their current 'access' action "listed" status.

I use the YouTube V2 API, an OAuth authentication for my content. Then I loop in the list of video IDs with this query:

  url = 'http://gdata.youtube.com/feeds/api/videos/' + youtube_id + 'alt = Json '  

And after about 214 requests, all subsequent people fail:

   & Lt; BODY BGCOLOR = "#FFFFFF" TEXT = "# 000000" & gt; & Lt; H1 & gt; Bad request & lt; / H1> & Lt; H2 & gt; 400 error & lt; / H2> & Lt; / Body & gt; & Lt; / Html & gt; Header = {'Status':' 400 ',' Content-Length ':' 145 ',' x-xss-protection ':' 1; 'Server': 'GSE', 'Cash-Control', 'X-Content-Type-Options':' Nozif ',' Finished ':' Venus, 21 June 2013 20:08:28 GMT: 'Private' , Max-age = 0 ',' date ':' Venus, 21 June 2013 20:08:28 GMT ',' X-frame-option ':' samomigin ',' content-type ':' text / html; Charset = UTF-8 '}   

There is no description about why, and the remaining ~ 300, unsuccessful.

This is repeatable, if I run it again after 214 and again if I start through the sequence, except for the first 212, it will die on 426th video. So this video is not # 215, whose problem is in isolation.

It seems like I'm reaching a quota, but we have been hit by it, and the API console does not show us anywhere near our border

Any thoughts?

I have not started making changes yet, so it is worrying. Thank you.

Before running the questions against the API, I logged into the OAUTH and created an HTTP request Was the object. My decision was made to request again from time to time, which I now do every 10th query - it seems enough.

FWW, My Authentication Magazine (based on examples of Pausnik) and speaks like this: Class YouTubeV2 (object): "API" authenticated to 2 Doing and stuffing we can not do with V3, such as caption "" "OAUTH_CCPE =" https://gdata.youtube.com "def __init __ (auto, client_id, client_cent, developer_key):" oh is authentic Creates the 'http' attribute to create a .request () Come to the customer, contact the customer: Get developer_key from http://code.google.com/apis/Console: http://code.google.com/apis/youtube/dashboard "#" This article code is normal And should be used for any API22 call. Self.client_id = client_id self.client_secret = client_secret self.developer_key = developer_key self.headers = {'GData-Version': '2', 'X-GData-key': 'key =% s'% self.developer_key} storage = Warehouse ("% s-oauth"% sys.argv [0]) self.credentials = store.get () If there are no self credentials or self.credentials.invalid: # If there are no valid cached credentials, then # Users through the OAuth2 login flow, and after completing # credentials, trust the client library to cache. Flow = OAuth2WebServerFlow (client_id = self.client_id, client_secret = self.client_secret, scope = self.OAUTH_SCOPE, user_agent = sys.argv [0]) self.credentials = runs (flow, storage) self.http = self.credentials.authorize (Httplib2.Http ()) yt2 = YouTubeV2 (client_id, client_secret, developer_key)

No comments:

Post a Comment