public function FeedsYoutubeParser::parse in Feeds: YouTube Parser 7.2
Same name and namespace in other branches
- 6 FeedsYoutubeParser.inc \FeedsYoutubeParser::parse()
- 7.3 plugins/FeedsYoutubeParser.inc \FeedsYoutubeParser::parse()
Parse the extra mapping sources provided by this parser.
Parameters
$fetcher_result FeedsFetcherResult:
$source FeedsSource:
See also
File
- ./
FeedsYoutubeParser.inc, line 23 - Feeds parser class for YouTube.
Class
- FeedsYoutubeParser
- Class definition for YouTube Parser.
Code
public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
$youtube_feed = $fetcher_result
->getRaw();
$result = new FeedsParserResult();
/**
* @see common_syndication_parser_parse()
*/
if (!defined('LIBXML_VERSION') || version_compare(phpversion(), '5.1.0', '<')) {
@($sxml = simplexml_load_string($youtube_feed, NULL));
}
else {
@($sxml = simplexml_load_string($youtube_feed, NULL, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NOCDATA));
}
// Got a malformed XML.
if ($sxml === FALSE || is_null($sxml)) {
throw new Exception(t('FeedsYoutubeParser: Malformed XML source.'));
}
// Run parsing if the feed is Atom or RSS
if ($this
->isAtomFeed($sxml)) {
$result = $this
->parseAtom($sxml, $source, $fetcher_result);
}
elseif ($this
->isRssFeed($sxml)) {
$result = $this
->parseRss20($sxml, $source, $fetcher_result);
}
else {
throw new Exception(t('FeedsYoutubeParser: Unknown type of feed.'));
}
return $result;
}