检索 YouTube v3 API 中的所有新订阅视频 [英] Retrieving all the new subscription videos in YouTube v3 API

查看:16
本文介绍了检索 YouTube v3 API 中的所有新订阅视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道 YouTube Data API v3 中与此 v2 请求相同的请求,用于检索所有新订阅视频.

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

我还没有见过像v2版本的reques那样简单干净的请求

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

推荐答案

您可以使用 Youtube V3 API 检索此信息,但效率非常低:

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

  • 首先从用户名中获取频道 ID(一个请求).
  • 现在获取频道的订阅(可批处理 - 每 50 个订阅一个请求).
  • 现在获取每个订阅频道的播放列表(可批处理 - 每 50 个订阅者一个请求).
  • 获取每个频道的上传"系统播放列表的最新播放列表项.(每个子请求一个).
  • 获取与每个 playlistItem 相关的视频(可批量 - 一次请求 50 个 playlistItems).

您现在可以按发布日期对视频进行排序并打印最新的.

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

如果您有 100 个订阅并从每个频道获取 5 个视频,这将产生 114 个 API 请求并使用大约 500 个配额单位(每日限制为 5000 万个单位).如果不并行化 API 调用,也需要大约 2 分钟才能运行.

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:

  • 您可以为任何具有公共帐户设置的用户执行此操作,而不仅仅是经过身份验证的用户,因此在这方面它与 V2 API 一样工作.
  • 它不会像 Youtube 主页那样随机丢失视频.

提供完整的 Python 实现:https://github.com/ali1234/ytsubs

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

这篇关于检索 YouTube v3 API 中的所有新订阅视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