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

Version 7.5 Adding Articles support

This commit is contained in:
daniel 2019-08-15 13:18:43 -03:00
parent e1d4f66780
commit 20205359cd
9 changed files with 127 additions and 42 deletions

View file

@ -9,6 +9,7 @@ class BulkEmbed extends PluginAbstract {
//$str = 'Set DEVELOPER_KEY to the "API key" value from the "Access" tab of the<br>Google Developers Console https://console.developers.google.com<br>Please ensure that you have enabled the YouTube Data API for your project.';
//$str.= '<br>Add the Redirect URI '.$global['webSiteRootURL'].'plugin/BulkEmbed/youtubeSearch.json.php';
$str = 'Create your API Key here https://console.developers.google.com/apis/credentials/key';
$str .= "<br> Also make sure you enable the API YouTube Data API v3";
return $str;
}

View file

@ -193,6 +193,38 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
}, 500);
}
function validURL(str) {
var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
'(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
return !!pattern.test(str);
}
function getFromUrl(url) {
if (!validURL(url)) {
return false;
}
var regex = /[?&]([^=#]+)=([^&#]*)/g,
params = {},
match;
while (match = regex.exec(url)) {
params[match[1]] = match[2];
}
return params;
}
function getPlayListId(url) {
var result = getFromUrl(url);
if (result && typeof result.list !== 'undefined') {
return result.list;
}
return false;
}
function search() {
// clear
$('#results').html('');
@ -201,6 +233,22 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
// get form input
q = $('#query').val(); // this probably shouldn't be created as a global
var playListId = getPlayListId(q);
if (playListId) {
$.get(
"https://www.googleapis.com/youtube/v3/playlistItems", {
part: 'snippet, id',
q: q,
type: 'video',
key: gapikey,
maxResults: 50,
videoEmbeddable: "true",
playlistId: playListId
}, function (data) {
processData(data);
});
} else {
// run get request on API
$.get(
"https://www.googleapis.com/youtube/v3/search", {
@ -211,6 +259,13 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
maxResults: 50,
videoEmbeddable: "true"
}, function (data) {
processData(data);
});
}
}
function processData(data) {
var nextPageToken = data.nextPageToken;
var prevPageToken = data.prevPageToken;
@ -229,7 +284,6 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
// Display buttons
$('#buttons').append(buttons);
});
}
// Next page function

View file

