2007-07-01, 22:37
Maybe a bit off topic (not a python script but php) but this will allow to directly stream youtube flv videos on XBMC via RSS.
Tested and working 100% on latest build: T3CH XBMC 2007-07-01 SVN rev9489
Enjoy.
Tested and working 100% on latest build: T3CH XBMC 2007-07-01 SVN rev9489
Enjoy.
PHP Code:
<?php
// Youtube RSS Feed Converter v0.1 - youtube_rss.php
// Stream youtube videos directly on your XBMC via rss feed
// Adds enclosure tags to youtube rss feeds
// Links to the flv videos directly from google cache servers (get video directly from id)
// Usage:
// youtube_rss.php?rss=[recently_added|recently_featured|top_favorites|top_rated|top_viewed_today | top_viewed_week|top_viewed_month|top_viewed]
// youtube_rss.php?user=[username]
// youtube_rss.php?tag=[tag]
// Requirements:
// - Web server running php where to host this file.
// - Snoopy php class: http://sourceforge.net/projects/snoopy/
// - An XBMC script that can stream media from RSS feeds like:
// Xbox Podcast Script - http://www.xbmcscripts.com/?option=com_docman&task=search_result&Itemid=Array&search_mode=phrase&search_phrase=XBox%20Podcast%20Script%20v0.5
// or
// Navi-X - http://www.xbmcscripts.com/?option=com_docman&task=search_result&Itemid=Array&search_mode=phrase&search_phrase=Navi-X%20v1.2
if(isset($_GET['rss'])){
$rss = $_GET['rss'];
if($rss == 'recently_added'| $rss == 'recently_featured' | $rss == 'top_favorites' | $rss == 'top_rated' | $rss == 'top_viewed_today' | $rss == 'top_viewed_week' | $rss == 'top_viewed_month'| $rss == 'top_viewed'){
$URL = 'http://www.youtube.com/rss/global/'.$rss.'.rss';
}
} else if(isset($_GET['user'])){
$user = $_GET['user'];
$URL = 'http://www.youtube.com/rss/user/'.$user.'/videos.rss';
} else if(isset($_GET['tag'])){
$tag = $_GET['tag'];
$URL = 'http://www.youtube.com/rss/tag/'.$tag.'.rss';
}
include "Snoopy-1.2.3/Snoopy.class.php";
$snoopy = new Snoopy;
$snoopy->rawheaders["Pragma"] = "no-cache";
$snoopy->expandlinks = false;
$snoopy->fetch($URL);
$rss=str_replace('.swf', '', $snoopy->results); // get rid of enclosure extension
$rss=str_replace('http://youtube.com/v/', 'http://cache.googlevideo.com/get_video?video_id=', $rss); // enclosure is flv
$rss=str_replace('application/x-shockwave-flash', 'video/flv', $rss); // adjust mime type
$rss=str_replace('http://youtube.com/?v=', 'http://cache.googlevideo.com/get_video?video_id=', $rss); // make urls link to flv too
echo $rss;
?>