This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VideoList.php
55 lines (48 loc) · 1.63 KB
/
VideoList.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* VideoList
*
* @author Skitsanos
*/
require_once 'Video.php';
require_once 'User.php';
require_once 'VzaarException.php';
class VideoList {
var $items;
static function fromJson($data) {
$jo = (array)json_decode($data);
if(array_key_exists('error', $jo)) {
throw new VzaarException($jo->error);
}
else {
$videos = array();
for ($i = 0, $l=count($jo); $i<$l; $i++) {
$video = new Video();
$video->duration = $jo[$i]->duration;
$video->playCount = $jo[$i]->play_count;
$video->title = $jo[$i]->title;
$video->description = $jo[$i]->description;
$video->url = $jo[$i]->url;
$video->createdAt = $jo[$i]->created_at;
$video->version = $jo[$i]->version;
$video->user= new User();
$video->user->authorAccount = $jo[$i]->user->author_account;
$video->user->authorName = $jo[$i]->user->author_name;
$video->user->authorUrl = $jo[$i]->user->author_url;
$video->user->videoCount = $jo[$i]->user->video_count;
$video->id = $jo[$i]->id;
$video->thumbnail = $jo[$i]->thumbnail;
$video->width = $jo[$i]->width;
$video->height = $jo[$i]->height;
$video->framegrabUrl = 'http://vzaar.com/videos/' . $jo[$i]->id . '.frame';
array_push($videos, $video);
}
return $videos;
}
}
}
?>