php 如何在 2015 年 4 月 20 日之后获得 Youtube 频道 RSS 提要(没有 v3 API)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29752447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:33:29  来源:igfitidea点击:

How to get a Youtube channel RSS feed after 2015 April 20 (without v3 API)?

phpyoutuberss

提问by Firsh - LetsWP.io

Now that API v2 is gone, what would be a way to get a simple RSS feed of a channel, without v3 API? I'm open to Yahoo Pipes or any workaround that is simpler than creating an application for v3 API if the target is a feed reader. I only need an RSS feed. It was available publicly until now and it can cease any minute now (I think). So why not let access to it without an API key anymore.

既然 API v2 已经消失,那么在没有 v3 API 的情况下,有什么方法可以获取频道的简单 RSS 提要?如果目标是提要阅读器,我对 Yahoo Pipes 或任何比为 v3 API 创建应用程序更简单的解决方法持开放态度。我只需要一个 RSS 提要。到目前为止,它一直是公开可用的,现在可以随时停止(我认为)。那么为什么不再允许在没有 API 密钥的情况下访问它。

回答by AitorF

At RSS Readersection https://support.google.com/youtube/answer/6098135?hl=enthere is an option to export to an OPML file your subscriptions. Then, looking at the contents of the OPML you can extract the feeds, and the structure of each feed is:

RSS 阅读器部分https://support.google.com/youtube/answer/6098135?hl=en有一个选项可以将您的订阅导出到 OPML 文件。然后,查看OPML的内容就可以提取提要,每个提要的结构是:

https://www.youtube.com/feeds/videos.xml?channel_id=XXXX

So you could generate new feeds from this structure if you know the channel id. This kind of feeds are not getting the "https://youtube.com/devicesupport" error, so I expect they are going to keep working.

因此,如果您知道频道 ID,则可以从此结构生成新提要。这种提要没有收到“ https://youtube.com/devicesupport”错误,所以我希望它们会继续工作。

回答by Primoz Rome

You can get the feeds like this:

你可以得到这样的提要:

https://www.youtube.com/feeds/videos.xml?channel_id=CHANNELID
https://www.youtube.com/feeds/videos.xml?user=USERNAME
https://www.youtube.com/feeds/videos.xml?playlist_id=YOUR_YOUTUBE_PLAYLIST_NUMBER

But the JSON format which used to be supported (with additional parameter &alt=JSON) is not supported anymore.

但是不再支持以前支持的 JSON 格式(带有附加参数&alt=JSON)。

Additionally you can request for API key for public access to your YouTube videos from your developer consoleand get YouTube Videos, Playlists in JSON format like this:

此外,您可以从开发者控制台请求公开访问您的 YouTube 视频的 API 密钥,并以 JSON 格式获取 YouTube 视频、播放列表,如下所示:

- Get Channels: 
  https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails&forUsername={YOUR_USER_NAME}&key={YOUR_API_KEY}
- Get Playlists: 
  https://www.googleapis.com/youtube/v3/playlists?part=snippet%2CcontentDetails&channelId={YOUR_CHANNEL_ID}&key={YOUR_API_KEY}
- Get Playlist Videos: 
  https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails%2Cstatus&playlistId={YOUR_PLAYLIST_ID}&key={YOUR_API_KEY}

More information from YouTube v3 docs.

来自YouTube v3 文档的更多信息。

回答by Halo Jones

in you tube, click on the subscriptions on the left hand pane. This will open up all your subscriptions in the center of the page. Scroll down and you'll find a Export to RSS reader button which produces an xml file of all your subscriptions . I've done this and added it to my prefered rss reader feedly.

在您的 Tube 中,单击左侧窗格中的订阅。这将在页面中央打开您的所有订阅。向下滚动,您将找到一个导出到 RSS 阅读器按钮,该按钮生成您所有订阅的 xml 文件。我已经完成了这个并将其添加到我喜欢的 RSS 阅读器中。

回答by Matt Way

If you inspect any Youtube channel page, inside the <head>you will find an rss meta node like this:

如果您检查任何 Youtube 频道页面,<head>您会在其中找到一个 rss 元节点,如下所示:

<link rel="alternate" 
      type="application/rss+xml" title="RSS"     
      href="https://www.youtube.com/feeds/videos.xml?channel_id=UCn8zNIfYAQNdrFRrr8oibKw">

This should provide you with the data you need.

这应该为您提供所需的数据。

回答by daygloink

Get the channel id by searching for the attribute data-channel-external-id in the source code of the YouTube channel page. (thanks to helq).

通过在 YouTube 频道页面的源代码中搜索属性 data-channel-external-id 来获取频道 id。(感谢 helq)。

