From 2c73bd03880359013ad8cb93b8f4c6659cae47bf Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Mon, 7 Feb 2022 21:07:51 +0100 Subject: [PATCH] Allow download without watermark --- app/Controllers/ProxyController.php | 12 ++++++++++-- components/feed.latte | 9 +++++++-- composer.json | 2 +- composer.lock | 10 +++++----- scripts/feed.js | 8 +++++--- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/app/Controllers/ProxyController.php b/app/Controllers/ProxyController.php index a17e385..84abacb 100644 --- a/app/Controllers/ProxyController.php +++ b/app/Controllers/ProxyController.php @@ -9,7 +9,14 @@ class ProxyController { static private function isValidDomain(string $url) { $host = parse_url($url, PHP_URL_HOST); $host_split = explode('.', $host); - return count($host_split) === 3 && in_array($host_split[1] . '.' . $host_split[2], self::VALID_TIKTOK_DOMAINS); + $host_count = count($host_split); + if ($host_count === 2) { + // Using no watermark + return in_array($host_split[0] . '.' . $host_split[1], self::VALID_TIKTOK_DOMAINS); + } elseif ($host_count === 3) { + return in_array($host_split[1] . '.' . $host_split[2], self::VALID_TIKTOK_DOMAINS); + } + return false; } static public function stream() { @@ -29,7 +36,8 @@ class ProxyController { if (isset($_GET['id'], $_GET['user'])) { $filename .= '-' . $_GET['user'] . '-' . $_GET['id']; } - $downloader->url($url, $filename, 'mp4'); + $watermark = isset($_GET['watermark']); + $downloader->url($url, $filename, $watermark); } else { // Stream $streamer = new \Sovit\TikTok\Stream(); diff --git a/components/feed.latte b/components/feed.latte index d1ed201..b31ca8f 100644 --- a/components/feed.latte +++ b/components/feed.latte @@ -6,7 +6,8 @@
@@ -38,7 +39,11 @@