I am trying to use youtube api to fetch the latest video uploaded in a channel and the query is as below
https://www.googleapis.com/youtube/v3/search?key={KEY}&channelId={CHANNEL-ID}&part=snippet&maxResults=1&order=date&type=video
But it is not returning the latest video uploaded in that channel. Adding or removing order attribute doesn't seem to work as it keeps returning the same video.
You have do to this by fetching playlist items. Get your channel id. It should look like this: UC######################. Now you have to replace the 'C' to 'U'. Like this: UU######################. You can call the youtube api with this id now.
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UU######################&maxResults=5&key=[YOUR_API_KEY]
Related
I have a large array of video id's. (Over 100) I need to determine which videos belong to the oauth'd user. Looking through the Youtube API docs it doesn't look like they have a way to get videos by ID for a channel. I see how to get all videos for a channel but that looks like it limits the results. Is there an efficient way to do this that I'm missing?
Ideally I'd like to say grab all videos with this id that belong to this channel. I'd accept a way to just get all videos for the users channel so I can compare the array of videos with my array of id's.
Using Laravel socialite and the PHP google api client.
You can either
Get videos by IDs using the videos:list API endpoint. The id parameter takes up to 50 comma-separated videoIDs.
or
Get all videos in a channel using the channels:list API endpoint. The id parameter takes up to 50 comma-separated channelIDs. Each page of results has up to 50 videos.
If you already have the videoIDs, option 1 would be best.
I have figured it out if you want to get the video with particular video id
https://www.youtube.com/watch?v=hcMzwMrr1tE
if you want the thumbnails for the particular video
https://storage.googleapis.com/yt-trends-top-ten-lists-2022/thumbs/**hcMzwMrr1tE**.jpg
put the video id you will get the details you can use google api like this
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}
I need some help getting the video ID number and the video title ( the title would be "Private video") for all private videos within a public playlist. Specifically I'd need help editing my script below. This script used to be able to do that, but I fear something has changed with Youtube's API. I want to know if there is any way to get this information and fix my script.
My script is located here
Just a month ago my script (see above) was able to retrieve video ID numbers and video names of private videos when fetching playlistItems from a playlistid (of course the video titles were renamed "Private video" - but that is the info I wanted). Unfortunately now when I fetch the same playlistid from youtube it hides all this info. It acts as if there are no videos in the playlist when a playlist contains private videos. Here is a question asked last year, it shows you can pull the video ID numbers and names from a playlist that contained private videos. Retrieve Video IDs contained in a Playlist - YouTube API v3
Here is an example of a playlist I would want to fetch the video ID and video name from.
https://www.youtube.com/playlist?list=PLAg_-NsALZoOLfXbX7eGIzFsbG21XAvct
I haven't tried it but you can try PlaylistItems: list and Advanced Google Services
Returns a collection of playlist items that match the API request parameters. You can retrieve all of the playlist items in a specified playlist or retrieve one or more playlist items by their unique IDs.
AFAIK if you own the private/unlisted videos, you can get the videos using Youtube API v3. You can read these related SO questions - Using the YouTube API v3 to list all private videos, Google Youtube Data API: Private videos with API key and Google YouTube API (v3): how to access my unlisted/private videos from my server? that all discuss retrieving the ID as the owner of the videos.
This issue has been fixed. You now get the behavior you were used to.
Using the YouTube Data API v3, is there a way to know if a video has been seen or hidden?
Reading through the docs, I didn't see anything on the Video resource that could match what I'm looking for.
Logically, “Watched” videos are just videos which have entries on your “Watch History” on Youtube.
You can get your “Watched” videos list through the API by getting your Watch History list from your channel. You can do that by using obtaining your Watch History ID which at the same time is also treated as playlistId.
Referring through the Channel API, make a GET HTTP request to
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&key={YOUR_API_KEY}
This should return a JSON which should contain an object with “watchHistory” key. The value paired with it is your playlistId which you can now use to make a request using the PlaylistItems API
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId={YOUR_WATCHED_PLAYLIST_ID}&key={YOUR_API_KEY}
This should return a list of videos that your account has already watched.
As for getting the list of “Hidden” videos on your subscription feed. I think it's not achievable through the API. Checked on different responses of subscription and video resources but to no avail. No responses containing "watched" or "hidden" related.
So I have this broken Youtube playlist (PHP loop that gets playlist info from Youtube feed). Oddly, it broke when a few duplicate/failed upload videos were deleted, no clue why.
Anyways, I have this playlist feed URL which doesn't seem to work, but was working earlier: http://gdata.youtube.com/feeds/api/playlists/6549D4CA7BB99B16?v=2
What is the number following /playlists/? It doesn't look like a playlist ID (since they appear to start with 'PL') or a user ID http://www.youtube.com/playlist?list=PL6549D4CA7BB99B16.
I have several such feeds in the code, they all used to work. Thoughts?
It is the playlist ID -- YouTube apparently just recently instituted a change that requires appending the 'PL' characters, like this:
http://gdata.youtube.com/feeds/api/playlists/PL6549D4CA7BB99B16?v=2