Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving all the new subscription videos in YouTube v3 API

Tags:

I need to know the equivalent request in YouTube Data API v3 as this v2 request for retrieving all the new subscription videos.

https://gdata.youtube.com/feeds/api/users/default/newsubscriptionvideos 

I have not seen any simple and clean requests that are as simple as the v2 version of the reques

like image 909
SARose Avatar asked Oct 28 '13 17:10

SARose


People also ask

How do you fetch all videos on a YouTube channel?

To make it even more automated you can use @for /f "usebackq tokens=2 delims=: " %a in (`dl-list.py^|findstr information`) do @echo https://www.youtube.com/watch?v=%a . It will print all the URL of the videos. PLAYLIST_ID can be a playlist or channel ID.

What data can you get from YouTube API?

The API provides the ability to retrieve feeds related to videos, users, and playlists. It also provides the ability to manipulate these feeds, such as creating new playlists, adding videos as favorites, and sending messsages.

Does YouTube API have a limit?

Projects that enable the YouTube Data API have a default quota allocation of 10,000 units per day, an amount sufficient for the majority of our API users. You can see your quota usage on the Quotas page in the API Console.


1 Answers

You can retrieve this information with the Youtube V3 API but it is incredibly inefficient:

  • First get the channel ID from the username (one request).
  • Now get the subscriptions for the channel (batchable - one request per 50 subs).
  • Now get the playlists for each subscribed channel (batchable - one request per 50 subs).
  • Get the most recent playlistItems for the "uploads" system playlist of each channel. (one request per sub).
  • Get the video related to each playlistItem (batchable - one request 50 playlistItems).

You can now sort the videos by publishing date and print the most recent.

If you have 100 subscriptions and fetch 5 videos from each channel this will result in 114 API requests and use around 500 quota units (the daily limit is 50 million units). It will also take about 2 minutes to run if you don't parallelize the API calls.

This method does have a couple of benefits over using activites though:

  • You can do it for any user with public account settings, not just the authenticated user, so it works like the V2 API in that respect.
  • It won't randomly lose videos like the Youtube homepage does.

A full Python implementation is available: https://github.com/ali1234/ytsubs

like image 169
Alistair Buxton Avatar answered Dec 25 '22 13:12

Alistair Buxton