forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaylistsVideos.json.php
73 lines (70 loc) · 3.15 KB
/
playlistsVideos.json.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Content-Type");
header('Content-Type: application/json');
global $global, $config;
if (!empty($_GET) && empty($_POST)) {
$_POST = $_GET;
}
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
require_once 'comment.php';
require_once 'subscribe.php';
// gettig the mobile submited value
$inputJSON = url_get_contents('php://input');
$input = _json_decode($inputJSON, true); //convert JSON into array
if (!empty($input) && empty($_POST)) {
foreach ($input as $key => $value) {
$_POST[$key]=$value;
}
}
if (!empty($_POST['user']) && !empty($_POST['pass'])) {
$user = new User(0, $_POST['user'], $_POST['pass']);
$user->login(false, true);
}
if (empty($_POST['playlists_id'])) {
die('Play List can not be empty');
}
require_once './playlist.php';
$videos = PlayList::getVideosFromPlaylist($_POST['playlists_id']);
$objMob = AVideoPlugin::getObjectData("MobileManager");
$index = 0;
foreach ($videos as $key => $value) {
$videos[$key] = cleanUpRowFromDatabase($videos[$key]);
$images = Video::getImageFromFilename($videos[$key]['filename'], $videos[$key]['type']);
$videos[$key]['images'] = $images;
$videos[$key]['Poster'] = !empty($objMob->portraitImage) ? $images->posterPortrait : $images->poster;
$videos[$key]['Thumbnail'] = !empty($objMob->portraitImage) ? $images->posterPortraitThumbs : $images->thumbsJpg;
$videos[$key]['imageClass'] = !empty($objMob->portraitImage) ? "portrait" : "landscape";
$videos[$key]['VideoUrl'] = getVideosURL($videos[$key]['filename']);
$videos[$key]['createdHumanTiming'] = humanTiming(strtotime($videos[$key]['created']));
$videos[$key]['pageUrl'] = PlayLists::getLink($_POST['playlists_id'], false, $index);
$videos[$key]['embedUrl'] = PlayLists::getLink($_POST['playlists_id'], true, $index);
unset($_POST['sort'], $_POST['current'], $_POST['searchPhrase']);
$_REQUEST['rowCount'] = 10;
$_POST['sort']['created'] = "desc";
$videos[$key]['comments'] = Comment::getAllComments($videos[$key]['id']);
$videos[$key]['commentsTotal'] = Comment::getTotalComments($videos[$key]['id']);
foreach ($videos[$key]['comments'] as $key2 => $value2) {
$user = new User($value2['users_id']);
$videos[$key]['comments'][$key2]['userPhotoURL'] = User::getPhoto($videos[$key]['comments'][$key2]['users_id']);
$videos[$key]['comments'][$key2]['userName'] = $user->getNameIdentificationBd();
}
$videos[$key]['subscribers'] = Subscribe::getTotalSubscribes($videos[$key]['users_id']);
$videos[$key]['firstVideo'] = '';
foreach ($videos[$key]['VideoUrl'] as $value2) {
if ($value2["type"] === 'video') {
$videos[$key]['firstVideo'] = $value2["url"];
break;
}
}
if (preg_match("/^videos/", $videos[$key]['photoURL'])) {
$videos[$key]['UserPhoto'] = "{$global['webSiteRootURL']}".$videos[$key]['photoURL'];
} else {
$videos[$key]['UserPhoto'] = $videos[$key]['photoURL'];
}
$index++;
}
echo json_encode($videos);