* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
* Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* Handles everything related to enclosures (including Media RSS and iTunes RSS)
* Used by {@see SimplePie_Item::get_enclosure()} and {@see SimplePie_Item::get_enclosures()}
* This class can be overloaded with {@see SimplePie::set_enclosure_class()}
class SimplePie_Enclosure
* @var SimplePie_Copyright
* @see get_restrictions()
* @see get_sampling_rate()
* Constructor, used to input the data
* For documentation on all the parameters, see the corresponding
* properties and their accessors
* @uses idna_convert If available, this will convert an IDN
public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
$this->bitrate = $bitrate;
$this->captions = $captions;
$this->categories = $categories;
$this->channels = $channels;
$this->copyright = $copyright;
$this->credits = $credits;
$this->description = $description;
$this->duration = $duration;
$this->expression = $expression;
$this->framerate = $framerate;
$this->keywords = $keywords;
$this->ratings = $ratings;
$this->restrictions = $restrictions;
$this->samplingrate = $samplingrate;
$this->thumbnails = $thumbnails;
if (class_exists('idna_convert'))
$idn = new idna_convert();
$parsed = SimplePie_Misc::parse_url($link);
$this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
$this->handler = $this->get_handler(); // Needs to load last
public function __toString()
// There is no $this->data here
return md5(serialize($this));
public function get_bitrate()
if ($this->bitrate !== null)
* @return SimplePie_Caption|null
public function get_caption($key = 0)
$captions = $this->get_captions();
if (isset($captions[$key]))
* @return array|null Array of {@see SimplePie_Caption} objects
public function get_captions()
if ($this->captions !== null)
* @return SimplePie_Category|null
public function get_category($key = 0)
$categories = $this->get_categories();
if (isset($categories[$key]))
return $categories[$key];
* @return array|null Array of {@see SimplePie_Category} objects
public function get_categories()
if ($this->categories !== null)
return $this->categories;
* Get the number of audio channels
public function get_channels()
if ($this->channels !== null)
* Get the copyright information
* @return SimplePie_Copyright|null
public function get_copyright()
if ($this->copyright !== null)
* @return SimplePie_Credit|null
public function get_credit($key = 0)
$credits = $this->get_credits();
if (isset($credits[$key]))
* @return array|null Array of {@see SimplePie_Credit} objects
public function get_credits()
if ($this->credits !== null)
* Get the description of the enclosure
public function get_description()
if ($this->description !== null)
return $this->description;
* Get the duration of the enclosure
* @param bool $convert Convert seconds into hh:mm:ss
* @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found)
public function get_duration($convert = false)
if ($this->duration !== null)
$time = SimplePie_Misc::time_hms($this->duration);
* @return string Probably one of 'sample', 'full', 'nonstop', 'clip'. Defaults to 'full'
public function get_expression()
if ($this->expression !== null)
return $this->expression;
public function get_extension()
if ($this->link !== null)
$url = SimplePie_Misc::parse_url($this->link);
return pathinfo($url['path'], PATHINFO_EXTENSION);
* Get the framerate (in frames-per-second)
public function get_framerate()
if ($this->framerate !== null)