Jump to content

Converting my php RSS to a google Video Sitemap.


Heath

Recommended Posts

This has been puzzling me for months now. Every time I try to edit it to match what google says here...

http://www.google.com/support/webmasters/bin/answer.py?answer=80472&topic=10079

 

Here is what they say the format they want is.

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:video="http://www.google.com/schemas/sitemap-video/1.0">
<url>
   <loc>http://www.site.com/videos/some_video_landing_page.html</loc>
   <video:video>
      <video:content_loc>http://www.site.com/video123.flv</video:content_loc>
      <video:player_loc allow_embed="yes">http://www.site.com/videoplayer.swf?video=123</video:player_loc>
      <video:title>My funny video</video:title>
      <video:thumbnail_loc>http://www.site.com/thumbs/123.jpg</video:thumbnail_loc>
   </video:video>
</url>

<url>
   <loc>http://www.site.com/videos/some_other_video_landing_page.html</loc>
   <video:video>
      <video:content_loc>http://www.site.com/videos/video1.mpg</video:content_loc>
      <video:description>A really awesome video</video:description>
   </video:video>
</url>
</urlset>

 

Which looks pretty simple to me. But converting the RSS/PHP i have now to match that is were I keep running into problems. Here is my current Php that creates my rss.

 

		case 'rss':
			$this->rss();

 

 

 

function rss() {
	global $mkportals, $DB, $mklib;

	$content = "<?xml version='1.0' encoding='iso-8859-1'?>\n
<rss version='2.0'>
<channel>
<title>$mklib->sitename</title>
<link>$mklib->siteurl</link>
<description>MkMedia Generated</description>
<generator>MkMedia</generator>
<language>Multi-Lang</language>
<copyright>MkMedia 2004 - ".date("Y")."</copyright>";

	$query = $DB->query("SELECT id, name, description, data, author FROM mkp_media WHERE validate = '1' AND visible = '1' ORDER by `data` DESC LIMIT 0,10");
	if (!$DB->get_num_rows($query)) {
		$content .= "
<item>
<title>Sorry There Are Currently No Feeds</title>
<link></link>
<pubDate></pubDate>
<author></author>
<description></description>
</item>
</channel>
</rss>";
		$rsslength = strlen($content);
		header("Content-Type: text/xml");
		header("Content-Length: ".$rsslength);
		header("Cache-Control: no-cache");
		echo $content;
		exit;
	}
	while ($row = $DB->fetch_row($query)) {
		$id = $row['id'];
		$date = $mklib->create_date($row['data']);
		$name = str_replace("´", "", $row['name']);
		$name = preg_replace('/&(?!(#[0-9]+|[a-z]+);)/si', '&', $name);
		$description = str_replace("´", "", $row['description']);
		$description = preg_replace('/&(?!(#[0-9]+|[a-z]+);)/si', '&', $description);
		$author = $row['author'];
		$content .= "
<item>
<title>{$name}</title>
<link>$mklib->siteurl/index.php?ind=media&op=file_view&iden={$id}</link>
<pubDate>{$date}</pubDate>
<author>{$author}</author>
<description>{$description}</description>
</item>";

	}
	$content .= "
</channel>
</rss>";
	$rsslength = strlen($content);
	header("Content-Type: text/xml");
	header("Content-Length: ".$rsslength);
	header("Cache-Control: no-cache");
	echo $content;
	exit;
}

 

My question is what exactly am I supposed to do to replicate the requirements for googles video sitemap with some thing written for RSS Output?

 

I am new to the whole php thing still, very little time to work on it, but from what I do know, every thing i've tried seems to be along the lines of what I was suggested to do with no luck. So if you could provide any help I would greatly appreciate it.

 

Thank you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.