Sort YouTube Videos by time of upload - youtube

I have searched the web tirelessly and looked through the YouTube API, but I still can't seem to find a way in which to request videos from a specific channel which have been uploaded since a certain date-time.
Something along the lines of this:
GET https://www.googleapis.com/youtube/v3/channels?part=videoContent&channel=UC_x5XG1OV2P6uZZ5FSM9Ttw&uploadedAfter=1421056357914

What you'd want to do is to get the channel's uploads playlist, the do a playlistItems.list with it.
Though currently playlistItems.list doesn't support orderBy or uploadedAfter, it's in the works.

Related

Get Only Video and not cortos videos

Good morning
I am using the youtube api to get the latest videos from a channel, but I also get the short videos that are like instagram or tiktok reels, is there any way to not get these videos?
I leave the endoint I am using
https://www.googleapis.com/youtube/v3/search?channelId=${channel_id}&part=snippet,id&order=date&maxResults=${totalVideos}&key=${API_KEY_YOUTUBE}
Greetings and thank you
If you check the Search.list method you will notice that it does not have any way of limiting the data that is returned.
You will need to remove these locally.
It may be worth adding a feature request to the issue forumn

YouTube API "playlistItems" does not return all items of the "Uploaded" playlist

I am wondering if anyone knows what could be the cause of this.
On a channel's upload playlist, it states there are 143 videos in the playlist:
When I use the "Playlistitems" API (with paging):
https://developers.google.com/youtube/v3/docs/playlistItems/list
I get 138 items.
I have singled out a specific video that is in the Playlist on YouTube as an example. Video ID Q3UDhRDLbPg:
But when I use the "Playlistitems" API explorer, on the playlist and specify the specific video, I get zero results.
The video is public and was uploaded a few days ago. Some videos that were uploaded on the same day does exist in the results too.
Has anyone seen this problem before and might know the cause of it?
This issue is solved.
As #stvar pointed out, there is some kind of a delay in YouTube's backend, some videos might take longer to be included than others.
All videos are accounted for now, 4 days after the upload time.

Get list of videos uploaded before and after certain video

Youtube use to have a feature where you could click a more videos button while watching any video, and see a snapshot of the uploads playlist with videos uploaded before and after the one you are currently watching.
I am trying to get a list like that with the v3 data API and it seems there is no way. There use to be a way to dictate an index when using the playlistItems call, but now there isn't.
If you go to a channels upload playlist and click play all, you can see a list of videos surrounding the one you are watching, so it seems this functionality is possible, but I don't know how they are doing it.
Any ideas?

How to know if a video has been seen/hidden?

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.

Youtube API: no way to get liked videos from user's activity feed

It's a known issue that Youtube API (v2) doesn't support liked videos - http://www.youtube.com/my_liked_videos (not http://www.youtube.com/my_favorites). The trick was to use events API for user's recent activity and filter out those with yt:rating.value = like. However, when I hit this endpoint https://gdata.youtube.com/feeds/api/users/default/events?inline=true (with proper authorization headers), I only get last 24 events and all of them are of 'X has uploded a video' type. Has anyone experienced this and figured out what is wrong?
You can get liked videos without much effort in v3 of the API. I don't think there's a workaround for this in v2.
In v3, make a channels.list(part=contentDetails) call to get the "likes" playlist id, and then do a playlistItems.list() call to get the contents of that playlist, i.e. the videos that have been liked.

Resources