This code will grab all video titles and ids from the feed and dump it into an array:

此代码将从提要中获取所有视频标题和 ID,并将其转储到一个数组中:

$channel_id = 'XXX'; // put the channel id here
$youtube = file_get_contents('https://www.youtube.com/feeds/videos.xml?channel_id='.$channel_id);
$xml = simplexml_load_string($youtube, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$youtube = json_decode($json, true);
$yt_vids = array();
$count = 0;
foreach ($youtube['entry'] as $k => $v) {
    $yt_vids[$count]['id'] = str_replace('http://www.youtube.com/watch?v=', '', $v['link']['@attributes']['href']);
    $yt_vids[$count]['title'] = $v['title'];
    $count++;
}
print_r($yt_vids);

回答by warrenwoodhouse

From My Blog Post: http://tcodesblog.blogspot.com/search/label/howtofindyouryoutubechannelfeed

来自我的博客文章: http://tcodesblog.blogspot.com/search/label/howtofindyouryoutubechannelfeed



HOW TO FIND YOUR YOUTUBE CHANNEL FEED

如何找到您的 YouTube 频道源

在过去,这很容易(2009 年),但现在很难找到(2012 年至今)。这是从您的 YouTube 频道中快速查找新供稿的方法。切记正确遵循清单!

  1. First find your channel id: You can do this by going to your YouTube Channel in the Dashboard

  2. Copy the channel id: Your channel idcan be found when visiting your YouTube Channel from within the Dashboard

  3. Copy your channel id: Copy your channel idand replace channelidgoesherebelow with your channel id: https://www.youtube.com/feeds/videos.xml?channel_id=channelidgoeshere

  4. Copy your entire YouTube Channel Feed and create a simplified feed: You can do this by creating a shorter feed link in FeedBurner at http://www.feedburner.com/(Requires a Google account. Free to use.), which is also part of Google. Create a new feed (select I'm A Podcaster!to see your videos appear in the feed and to make your feed compatible with other feed readers such as: Digg Reader, Apple iPhone Apple News App, Apple iPhone Podcasts App, Feedly, etc.) -OR- edit an existing one by copying your entire YouTube Channel Feed and then click Save Feed Detailsas normal

  5. Your YouTube Channel Feed now works and your videos can be seen in a feed file directly on your FeedBurner feed. Mine is at YouTube as a feed at https://www.youtube.com/feeds/videos.xml?channel_id=UCvFR6YxwnYfLt_QqRFk_r3g& at FeedBurner as http://feeds.feedburner.com/youtube/warrenwoodhousewith my videos that appear only as text format, as an example, since I need to update mine to show my videos. You can change different settings in FeedBurner and do other things so it's worth a try since it's free and easy to use. I highly recommend using FeedBurner or another feed creation service, however, FeedBurner is your best bet since it also includes cross-feed subscription service mechanism (USM - Universal Subscription Mechanism), which means your feed can be read from any compatible device such as a computer, mobile phone (with the correct app installed), via an older web browser (such as Internet Explorer which supports Web Slices & RSS/Atom/XML Feeds).

  1. 首先找到您的频道 ID:您可以通过在仪表板中转到您的 YouTube 频道来完成此操作

  2. 复制频道 ID:从仪表板中访问您的 YouTube 频道时可以找到您的频道 ID

  3. 复制您的频道 ID:复制您的频道 ID并将下面的channelidgoeshere替换为您的频道 IDhttps://www.youtube.com/feeds/videos.xml?channel_id=channelidgoeshere

  4. 复制您的整个 YouTube 频道供稿并创建一个简化的供稿:您可以通过在 FeedBurner 中创建一个较短的供稿链接来做到这一点http://www.feedburner.com/(需要 Google 帐户。免费使用。),这也是 Google 的一部分。创建一个新提要(选择我是播客!以查看您的视频出现在提要中并使您的提要与其他提要阅读器兼容,例如:Digg Reader、Apple iPhone Apple News App、Apple iPhone Podcasts App、Feedly 等.) - 或 - 通过复制整个 YouTube 频道供稿来编辑现有频道,然后照常点击保存供稿详细信息

  5. 您的 YouTube 频道供稿现在可以正常工作,您的视频可以直接在您的 FeedBurner 供稿的供稿文件中看到。我在 YouTube 上作为供稿https://www.youtube.com/feeds/videos.xml?channel_id=UCvFR6YxwnYfLt_QqRFk_r3g在 FeedBurner上作为供稿http://feeds.feedburner.com/youtube/warrenwoodhouse以我的视频仅显示为文本格式为例,因为我需要更新我的视频以显示我的视频。您可以在 FeedBurner 中更改不同的设置并执行其他操作,因此值得一试,因为它免费且易于使用。我强烈建议使用 FeedBurner 或其他提要创建服务,但是,FeedBurner 是您最好的选择,因为它还包括交叉提要订阅服务机制(USM - 通用订阅机制),这意味着您可以从任何兼容设备读取您的提要,例如计算机、手机(安装了正确的应用程序)、通过旧版网络浏览器(例如支持网页切片和 RSS/Atom/XML 订阅源的 Internet Explorer)。

Your feed can also be opened up in Apple iPhone Apple News App & Apple iPhone Podcasts App on your Apple iPhone, Apple iPod Touch and Apple iPad if you've set the settings correctly to USM (Universal Subscription Mechanism). Once this is in effect, your feed can be viewed through different services and devices.

如果您已将设置正确设置为 USM(通用订阅机制),您的订阅源也可以在 Apple iPhone、Apple iPod Touch 和 Apple iPad 上的 Apple iPhone Apple News App 和 Apple iPhone Podcasts App 中打开。生效后,您可以通过不同的服务和设备查看您的提要。

Your feed on FeedBurner allows you to create an Email Subscription, Headline Animator (which shows you how a link to the latest post) along with how many subscribers, Chiclets and other cool stuff.

您在 FeedBurner 上的提要允许您创建电子邮件订阅、标题动画制作器(它会向您展示指向最新帖子的链接)以及订阅者的数量、Chiclets 和其他很酷的东西。

I hope this answer proves useful and if you want to see some more cool awesome coding practices by me, please feel free to check out my T-Codes website at http://warrenwoodhouse.webs.com/codesfor lots more stuff.

我希望这个答案被证明是有用的,如果你想看到我的一些更酷的很棒的编码实践,请随时查看我的 T-Codes 网站http://warrenwoodhouse.webs.com/codes了解更多内容。

回答by Albirew

There also exist RSS-Bridge witch can extract RSS feeds from a lot of services like Twitter, Google+, Flickr, Youtube, Identi.ca, etc.

也有 RSS-Bridge 女巫可以从 Twitter、Google+、Flickr、Youtube、Identi.ca 等许多服务中提取 RSS 提要。

source: https://github.com/sebsauvage/rss-bridge

来源:https: //github.com/sebsauvage/rss-bridge

demo server: https://bridge.suumitsu.eu/

演示服务器:https: //bridge.suumitsu.eu/

回答by Rolland

try using this URL: https://www.youtube.com/feeds/videos.xml?user=USERNAME

尝试使用此 URL:https: //www.youtube.com/feeds/videos.xml?user=USERNAME

Works fine for me.

对我来说很好用。

回答by Dan

I've created a small PHP script that scrapes a Youtube URL for video links, and then outputs them as an atom feed: https://gist.github.com/Skalman/801436d9693ff03bc4ce

我创建了一个小的 PHP 脚本,用于抓取视频链接的 Youtube URL,然后将它们作为原子提要输出:https: //gist.github.com/Skalman/801436d9693ff03bc4ce

URLs such as https://www.youtube.com/user/scishow/videoswork.

诸如https://www.youtube.com/user/scishow/videos 之类的URL有效。

Caveats:

注意事项:

  • The tool doesn't scrape dates
  • Playlists won't include more than 100 videos
  • Playlists include the "play all" link
  • Author is correctly set only for channels (e.g. not playlists)
  • Maybe Youtube will block you if you use this too much (but hopefully the limits are high enough)
  • Likely several more...
  • 该工具不会抓取日期
  • 播放列表不会包含超过 100 个视频
  • 播放列表包括“全部播放”链接
  • 仅针对频道(例如,不是播放列表)正确设置了作者
  • 如果您使用太多,Youtube 可能会阻止您(但希望限制足够高)
  • 可能还有几个...

回答by agektmr

I have created an example Yahoo Pipes here.
http://pipes.yahoo.com/pipes/pipe.info?_id=6eeff0110a81f2ab94e8472620770b11

我在这里创建了一个 Yahoo Pipes 示例。
http://pipes.yahoo.com/pipes/pipe.info?_id=6eeff0110a81f2ab94e8472620770b11

You can run this pipe by pressing "Run Pipe" without API Key filled. But you must provide your own API Key and channel id (which can be obtained via channels API) when cloned. Wanted to automate fetching channelId by YouTube username but not easy to pipe.

您可以通过按“运行管道”而不填充 API 密钥来运行此管道。但是你必须在克隆时提供你自己的 API Key 和通道 ID(可以通过通道 API 获得)。想要通过 YouTube 用户名自动获取 channelId 但不容易管道。