There's no way to do this for arbitrary videos. You can only retrieve caption tracks using the API for videos that belong to your authenticated account.
https://developers.google.com/youtube/2.0/developers_guide_protocol_captions
Cheers,
-Jeff Posnick, YouTube API Team
apiblog.youtube.com | Google+: http://goo.gl/bZflZ
On Sunday, June 24, 2012 7:32:05 PM UTC-4, Rucha Deshpande wrote:
Hello Jeffrey,Is there a similar way to retrieve already available caption track (generated by Google Voice Recognition) if we know the VIDEO_ID ?Rucha
On Monday, 29 November 2010 12:54:07 UTC-6, Jeffrey Posnick wrote:Hello Rajesh,
It's a coincidence, because I was just writing some new Java code to
handle caption track creation and I realized that the code you're
working from, which looks to be from YouTube Direct, isn't working
anymore. Here's a modified version of a portion of the code that
should now work:
GDataRequest request = service.createInsertRequest(new
URL(captionsUrl)); // http://gdata.youtube.com/feeds/api/videos/VIDEOID/ captions
request.setHeader("Content-Language", languageCode); // languageCode
should be a ISO 639-1 two letter code
request.setHeader("Content-Type", "application/
vnd.youtube.timedtext; charset=UTF-8");
request.getRequestStream().write(bytes); // get the caption track's
UTF-8 bytes via whatever method is appropriate
request.execute();
I'll probably update the YouTube Direct codebase in the near future.
Cheers,
-Jeff Posnick, YouTube API Team
~ YouTube is hiring! ~ http://google.com/jobs/workyoutube ~
On Nov 23, 12:15 pm, RajeshM <rajesh.maha...@gmail.com> wrote:
> Hi,
>
> I am getting 'Content is now allowed in prolog' error when I
> 'execute()' in the caption code (at the end). I successfully do a
> upload of the content and pass the correct videoid. The YouTubeService
> 'service' is a authenticated handle....
>
> Sorry, your upload was invalid:
> <errors xmlns='http://schemas.google.com/g/2005 '>
> <error>
> <domain>GData</domain>
> <code>ParseException</code>
> <internalReason>Content is not allowed in prolog.</internalReason>
> </error>
> </errors>
>
> com.google.gdata.util.InvalidEntryException: Content is not allowed in
> prolog.
> <errors xmlns='http://schemas.google.com/g/2005 '>
> <error>
> <domain>GData</domain>
> <code>ParseException</code>
> <internalReason>Content is not allowed in prolog.</internalReason>
> </error>
> </errors>
>
> at
> com.google.gdata.client.http.HttpGDataRequest. handleErrorResponse(HttpGData Request.java:
> 594)
> at
> com.google.gdata.client.http.GoogleGDataRequest. handleErrorResponse(GoogleG DataRequest.java:
> 563)
> at
> com.google.gdata.client.http.HttpGDataRequest. checkResponse(HttpGDataReques t.java:
> 552)
> at
> com.google.gdata.client.http.HttpGDataRequest.execute( HttpGDataRequest.java :
> 530)
> at
> com.google.gdata.client.http.GoogleGDataRequest.execute( GoogleGDataRequest. java:
> 535)
> at
> com.percussion.nhlbi.extensions. YouTubeUploadClient. updateCaptionTrack(YouT ubeUploadClient.java:
> 245)
> at
> com.percussion.nhlbi.extensions. YouTubeUploadClient.main( YouTubeUploadClien t.java:
> 375)
>
> static String caption = "0:01:23.000,0:01:25.000"+"\n"+
> "This text displays for two seconds starting"+"\n"+
> "1 minute and 23 seconds into the video.";
>
> public boolean updateCaptionTrack(YouTubeService service, String
> videoId, String captionTrack)
> throws MalformedURLException, IOException, ServiceException
> {
> System.out.println("Updating caption...");
> String captionsUrl = String.format(CAPTION_FEED_URL_FORMAT,
> videoId);
> GDataRequest request = service.createInsertRequest(new
> URL(captionsUrl));
> request.getRequestStream().write(captionTrack.getBytes(" UTF-8"));
> System.out.println("captions..." + captionsUrl);
> request.execute();
> System.out.println("executed");
> BufferedReader bufferedReader = new BufferedReader(new
> InputStreamReader(request.getResponseStream()));
> StringBuilder builder = new StringBuilder();
> String line = null;
> while ((line = bufferedReader.readLine()) != null)
> {
> builder.append(line + "\n");
> }
> bufferedReader.close();
> String responseBody = builder.toString();
> log.info("Response to captions request: " + responseBody);
> if (responseBody.contains(CAPTION_FAILURE_TAG))
> {
> return false;
> }
> return true;
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/youtube-api-gdata/-/KSyVRd85MaIJ.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
No comments:
Post a Comment