Watermarked videos will download locally to serve
Enabled local download feature is back again with jQuery ajax request service. Currently in the testing phase for performance checkup.
This commit is contained in:
parent
80b76165b4
commit
74e39ac1ad
34
index.php
34
index.php
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$store_locally = false; /* change to false if you don't want to host videos locally */
|
$store_locally = true; /* change to false if you don't want to host videos locally */
|
||||||
|
|
||||||
function generateRandomString($length = 10) {
|
function generateRandomString($length = 10) {
|
||||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
@ -14,7 +14,7 @@ function generateRandomString($length = 10) {
|
|||||||
|
|
||||||
function downloadVideo($video_url, $geturl = false)
|
function downloadVideo($video_url, $geturl = false)
|
||||||
{
|
{
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
$options = array(
|
$options = array(
|
||||||
CURLOPT_URL => $video_url,
|
CURLOPT_URL => $video_url,
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
@ -48,6 +48,20 @@ function downloadVideo($video_url, $geturl = false)
|
|||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['url']) && !empty($_GET['url'])) {
|
||||||
|
if ($_SERVER['HTTP_REFERER'] != "") {
|
||||||
|
$url = $_GET['url'];
|
||||||
|
$name = downloadVideo($url);
|
||||||
|
echo $name;
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getContent($url, $geturl = false)
|
function getContent($url, $geturl = false)
|
||||||
{
|
{
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
@ -190,7 +204,19 @@ function getContent($url, $geturl = false)
|
|||||||
mkdir("user_videos");
|
mkdir("user_videos");
|
||||||
}
|
}
|
||||||
if ($store_locally){
|
if ($store_locally){
|
||||||
$filename = downloadVideo($contentURL);
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function(){
|
||||||
|
$('#wmarked_link').text("Please wait ...");
|
||||||
|
$.get('./<?php echo basename($_SERVER['PHP_SELF']); ?>?url=<?php echo urlencode($contentURL); ?>').done(function(data)
|
||||||
|
{
|
||||||
|
$('#wmarked_link').removeAttr('disabled');
|
||||||
|
$('#wmarked_link').attr('onclick', 'window.location.href="' + data + '"');
|
||||||
|
$('#wmarked_link').text("Download Video");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
@ -207,7 +233,7 @@ function getContent($url, $geturl = false)
|
|||||||
<div class="col-sm-6 col-md-6 col-lg-6 text-center mt-5"><ul style="list-style: none;padding: 0px">
|
<div class="col-sm-6 col-md-6 col-lg-6 text-center mt-5"><ul style="list-style: none;padding: 0px">
|
||||||
<li>a video by <b>@<?php echo $username; ?></b></li>
|
<li>a video by <b>@<?php echo $username; ?></b></li>
|
||||||
<li>uploaded on <b><?php echo $create_time; ?></b></li>
|
<li>uploaded on <b><?php echo $create_time; ?></b></li>
|
||||||
<li><button disabled="disabled" class="btn btn-primary mt-3" onclick="window.location.href='<?php if ($store_locally){ echo $filename;} else { echo $contentURL; } ?>'">Download Video</button> <button class="btn btn-info mt-3" onclick="window.location.href='<?php echo $cleanVideo; ?>'">Download Watermark Free!</button></li>
|
<li><button id="wmarked_link" disabled="disabled" class="btn btn-primary mt-3" onclick="window.location.href='<?php if ($store_locally){ echo $filename;} else { echo $contentURL; } ?>'">Download Video</button> <button class="btn btn-info mt-3" onclick="window.location.href='<?php echo $cleanVideo; ?>'">Download Watermark Free!</button></li>
|
||||||
<li><div class="alert alert-primary mb-0 mt-3">If the video opens directly, try saving it by pressing CTRL+S or on phone, save from three dots in the bottom left corner</div></li>
|
<li><div class="alert alert-primary mb-0 mt-3">If the video opens directly, try saving it by pressing CTRL+S or on phone, save from three dots in the bottom left corner</div></li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user