Closed Captions in YouTube as JSON - youtube-api

Is there a way to get closed captions in a youtube clip as json ? I read passing "alt=json" should work, but it doesn't seem to. Any idea ? Also does the CC also work when it is done via translation ? For example
curl "http://www.youtube.com/api/timedtext?v=V6Tsrg_EQMw&lang=en" doesn't return anything (though the clip does have CC)

There currently is no supported API for retrieving closed caption tracks for arbitrary videos. (You might be able to reverse-engineer some methods of getting that data, but it's not supported and I can't encourage doing that.)
The officially supported methods for working with captions are for v2 of the YouTube Data API and are documented at https://developers.google.com/youtube/2.0/developers_guide_protocol_captions
Only an authenticated request as the owner of a given video will expose the list of caption tracks and allow you to download them in .srt or .sub format (not JSON).
I would expect that at some point there will be methods for interacting with captions in v3 of the API, but unfortunately I don't have any specific information to share about when that might happen.

Use youtube-dl to download the captions (as either srt, ass, vtt, or lrc).
Use TranscribeFiles' Online Captions & Subtitles Converter to convert to any of 11 different json schemas.

Related

Localization in PlaylistItems YouTube API

I have an application that uses the YouTube API to display a list of playlists and videos from a particular YouTube Channel. The application supports multiple languages so I also used the localizations feature YouTube API offers and it works great with v3/videos and v3/playlists using the hl param, but the only problem I faced was with v3/playlistItems as it doesn't have support for localizations.
Please help me in adding localizations using v3/playlistItems so that all videos under a particular playlist displays localized title and description.
An ugly work around is to send two requests. First fetch the video-ids by using v3/playlistItems, then use v3/videos with the video-ids separated by comma, to get the translation with the available hl param.
There is currently no indicated way of doing this from the PlaylistItems docs. Try filing for a feature request here.

Uploading a video to youtube from my swift app

I've been asked to integrate videos into an existing app which previously only let users upload posts with images.
I don't want to host the videos on my own server for the following reasons:
Server Bandwidth
File Size Limits and Storage Space
Slow-Loading Video or Unexpected Pauses During Playback
Issues with converting to specific formats
Piracy
Based off this article:
https://www.wp101.com/10-reasons-why-you-should-never-host-your-own-videos/
So I tried to research into where I could host the files and then I would simply have to store the URL in my db and use a video player to stream the content.
Vimeo and youtube seemed to be the main options I could find.
I'm wondering how best to implement, would I make use of a youtube API and on successful upload, grab the link and upload to my own server? I'm concerned this may be a long process for the end user.
Another problem is I can't see any swift examples (ZERO obj-c experience) of making the http request but perhaps it is still possible but I'd just have to write the code myself? I'm wondering if anyone has implemented anything like this already as I can't find any examples.
Looking at this question:
How do I upload a video to YouTube from within an iOS application?
None of the links in the comments work and the answer directs to the youtube 2.0 API and I'm concerned that this is now deprecated.
Any advice appreciated!

YouTube live streaming captions - more than one language

I'm currently live streaming a tv channel (beta phase yet) using YouTube.
How do I add captions in more than 1 language for a live stream (with POST caption URL)?
Even using just one language captions, how can I change the language? (The only option to the user - on web or app - is "EN" even if the caption is in other language)
When using POST approach do send captions on live streams how/where to set/define duration of each subtitle?
Please don't refer this url link. I know it already.
AFAIK you can do only one language, if any at all. I have tried using the POST method YouTube describes on the page you link to - without success. Only get
Result 299: "Error donwloading [...] Can't parse HTTP POST body."
Tried searching all kinds of support forums, but it seems no one has any advice and YouTube never replies to questions related to live caption. Including here...
According to the docs on contentDetails.closedCaptionsType, you can embed captions in your video stream using the option closedCaptionsEmbedded and provide EIA-608 and/or CEA-708 formatted captions in your video from your encoder.
Sending multiple caption tracks muxed with your video with different languages specified by the "Language" tag on the caption stream should allow the user to switch between different captions in the web player.

YouTube API Search by Tags

I'm trying to add videos to an existing ASP.NET MVC site, and I'd like to show videos from our YouTube channel.
I have added a tag to each video to indicate what page it should appear on. I had thought that I could search our channel by tag on each page to render the relevant video on that page.
I'm trying to exclusively use the API v3, but it seems I can't do this.
I can't use developer tags, because videos are uploaded by multiple users using the standard YouTube front end. This seems like basic functionality, so I'm assuming it's my inexperience with this API.
As an example, our YouTube channel is ChillinWithCharlie. During development, one video is tagged 20141213Cheneys.
I can get all videos in our channel, but is there a way to query the v3 API to retrieve just this video?
I've seen one suggestion here that I retrieve all videos, and filter in code. This feels inefficient, so I'd rather not do this, but I can't even see where the tag is returned with all channel videos, that I could interrogate in code.
It's not just you. There seems to be no specific query parameter to search by tag with API v3.
I would recommend doing a search with your tag in the 'q' (search) parameter, then checking the results to see if the tag exists in the returned snippet->tags property to verify the exact video.
Note YouTube tags are only visible to the video's uploader.
https://developers.google.com/youtube/v3/docs/videos#snippet.tags[]

How to know if a link is a video? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to determine if a given URL link is a video or image?
I'm building a forum and I want the facebook feature whereby when the user paste a video URL, i can automatically know its a video and display it differently??
You can check it's "mime type".
The way Facebook implemented requires quite a lot of computing power and may not be suitable for small scaled website.
After the user input the video URL, Facebook will proceed to determine if the URL belongs to a known host (such as Youtube, CollegeHumour). If the URL does not belong to a known host, Facebook will proceed to retrieve the page and determine the video parameters from the <meta> tags, according to what Facebook defines them to be.
However to keep things easy for you, maybe your forum can determine that if the URL is from Youtube, you can use Youtube's embed code to display the video.
This does not deal with MIME types, or video files directly. If it is video files, you will still need to proceed to fetch the headers of the video file, and determine what plugin or Flash player should display the video.

Resources