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

后端 未结 16 1118
野趣味
野趣味 2020-12-22 17:14

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

相关标签:
16条回答
  • 2020-12-22 17:34

    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).

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

    $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);
    
    0 讨论(0)
  • 2020-12-22 17:41

    I think there are some changes in youtube response so i make some changes to get channel id from rss feed using Curl.

    $channel_id = 'XXXXXXXX'; // put the channel id here
    
    //using curl
    $url = 'https://www.youtube.com/feeds/videos.xml?channel_id='.$channel_id.'&orderby=published';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    $response  = curl_exec($ch);
    curl_close($ch);
    
    $response=simplexml_load_string($response);
    $json = json_encode($response);
    $youtube= json_decode($json, true);
    
    $count = 0;
    if(isset($youtube['entry']['0']) && $youtube['entry']['0']!=array())
    {
        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++;
        }
    }
    else
    {
        $yt_vids[$count]['id']=str_replace('http://www.youtube.com/watch?v=', '', $youtube['entry']['link']['@attributes']['href']);
        $yt_vids[$count]['title']=$youtube['title'];
    }
    echo "<pre>";
    print_r($yt_vids);
    
    0 讨论(0)
  • 2020-12-22 17:42

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


    HOW TO FIND YOUR YOUTUBE CHANNEL FEED

    In the old days, it was easy (2009) but now a days it is much harder to find it (2012-present). Here is a quick way to find your new feed from your YouTube Channel. Remember to follow the list correctly!

    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 id can be found when visiting your YouTube Channel from within the Dashboard

    3. Copy your channel id: Copy your channel id and replace channelidgoeshere below 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 Details as 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/warrenwoodhouse with 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).

    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.

    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.

    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/codes for lots more stuff.

    0 讨论(0)
  • 2020-12-22 17:42

    I would suggest using an excellent rss parser. Many of them are available, but you can try http://simplepie.org/, one of the best I used for my personal projects.

    Its pretty well documented with some examples.

    Usage example

    Note:Used YouTube channel college humor, you can get it from the channel page itself

    <?php
    include_once('../autoloader.php');
    // Parse it
    $feed = new SimplePie();
    $feed->set_feed_url('https://www.youtube.com/feeds/videos.xml?channel_id=UCPDXXXJj9nax0fr0Wfc048g');
    $feed->enable_cache(false);
    $feed->init();
    
    $items = $feed->get_items();
    
    foreach ($items as $item)
    {
        echo $item->get_title() . "\n";
    }
    
    var_dump($feed->get_item_quantity());
    
    0 讨论(0)
  • 2020-12-22 17:43

    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.

    0 讨论(0)
  • 2020-12-22 17:43

    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

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

    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...
    0 讨论(0)
提交回复
热议问题