|
I have managed to build a Video Sitemap for Vshare. This is what I am currently using. I submitted it to Google and he liked it. No problems so far. Just edit your MySQL Details and your site name in the script, then save it in your site root (use .php as extension, any name will do) and then submit it too Google Video Sitemap <?php echo "<?xml version='1.0' encoding='iso-8859-1'?>"; echo "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' xmlns:video='http://www.google.com/schemas/sitemap-video/1.0'>";
// hostname on which MySQL is (usally localhost) $dbhost = "localhost"; // Database name $dbname = "my_database_name"; // Username $dbuser = "my_user_name"; // Password $dbpass = "my_password";
// mysql_connect() fnction $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die("Unable to connect to MySQL.");
// mysql_select_db() function mysql_select_db($dbname,$conn) or die("Unable to connect to Database $dbname");
$sql = "Select VID, title, description, adddate, flvdoname, duration from video where approve=1 and active=1";
// execute SQL Command $res = mysql_query($sql,$conn) or die( "Error: " . mysql_error() );
// Retrieve Results while ($info = mysql_fetch_row($res)) { $SefUrl=strtolower(preg_replace("/[^a-zA-Z0-9]+/","-", $info[1]));
$title=str_replace("&","e", $info[1]); $title=str_replace("\"","", $title);
$desc=str_replace("&","e", $info[2]); $desc=str_replace("\"","'", $desc); $desc=str_replace("<","", $desc); $desc=str_replace(">","", $desc);
echo "<url> <loc>http://www.yoursite.com/view/".$info[0]."/".$SefUrl."/</loc> <video:video> <video:content_loc>http://www.yoursite.com/flvideo/".$info[4]."</video:content_loc> <video:player_loc allow_embed='yes'>http://www.yoursite.com/player.swf</video:player_loc> <video:title>".$title."</video:title> <video:description>".$desc."</video:description> <video:thumbnail_loc>http://www.yoursite.com/thumb/".$info[0].".jpg</video:thumbnail_loc> //change the following line if your site contains adult videos <video:family_friendly>Yes</video:family_friendly> <video:duration>".$info[5]."</video:duration> </video:video></url>"; } echo "</urlset>";
// mysql_close() function mysql_close($conn); ?> |