diff --git a/app/Controllers/ProxyController.php b/app/Controllers/ProxyController.php index 84abacb..cf0ec77 100644 --- a/app/Controllers/ProxyController.php +++ b/app/Controllers/ProxyController.php @@ -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); } diff --git a/components/feed.latte b/components/feed.latte index 7ca826f..d4af815 100644 --- a/components/feed.latte +++ b/components/feed.latte @@ -7,7 +7,7 @@
- Download with watermark + Download with watermark Download without watermark
-

Please be patient with the No Watermark option. It takes a while to download

diff --git a/composer.json b/composer.json index 57fb793..01de09d 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index 243f44e..7221a56 100644 --- a/composer.lock +++ b/composer.lock @@ -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",