@ -58,7 +58,7 @@ if (!empty($videos)) {
<div class="col-md-10 col-md-offset-1 list-group-item">
<div class="clear clearfix"><?php echo $video['creator']; ?> </div>
<h2><?php echo $video['title']; ?></h2>
<div><?php echo nl2br(textToLink($video['description'])); ?></div>
<div><?php echo $video['description']; ?></div>
<div class="main-video embed-responsive <?php
echo $embedResponsiveClass;
?>">

View file

@ -163,10 +163,16 @@ function createGallerySection($videos, $crc = "", $get = array()) {
$startG = microtime(true);
?>
</div>
<?php
if($value['type']!=='pdf' && $value['type']!=='article'){
?>
<span class="duration"><?php echo Video::getCleanDuration($value['duration']); ?></span>
<div class="progress" style="height: 3px; margin-bottom: 2px;">
<div class="progress-bar progress-bar-danger" role="progressbar" style="width: <?php echo $value['progress']['percent'] ?>%;" aria-valuenow="<?php echo $value['progress']['percent'] ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<?php
}
?>
</a>
<a class="h6 galleryLink" videos_id="<?php echo $value['id']; ?>" href="<?php echo Video::getLink($value['id'], $value['clean_title'], false, $getCN); ?>" title="<?php echo $value['title']; ?>">
<h2><?php echo $value['title']; ?></h2>
@ -230,7 +236,7 @@ function createGallerySection($videos, $crc = "", $get = array()) {
<?php echo $name; ?>
</a>
<?php if ((!empty($value['description'])) && !empty($obj->Description)) { ?>
<button type="button" data-trigger="focus" class="label label-danger" data-toggle="popover" data-placement="top" data-html="true" title="<?php echo $value['title']; ?>" data-content="<div> <?php echo str_replace('"', '&quot;', nl2br(textToLink($value['description']))); ?> </div>" ><?php echo __("Description"); ?></button>
<button type="button" data-trigger="focus" class="label label-danger" data-toggle="popover" data-placement="top" data-html="true" title="<?php echo $value['title']; ?>" data-content="<div> <?php echo str_replace('"', '&quot;', $value['description']); ?> </div>" ><?php echo __("Description"); ?></button>
<?php } ?>
</div>
<?php if (Video::canEdit($value['id'])) { ?>

View file

@ -23,10 +23,16 @@ if ($obj->BigVideo && empty($_GET['showOnly'])) {
<img src="<?php echo $global['webSiteRootURL']; ?>view/img/loading-gif.png" data-src="<?php echo $imgGif; ?>" style="position: absolute; top: 0; display: none;" alt="<?php echo $video['title']; ?>" id="thumbsGIF<?php echo $video['id']; ?>" class="thumbsGIF img-responsive <?php echo @$img_portrait; ?> rotate<?php echo $video['rotation']; ?>" height="130" />
<?php } ?>
</div>
<?php
if ($video['type'] !== 'pdf' && $video['type'] !== 'article') {
?>
<span class="duration"><?php echo Video::getCleanDuration($video['duration']); ?></span>
<div class="progress" style="height: 3px; margin-bottom: 2px;">
<div class="progress-bar progress-bar-danger" role="progressbar" style="width: <?php echo $video['progress']['percent'] ?>%;" aria-valuenow="<?php echo $video['progress']['percent'] ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<?php
}
?>
</a>
</div>
<div class="col-sm-6">
@ -34,7 +40,7 @@ if ($obj->BigVideo && empty($_GET['showOnly'])) {
<h1><?php echo $video['title']; ?></h1>
</a>
<div class="mainAreaDescriptionContainer">
<h4 class="mainAreaDescription" itemprop="description"><?php echo nl2br(textToLink($video['description'])); ?></h4>
<h4 class="mainAreaDescription" itemprop="description"><?php echo $video['description']; ?></h4>
</div>
<div class="text-muted galeryDetails">
<div>

View file

@ -129,7 +129,7 @@ if ($obj->BigVideo && empty($_GET['showOnly'])) {
?>
<div class="infoText col-md-4 col-sm-6 col-xs-6">
<h4 class="mainInfoText" itemprop="description">
<?php echo nl2br(textToLink($video['description'])); ?>
<?php echo $video['description']; ?>
</h4>
<?php
if (YouPHPTubePlugin::isEnabledByName("VideoTags")) {

View file

@ -156,7 +156,7 @@ foreach ($videos as $value) {
?>
<div class="infoText col-md-4 col-sm-6 col-xs-8">
<h4 class="mainInfoText" itemprop="description">
<?php echo nl2br(textToLink($value['description'])); ?>
<?php echo $value['description']; ?>
</h4>
<?php
if (YouPHPTubePlugin::isEnabledByName("VideoTags")) {

View file

@ -23,10 +23,16 @@ if ($objYTube->BigVideo && empty($_GET['showOnly'])) {
<img src="<?php echo $global['webSiteRootURL']; ?>view/img/loading-gif.png" data-src="<?php echo $imgGif; ?>" style="position: absolute; top: 0; display: none;" alt="<?php echo $video['title']; ?>" id="thumbsGIF<?php echo $video['id']; ?>" class="thumbsGIF img-responsive <?php echo @$img_portrait; ?> rotate<?php echo $video['rotation']; ?>" height="130" />
<?php } ?>
</div>
<?php
if ($video['type'] !== 'pdf' && $video['type'] !== 'article') {
?>
<span class="duration"><?php echo Video::getCleanDuration($video['duration']); ?></span>
<div class="progress" style="height: 3px; margin-bottom: 2px;">
<div class="progress-bar progress-bar-danger" role="progressbar" style="width: <?php echo $video['progress']['percent'] ?>%;" aria-valuenow="<?php echo $video['progress']['percent'] ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<?php
}
?>
</a>
</div>
<div class="col-sm-6">
@ -34,7 +40,7 @@ if ($objYTube->BigVideo && empty($_GET['showOnly'])) {
<h1><?php echo $video['title']; ?></h1>
</a>
<div class="mainAreaDescriptionContainer">
<h4 class="mainAreaDescription" itemprop="description"><?php echo nl2br(textToLink($video['description'])); ?></h4>
<h4 class="mainAreaDescription" itemprop="description"><?php echo $video['description']; ?></h4>
</div>
<div class="text-muted galeryDetails">
<div>

View file

@ -0,0 +1,12 @@
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
ALTER TABLE `videos`
CHANGE COLUMN `type` `type` ENUM('audio', 'video', 'embed', 'linkVideo', 'linkAudio', 'torrent', 'pdf', 'image', 'gallery', 'article') NOT NULL DEFAULT 'video';
UPDATE configurations SET version = '7.5', modified = now() WHERE id = 1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;