[wp-hackers] Adding links to feed

Navjot Singh navjotjsingh at gmail.com
Fri Nov 7 19:40:32 GMT 2008


Sorry but I am not conversed well with php. I am running a download
videos site. Now I want to provide download urls of videos from
youtube.

I am using the following code to display download urls in single.php
automatically in my theme's function.php:

function str_between($string, $start, $end){ $string = " ".$string;
$ini = strpos($string,$start); if ($ini == 0) return ""; $ini +=
strlen($start); $len = strpos($string,$end,$ini) - $ini; return
substr($string,$ini,$len); }
function get_youtube_download_link($url){
if( $url !== "")
{
$youtube_link = $url;
//$url = get_post_meta($post->ID, 'url', true);
if ( file_get_contents($youtube_link) !== "")
{
$youtube_page = file_get_contents($youtube_link);
$v_id = str_between($youtube_page, "&video_id=", "&");
$t_id = str_between($youtube_page, "&t=", "&");
$flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id";
$hq_flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=6";
$mp4_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=18";
$threegp_link =
"http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=17";
echo "\t\tDownload (right-click > save as):\n\t\t";
echo "<a href=\"$flv_link\">FLV</a>\n\t\t";
echo "<a href=\"$hq_flv_link\">HQ FLV (if available)</a>\n\t\t";
echo "<a href=\"$mp4_link\">MP4</a>\n\t\t";
echo "<a href=\"$threegp_link\">3GP</a><br><br>\n";
}
}
}

This works wonderfully.

How to modify this code so that the links display well in feeds as
well? Currently it displays only in the post but not in the feeds.

Regards
Navjot Singh


More information about the wp-hackers mailing list