class LifeStream_YouTubeFeed extends LifeStream_FlickrFeed
{
// quick hack by fgo, cfr. http://blog.futtta.be/2008/12/09/lifestream-plugin-hack-youtube-favorites/
const ID = 'youtube';
const NAME = 'YouTube';
const URL = 'http://www.youtube.com/';
const DESCRIPTION = 'Publish your uploaded and optionally favorited YouTube video\'s in your lifestream.';
function __toString() {
return $this->options['username'];
}
function get_options() {
return array (
'username' => array('Username:', true, '', ''),
'show_favorited' => array('Include my favorited video\'s as well.', false, true, false),
);
}
function get_public_url() {
return 'http://www.youtube.com/user/'.$this->options['username'];
}
function get_label_single($key) {
if ($key == 'posted') $label = 'Posted a video on %s.';
else if ($key == 'favorited') $label = 'Favorited a video on %s.';
return $label;
}
function get_label_plural($key) {
if ($key == 'posted') $label = 'Posted %d videos on %s.';
else if ($key == 'favorited') $label = 'Favorited %d videos on %s.';
return $label;
}
function get_label_single_user($key) {
if ($key == 'posted') $label = '%s posted a video on %s.';
else if ($key == 'favorited') $label = '%s favorited a video on %s.';
return $label;
}
function get_label_plural_user($key) {
if ($key == 'posted') $label = '%s posted %d videos on %s.';
else if ($key == 'favorited') $label = '%s favorited %d videos on %s.';
return $label;
}
function get_posted_url() {
return 'http://www.youtube.com/rss/user/'.$this->options['username'].'/videos.rss';
}
function get_favorited_url() {
return 'http://gdata.youtube.com/feeds/api/users/'.$this->options['username'].'/favorites?v=2';
}
function get_url() {
$urls = array();
$urls[] = array($this->get_posted_url(), 'posted');
if ($this->options['show_favorited']) $urls[] = array($this->get_favorited_url(), 'favorited');
return $urls;
}
function yield($item) {
if ($enclosure = $item->get_enclosure()) {
if ($thumbnail = $enclosure->get_thumbnail()) $data['thumbnail'] = $thumbnail;
if ($image = $enclosure->get_medium()) $data['image'] = $image;
}
return array(
'date' => $item->get_date('U'),
'link' => html_entity_decode($item->get_link()),
'title' => html_entity_decode($item->get_title()),
'thumbnail' => $data['thumbnail'],
'image' => $data['image'],
);
}
}
register_lifestream_feed('LifeStream_YouTubeFeed');