How to retrieve YouTube video id of videos from a channel (YouTube) - youtube-api

I am working in an android app which shows videos from a YouTube Channel.
I have the channel id and all other stuffs. But I need the video id to show the video in YouTube Player.
***eg. player.cueVideo("nCgQDjiotG0");***
When I go through the developer site again and again, I got this one -https://www.googleapis.com/youtube/v3/videos?part=id&chart=mostPopular&key={YOUR_API_KEY}
It is working perfectly returning the correct Video id to play. But I can't done it with my Channel id (There is no option for passing channel ID as parameter).
The only one url which accept the channel ID and returns snippet is this one -
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCxUtHtpGzd0bA5rYRY7h4VQ&q=PIVideoLibrary&type=channel&key={YOUR_API_KEY}
But the id it returning is not compatible with the above method. When I run it in the device it shows "Invalid Request" Here is screen shot which is the response of the above search request.
So this is my question.
How can we get video id of a video from a YouTube channel to show that
vedio in a youtube player integrated in the android app using YouTube
api v3
Thank You.

Ya I found it.
Go to youtube developer, https://developers.google.com/youtube/v3/docs/activities/list .
You can find a "TRY IT" field at middle of the page, fill the fields, you have to enter "contentDetails in the 'part' field to obtain video id. Then enter your channel id in the respective field. Execute the query, you can find the video id in the XML result.

Related

How to get YouTube channel's trailer and featured video via the Data API?

I'm trying to use the YouTube Data API to get a channel's Trailer and Featured Video but can't find anything in the [API docs][1] or responses that might provide it. Ideally, there'd be something that would return the ID of whichever videos had been selected here: https://studio.youtube.com/channel/[CHANNEL_ID]/editing/sections
Maybe it's buried in an obscure endpoint. Maybe the API simply doesn't include this anywhere. Can anyone please point me in the right direction?
Update: I've found the channel trailer as unsubscribedTrailer under the channels:list endpoint with the brandingSettings part. However, for some reason Google has decided not to include the featured video with it.
One more time YouTube Data API v3 doesn't provide a basic feature.
As Video spotlight you can have:
Featured video for returning subscribers
Highlight a video for your subscribers to watch. This video won’t be shown again at the top of your page for subscribers who have watched it. Learn more
Source: https://studio.youtube.com/channel/CHANNEL_ID/editing/sections
For the featured video:
you first need to subscribe to the give YouTube channel. To do so in an automatic way, use YouTube Data API v3 Subscriptions: insert endpoint.
then open your web-browser Network developer tool tab (Ctrl + Shift + E on FireFox) and filter HTML requests, then visit https://www.youtube.com/channel/CHANNEL_ID and copy the initial request to CHANNEL_ID as cURL, that way you can re-execute this cURL request for any channel you are subscribed to by changing the URL in the cURL request to https://www.youtube.com/channel/ANOTHER_CHANNEL_ID. Furthermore you'll find the featured video id in the JavaScript variable ytInitialData in the JSON entry
contents/twoColumnBrowseResultsRenderer/tabs/0/tabRenderer/content/sectionListRenderer/contents/0/itemSectionRenderer/contents/0/channelFeaturedContentRenderer/items/0/videoRenderer/videoId.
The channel with id UCv_LqFI-0vMVYgNR3TeB3zQ have both a channel trailer (1RHxvM8mQS4) and a featured video (rFuip5CSWcA).

YouTube API: why can't I see latest video for this channel?

The latest video for this channel shows up when viewed via the Youtube website:
https://www.youtube.com/user/stefbot/videos
(video ID a4pPLwAL_Qo)
However that video does not get returned when the channel is queried via the Youtube API. I retrieve the channel video list by making a call to channels, followed by a call to playlistItems e.g.:
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=stefbot&key=xxxxxxxxxxxxxxxxx
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUC3L8QaxqEGUiBC252GHy3w&key=xxxxxxxxxxxxxxxxxx
See playlist response JSON here
It has been more than 24hrs since this video was posted. Can someone explain why the API would not be returning the latest video for this channel?
Based from this support page, it can take a few days for uploaded videos to be reflected in YouTube search results, especially if you recently changed or removed your video. Also, you can use this reference and use Search: list to get the latest videos from user's uploads.
GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={CHANNEL_ID}&maxResults=10&order=date&type=video&key={YOUR_API_KEY}

Upload video to different channel using Youtube API, Ruby

I use Yt gem to work with Youtube API and upload video using Yt::Account class.
The problem is that I need to allow user to choose channel to upload to – for example, one user has a second channel related to Google Plus page and this user should be able to upload video to that Youtube channel, not user's default one.
It seems like Yt misses the ability to specify channel (or I missed something).
I found also examples from Google https://developers.google.com/youtube/v3/code_samples/ruby but all it says is "upload a video to the channel associated with the request" – and nothing about how to associate different channel.
Any help is appreciated

Google Play Web Video Player API

Is there an API for the Google Play online video playback of content? Would the YouTube API work?
I am wanting to embed Google Play content into a website I am building.
Thank you,
Joseph Irvine
Google Play movie purchases and rentals do also show up as YouTube videos (with a unique YouTube video ID), and so it is possible; obviously, you'd need to use oAuth2 authentication so when a user logs in, YouTube can verify that the user has the permission to see that film/TV show.
The real trick, however, is getting the right YouTube ID. They show up through search results via the search endpoint (so, for example, https://www.googleapis.com/youtube/v3/search?part=snippet&q=Monsters+University&key={YOUR_API_KEY} would be such a search), but that endpoint only gives you access to the "snippet" content type, which doesn't include the parameter "licensedContent" to let you know if it's a for-pay video (that parameter is found in the "contentDetails" type, which is only available from a video list call).

How can I link my private videos on YouTube to be played on my website?

How can I link my private videos on YouTube to be played on my website. The point is to bring more viewers to my site by making videos available on my site, yet private on YouTube.
You should set your videos to "unlisted" instead of "private". That
way the video does not show up on your channel or on any search
results but anyone with a link to the video can see it and you can
embed the video on any site.
I didn't try this workaround yet but theoretically it should work, you need to use YouTube API V 3 and follow the below steps:
Set the video's privacy status to unlisted through API.
Embed the video via API in a hidden div.
Use onPlayerStateChange event to check if the video player is currently playing the video, use the API to pause the video at the first second.
If the state changed to "playing" then send an AJAX request to a server side script to revert the the video's privacy status to be private, once you get a confirmation message display the video and use the API to play it.
This should keep the video private even if the user copy & paste the URL in another tab, s/he should get a message that the video is private.
References:
https://developers.google.com/youtube/iframe_api_reference?hl=en
PHP - How to change privacy status of a youtube video through Youtube API v3?

Resources