Example #1
0
 public static function parse_list($response)
 {
     $result = array();
     try {
         $atom = Atom::parse($response, new YouTubeDataMedia());
     } catch (Exception $e) {
         throw new Exception($response);
     }
     foreach ($atom->arEntry() as $entry) {
         $obj = new self();
         $links = $entry->link();
         if (isset($links[0])) {
             $obj->url($links[0]->href());
         }
         if (isset($links[3])) {
             $obj->mobile_url($links[3]->href());
         }
         if ($entry->content() instanceof AtomContent) {
             $obj->content($entry->content()->value());
         }
         $obj->title($entry->title());
         $obj->published($entry->published());
         $obj->updated($entry->updated());
         $obj->keyword($entry->extra()->keyword());
         $obj->duration($entry->extra()->duration());
         $obj->player($entry->extra()->player());
         $obj->category($entry->extra()->category());
         $obj->thumbnail($entry->extra()->thumbnail());
         $result[] = $obj;
     }
     return $result;
 }
Example #2
0
 public function parse(&$src, &$result)
 {
     if (Tag::setof($tag, $src, "media:group")) {
         $media = new self();
         $media->keyword($tag->f("media:keywords.value()"));
         $media->duration($tag->f("yt:duration.param(seconds)"));
         $media->player($tag->f("media:player.value()"));
         $media->category($tag->f("media:category.value()"));
         $media->thumbnail($tag->f("media:thumbnail.param(url)"));
         $result = $media;
     }
 }