Page 1 of 1

YouTube thumbnails

Posted: Mon Oct 15, 2007 3:59 pm
by T
Is there any way of displaying the thumbnails from a YouTube-RSS-feed in the sidebar?
Thanks in advance,

Re: YouTube thumbnails

Posted: Mon Oct 15, 2007 4:16 pm
by garvinhicking
Hi!

Have you tried using the Remote OPML/RSS sidebar plugin?

How does a youtube RSS feed look like? I'm sure it can be done.

Regards,
Garvin

Re: YouTube thumbnails

Posted: Mon Oct 15, 2007 11:37 pm
by T
Yes, I have tried to modify the RSS-plugin but no luck.
garvinhicking wrote:How does a youtube RSS feed look like? I'm sure it can be done.
See for example http://www.youtube.com/rss/user/youtube/videos.rss

Here's an example of an item in such a feed:

Code: Select all

<item>
			<author>rss@youtube.com (YouTube)</author>
			<title>Bill Clinton talks about the YouTube Nonprofit Program</title>
			<link>http://youtube.com/?v=fvfumQ0_0_Q</link>

			<description>
				<![CDATA[
				<img src="http://img.youtube.com/vi/fvfumQ0_0_Q/default.jpg" align="right" border="0" width="120" height="90" vspace="4" hspace="4" />
				<p>
				With Chad, Steve and Larry, President Clinton talks about the YouTube Nonprofit Program.

http://youtube.com/nonprofits

Thanks to YouTuber theresident for shooting this footage!

http://youtube.com/theresident
				</p>
				<p>
					Author: <a href="http://youtube.com/profile?user=YouTube">YouTube</a><br/>
					Keywords:  <a href="/results?search_query=youtube">youtube</a> <a href="/results?search_query=nonprofit">nonprofit</a> <a href="/results?search_query=program">program</a><br/>
					Added: September 28, 2007<br/>
				</p>
]]>
			</description>
			<guid isPermaLink="true">http://youtube.com/?v=fvfumQ0_0_Q</guid>
			<pubDate>Fri, 28 Sep 2007 16:08:36 -0700</pubDate>

			<media:player url="http://youtube.com/?v=fvfumQ0_0_Q" />
			<media:thumbnail url="http://img.youtube.com/vi/fvfumQ0_0_Q/default.jpg" width="120" height="90" />

			<media:title>Bill Clinton talks about the YouTube Nonprofit Program</media:title>
			<media:category label="Tags">youtube nonprofit program</media:category>
			<media:credit>YouTube</media:credit>
			<enclosure url="http://youtube.com/v/fvfumQ0_0_Q.swf" duration="179" type="application/x-shockwave-flash"/>
		</item>
I want to display the media:thumbnail element (the thumbnail image) and link it to the video.

Re: YouTube thumbnails

Posted: Tue Oct 16, 2007 10:19 am
by garvinhicking
Hi!

Uh, this is actually complex, because you would need customized code to do so.

You could simply display the "description" element with the full content?

To modify the plugin, you need to edit the serendipity_plugin_remoterss.php plugin file and chagne the "generate_content" method. There you'll need to insert PHP code to do the necessary HTML transformation of the media:thumbnail element.

The important part is this part of the code:

Code: Select all

foreach($rss_elements AS $rss_element) {
    $rss_element = trim($rss_element);
    if ($escape_rss) {
        $content .= $this->decode($item[$rss_element]);
    } else {
        $content .= htmlspecialchars($this->decode($item[$rss_element]));
    }
}
that would need to be modified. HOWEVER the problem is that the youtube RSS puts the media:thumbnail stuff into an attribute ("url=...") instead in the content of a <media:thumbnail>...</media:thumbnail> attribute. That sucks, because the Onyx RSS library cannot parse attributes. So you would need to fully switch the used RSS decoder to magpie or something else, which is more work than I could spend right now.

Maybe you could use the Yahoo Pipes! application to transform a youtube feed to a proper feed which will contain a:

Code: Select all

<media:thumbnail><![CDATA[<img src="/blabla.jpg" />]]></media:thumbnail>
element, because then you could use an unmodified version of the plugin and simply configured "media:thumbnail" as the required output element.

Regards,
Garvin

Posted: Fri Oct 19, 2007 9:11 pm
by T
Hi,

I managed to modify the feed using www.referd.info, however this site seems to be pretty unstable...

More importantly, I had to modify the RSS-plugin to display the image URL. It shows up in the feed as <thumbnail_url>http://someurl.com/img.jpg</thumbnail_url>, and the unmodified version will display this URL as plain text. Any way to change this and use the unmodified version?

Thanks in advance,

Posted: Sat Oct 20, 2007 2:24 pm
by garvinhicking
Hi!
Any way to change this and use the unmodified version?
Sadly not,because of the same reasons: You would need conditional logic to insert text. You would either need to edit the PHP plugin file for that (and add the extra 'img' parameter) or use an external RSS-modification service.

Did you look at Yahoo Pipes?

Regards,
Garvin

Re: YouTube thumbnails

Posted: Mon Feb 09, 2009 11:07 pm
by tazilein
Hi,

I have the same problem as described in this thread. Is there a new solution to it?