1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 17:59:55 +02:00

Some improvements to combine sites

This commit is contained in:
daniel 2020-05-08 14:14:22 -03:00
parent 2b62335d5e
commit f5d738c7ec
5 changed files with 119 additions and 19 deletions

View file

@ -3017,3 +3017,9 @@ function isToShowDuration($type){
return true; return true;
} }
} }
function _dieAndLogObject($obj, $prefix=""){
$objString = json_encode($obj);
_error_log($prefix.$objString);
die($objString);
}

View file

@ -173,14 +173,14 @@ class API extends PluginAbstract {
if (empty($value['filename'])) { if (empty($value['filename'])) {
continue; continue;
} }
if($value['type']=='serie'){ if ($value['type'] == 'serie') {
require_once $global['systemRootPath'] . 'objects/playlist.php'; require_once $global['systemRootPath'] . 'objects/playlist.php';
$rows[$key]['playlist'] = PlayList::getVideosFromPlaylist($value['serie_playlists_id']); $rows[$key]['playlist'] = PlayList::getVideosFromPlaylist($value['serie_playlists_id']);
} }
$images = Video::getImageFromFilename($rows[$key]['filename'], $rows[$key]['type']); $images = Video::getImageFromFilename($rows[$key]['filename'], $rows[$key]['type']);
$rows[$key]['images'] = $images; $rows[$key]['images'] = $images;
$rows[$key]['videos'] = Video::getVideosPaths($value['filename'], true); $rows[$key]['videos'] = Video::getVideosPaths($value['filename'], true);
if(empty($rows[$key]['videos'])){ if (empty($rows[$key]['videos'])) {
$rows[$key]['videos'] = new stdClass(); $rows[$key]['videos'] = new stdClass();
} }
$rows[$key]['Poster'] = !empty($objMob->portraitImage) ? $images->posterPortrait : $images->poster; $rows[$key]['Poster'] = !empty($objMob->portraitImage) ? $images->posterPortrait : $images->poster;
@ -193,7 +193,7 @@ class API extends PluginAbstract {
if ($SubtitleSwitcher) { if ($SubtitleSwitcher) {
$rows[$key]['subtitles'] = getVTTTracks($value['filename'], true); $rows[$key]['subtitles'] = getVTTTracks($value['filename'], true);
foreach ($rows[$key]['subtitles'] as $key2=>$value) { foreach ($rows[$key]['subtitles'] as $key2 => $value) {
$rows[$key]['subtitlesSRT'][] = convertSRTTrack($value); $rows[$key]['subtitlesSRT'][] = convertSRTTrack($value);
} }
} }
@ -277,22 +277,22 @@ class API extends PluginAbstract {
$obj = $this->startResponseObject($parameters); $obj = $this->startResponseObject($parameters);
$dataObj = $this->getDataObject(); $dataObj = $this->getDataObject();
if ($dataObj->APISecret === @$_GET['APISecret']) { if ($dataObj->APISecret === @$_GET['APISecret']) {
if(!empty($_GET['users_id'])){ if (!empty($_GET['users_id'])) {
$user = new User($_GET['users_id']); $user = new User($_GET['users_id']);
}else if(!empty($_GET['user'])){ } else if (!empty($_GET['user'])) {
$user = new User(0, $_GET['user'], false); $user = new User(0, $_GET['user'], false);
}else{ } else {
return new ApiObject("User Not defined"); return new ApiObject("User Not defined");
} }
if(empty($user) || empty($user->getId())){ if (empty($user) || empty($user->getId())) {
return new ApiObject("User Not found"); return new ApiObject("User Not found");
} }
$p = AVideoPlugin::loadPlugin("Live"); $p = AVideoPlugin::loadPlugin("Live");
$obj->user = User::getUserFromID($user->getBdId()); $obj->user = User::getUserFromID($user->getBdId());
$obj->livestream = LiveTransmition::getFromDbByUser($user->getBdId()); $obj->livestream = LiveTransmition::getFromDbByUser($user->getBdId());
$obj->livestream["server"] = $p->getServer()."?p=".$user->getPassword(); $obj->livestream["server"] = $p->getServer() . "?p=" . $user->getPassword();
return new ApiObject("", false, $obj); return new ApiObject("", false, $obj);
} else { } else {
@ -300,7 +300,6 @@ class API extends PluginAbstract {
} }
} }
/** /**
* @param type $parameters * @param type $parameters
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName} * @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
@ -358,6 +357,79 @@ class API extends PluginAbstract {
return new ApiObject("", false, $obj); return new ApiObject("", false, $obj);
} }
/**
* @param type $parameters
* Return all channels on this site
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
* @return \ApiObject
*/
public function get_api_channels($parameters) {
global $global;
require_once $global['systemRootPath'] . 'objects/Channel.php';
$channels = Channel::getChannels();
$list = array();
foreach ($channels as $value) {
$obj = new stdClass();
$obj->id = $value['id'];
$obj->photo = User::getPhoto($value['id']);
$obj->channelLink = User::getChannelLink($value['id']);
$obj->name = User::getNameIdentificationById($value['id']);
$list[] = $obj;
}
return new ApiObject("", false, $list);
}
/**
* @param type $parameters
* Return all Programs (Playlists) on this site
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
* @return \ApiObject
*/
public function get_api_programs($parameters) {
global $global;
require_once $global['systemRootPath'] . 'objects/category.php';
$playlists = PlayList::getAll();
foreach ($playlists as $value) {
$videosArrayId = PlayList::getVideosIdFromPlaylist($value['id']);
if (empty($videosArrayId) || $value['status'] == "favorite" || $value['status'] == "watch_later") {
continue;
}
$obj = new stdClass();
$obj->id = $value['id'];
$obj->photo = User::getPhoto($value['users_id']);
$obj->channelLink = User::getChannelLink($value['users_id']);
$obj->username = User::getNameIdentificationById($value['users_id']);
$obj->name = $value['name'];
$obj->link = PlayLists::getLink($value['id']);
$list[] = $obj;
}
return new ApiObject("", false, $list);
}
/**
* @param type $parameters
* Return all categories on this site
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
* @return \ApiObject
*/
public function get_api_categories($parameters) {
global $global;
require_once $global['systemRootPath'] . 'objects/category.php';
$categories = Category::getAllCategories();
array_multisort(array_column($categories, 'hierarchyAndName'), SORT_ASC, $categories);
$list = array();
foreach ($categories as $value) {
$obj = new stdClass();
$obj->id = $value['id'];
$obj->iconClass = $value['iconClass'];
$obj->hierarchyAndName = $value['hierarchyAndName'];
$obj->name = $value['name'];
$obj->fullTotal = $value['fullTotal'];
$obj->total = $value['total'];
$list[] = $obj;
}
return new ApiObject("", false, $list);
}
/** /**
* @param type $parameters * @param type $parameters

View file

@ -0,0 +1,22 @@
<?php
$configFile = '../../videos/configuration.php';
if (!file_exists($configFile)) {
list($scriptPath) = get_included_files();
$path = pathinfo($scriptPath);
$configFile = $path['dirname'] . "/" . $configFile;
}
require_once $configFile;
require_once $global['systemRootPath'].'plugin/API/API.php';
header('Content-Type: application/json');
$plugin = AVideoPlugin::loadPluginIfEnabled("API");
$objData = AVideoPlugin::getObjectDataIfEnabled("API");
if(empty($plugin)){
$obj = new ApiObject("API Plugin disabled");
}else{
$obj = new ApiObject("API Plugin enabled", false);
}
die(json_encode($obj));

View file

@ -138,7 +138,7 @@ if (!empty($videos)) {
<?php echo __("Make it public"); ?> <?php echo __("Make it public"); ?>
<div class="material-switch pull-right"> <div class="material-switch pull-right">
<input id="publicPlayList<?php echo $video['id']; ?>" name="publicPlayList" type="checkbox" checked="checked"/> <input id="publicPlayList<?php echo $video['id']; ?>" name="publicPlayList" type="checkbox" checked="checked"/>
<label for="publicPlayList" class="label-success"></label> <label for="publicPlayList<?php echo $video['id']; ?>" class="label-success"></label>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View file

@ -259,8 +259,8 @@ $(document).ready(function () {
} }
changingVideoFloat = 1; changingVideoFloat = 1;
var s = $(window).scrollTop(); var s = $(window).scrollTop();
console.log("$(window).scrollTop()= " + s); //console.log("$(window).scrollTop()= " + s);
console.log("mainVideoHeight = $('#videoContainer').innerHeight()= " + mainVideoHeight); //console.log("mainVideoHeight = $('#videoContainer').innerHeight()= " + mainVideoHeight);
if (s > mainVideoHeight) { if (s > mainVideoHeight) {
setFloatVideo(); setFloatVideo();
} else { } else {