No watermark without external service

This commit is contained in:
Pablo Ferreiro 2022-02-07 23:45:07 +01:00
parent 7203bc1509
commit fccec753d9
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
4 changed files with 36 additions and 20 deletions

View file

@ -19,27 +19,44 @@ class ProxyController {
return false;
}
static public function stream() {
static private function checkUrl() {
if (!isset($_GET['url'])) {
die('You need to send a url!');
die('You need to send a URL');
}
$url = $_GET['url'];
if (!filter_var($url, FILTER_VALIDATE_URL) || !self::isValidDomain($url)) {
if (!filter_var($_GET['url'], FILTER_VALIDATE_URL) || !self::isValidDomain($_GET['url'])) {
die('Not a valid URL');
}
}
static private function getFileName(): string {
$filename = 'tiktok-video';
if (isset($_GET['user'])) {
$filename .= '-' . $_GET['user'] . '-' . $_GET['id'];
}
return $filename;
}
static public function stream() {
if (isset($_GET['download'])) {
// Download
$downloader = new \Sovit\TikTok\Download();
$filename = 'tiktok-video';
if (isset($_GET['id'], $_GET['user'])) {
$filename .= '-' . $_GET['user'] . '-' . $_GET['id'];
}
$watermark = isset($_GET['watermark']);
$downloader->url($url, $filename, $watermark);
if ($watermark) {
self::checkUrl();
$filename = self::getFileName();
$downloader = new \Sovit\TikTok\Download();
$downloader->url($_GET['url'], $filename, true);
} else {
if (!isset($_GET['id'])) {
die('You need to send an ID!');
}
$filename = self::getFileName();
$downloader = new \Sovit\TikTok\Download();
$downloader->url($_GET['id'], $filename, false);
}
} else {
// Stream
self::checkUrl();
$url = $_GET['url'];
$streamer = new \Sovit\TikTok\Stream();
$streamer->stream($url);
}

View file

@ -7,7 +7,7 @@
<div class="column is-one-quarter clickable-img" id="{$item->id}" onclick="openVideo(this.id)"
data-video_url="{path('/stream?url=' . urlencode($item->video->playAddr))}"
data-video_download_watermark="{path('/stream?url=' . urlencode($item->video->playAddr) . '&download=1&id=' . $item->id . '&user=' . $item->author->uniqueId) . '&watermark='}"
data-video_download_nowatermark="{path('/stream?url=' . urlencode($share_url) . '&download=1&id=' . $item->id . '&user=' . $item->author->uniqueId)}"
data-video_download_nowatermark="{path('/stream?download=1&id=' . $item->id . '&user=' . $item->author->uniqueId)}"
data-video_share_url="{$share_url}"
data-desc="{$item->desc}"
data-music_title="{$item->music->title}"
@ -48,10 +48,9 @@
</div>
</div>
<div class="buttons is-centered">
<a target="_blank" id="download_watermark" class="button is-info" download>Download with watermark</a>
<a target="_blank" id="download_watermark" class="button is-info">Download with watermark</a>
<a target="_blank" id="download_nowatermark" class="button is-info">Download without watermark</a>
</div>
<p>Please be patient with the No Watermark option. It takes a while to download</p>
<p id="audio_title"></p>
<audio id="audio" controls preload="none"></audio>
<div class="buttons is-centered">

View file

@ -1,7 +1,7 @@
{
"name": "pablouser1/proxitok",
"description": "An alternative frontend for TikTok",
"version": "1.4.1.3",
"version": "1.4.1.4",
"license": "AGPL-3.0-or-later",
"type": "project",
"homepage": "https://github.com/pablouser1/ProxiTok",

8
composer.lock generated
View file

@ -381,12 +381,12 @@
"source": {
"type": "git",
"url": "https://github.com/pablouser1/TikTok-API-PHP.git",
"reference": "390d12b967e0e072227171d8bdc6cfb4544a11f2"
"reference": "60c00cfd321888b80eba93b6214c8c4003e98e57"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pablouser1/TikTok-API-PHP/zipball/390d12b967e0e072227171d8bdc6cfb4544a11f2",
"reference": "390d12b967e0e072227171d8bdc6cfb4544a11f2",
"url": "https://api.github.com/repos/pablouser1/TikTok-API-PHP/zipball/60c00cfd321888b80eba93b6214c8c4003e98e57",
"reference": "60c00cfd321888b80eba93b6214c8c4003e98e57",
"shasum": ""
},
"type": "library",
@ -425,7 +425,7 @@
"issues": "https://github.com/ssovit/TikTok-API-PHP/issues",
"email": "sovit.tamrakar@gmail.com"
},
"time": "2022-02-07T20:13:16+00:00"
"time": "2022-02-07T22:43:53+00:00"
},
{
"name": "symfony/polyfill-ctype",