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; }
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; } }
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; }