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 static function parse_list($response, $paginator)
 {
     $result = array();
     $res = Text::parse_json($response);
     if (isset($res["error"])) {
         throw new Exception($res["error"]);
     }
     if (!empty($res["pager"])) {
         $paginator = new Paginator($res["pager"]["clips_in_page"], $res["pager"]["current_page"], $res["pager"]["total_entries"]);
     }
     if (!empty($res["entries"])) {
         foreach ($res["entries"] as $re) {
             $obj = new self();
             $obj->id($re["id"]);
             $obj->title($re["title"]);
             $obj->url($re["permalink"]);
             $obj->author(new FlipClipAuthor($re["author"]["id"], $re["author"]["name"], $re["author"]["uri"]));
             $obj->summary($re["summary"]);
             $obj->updated($re["updated"]);
             if (isset($re["category"])) {
                 $obj->category(new FlipClipCategory($re["category"]["term"], $re["category"]["scheme"], $re["category"]["label"]));
             }
             if (isset($re["subcategory"])) {
                 $obj->category(new FlipClipCategory($re["subcategory"]["term"], $re["subcategory"]["scheme"], $re["subcategory"]["label"]));
             }
             if (isset($re["tags"])) {
                 foreach ($re["tags"] as $tag) {
                     $obj->tags(new FlipClipTag($tag["term"], $tag["scheme"], $tag["label"]));
                 }
             }
             $obj->embed_script($re["embed_script"]);
             $obj->latitude($re["latitude"]);
             $obj->longitude($re["longitude"]);
             $obj->privacy($re["privacy"]);
             $obj->duration($re["duration"]);
             $obj->image($re["image"]);
             $obj->image_medium($re["imageMedium"]);
             $obj->image_small($re["imageSmall"]);
             $obj->thumbnail($re["thumbnail"]);
             $result[] = $obj;
         }
     }
     return $result;
 }
Example #3
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;
     }
 }
Example #4
0
 public static function parse($src)
 {
     $result = array();
     foreach (Tag::anyhow($src)->in("item") as $in) {
         $o = new self();
         $o->title($in->f("title.value()"));
         $o->link($in->f("link.value()"));
         $o->description($in->f("description.value()"));
         $o->author($in->f("author.value()"));
         $o->category($in->f("category.value()"));
         $o->comments($in->f("comments.value()"));
         $o->pubDate($in->f("pubDate.value()"));
         $o->guid($in->f("guid.value()"));
         $value = $in->value();
         $o->enclosure = RssEnclosure::parse($value);
         $o->source = RssSource::parse($src);
         $result[] = $o;
     }
     return $result;
 }