YouTube thumbnails

Creating and modifying plugins.
Post Reply
T
Regular
Posts: 48
Joined: Tue Feb 20, 2007 11:24 pm

YouTube thumbnails

Post by T »

Is there any way of displaying the thumbnails from a YouTube-RSS-feed in the sidebar?
Thanks in advance,
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: YouTube thumbnails

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
T
Regular
Posts: 48
Joined: Tue Feb 20, 2007 11:24 pm

Re: YouTube thumbnails

Post 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.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: YouTube thumbnails

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
T
Regular
Posts: 48
Joined: Tue Feb 20, 2007 11:24 pm

Post 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,
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
tazilein
Regular
Posts: 56
Joined: Sun Apr 30, 2006 11:44 pm
Contact:

Re: YouTube thumbnails

Post by tazilein »

Hi,

I have the same problem as described in this thread. Is there a new solution to it?
my S9Y-Blogs: my personal brainbackup | [url=http://www.viennacityflats,at]Vienna Apartments Rental[/url] | Kasperls Geschichten | various other Sites using S9y as CMS
Post Reply