From 7d2f6e8fd66c558aea114d5defce2518ed643145 Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Thu, 26 Jan 2023 17:20:38 +0100 Subject: [PATCH] bump scraper --- app/Controllers/ProxyController.php | 59 +++++++++++++++-------------- composer.json | 2 +- composer.lock | 14 +++---- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/app/Controllers/ProxyController.php b/app/Controllers/ProxyController.php index 7121fb7..7c4d4e6 100644 --- a/app/Controllers/ProxyController.php +++ b/app/Controllers/ProxyController.php @@ -8,35 +8,6 @@ class ProxyController { "tiktokcdn.com", "tiktokcdn-us.com", "tiktok.com" ]; - static private function isValidDomain(string $url) { - $host = parse_url($url, PHP_URL_HOST); - $host_split = explode('.', $host); - $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 private function checkUrl() { - if (!isset($_GET['url'])) { - die('You need to send a URL'); - } - - if (!filter_var($_GET['url'], FILTER_VALIDATE_URL) || !self::isValidDomain($_GET['url'])) { - die('Not a valid URL'); - } - - } - - static private function getFilename(string $id, string $user): string { - $filename = 'tiktok-video-' . $id . '-' . $user; - return $filename; - } - static public function stream() { self::checkUrl(); $url = $_GET['url']; @@ -59,4 +30,34 @@ class ProxyController { // Running $downloader->url($url, $filename, $watermark); } + + static private function isValidDomain(string $url): bool { + $valid = false; + $host = parse_url($url, PHP_URL_HOST); + $host_split = explode('.', $host); + $host_count = count($host_split); + if ($host_count === 2) { + // Using no watermark + $valid = in_array($host_split[0] . '.' . $host_split[1], self::VALID_TIKTOK_DOMAINS); + } elseif ($host_count === 3) { + $valid = in_array($host_split[1] . '.' . $host_split[2], self::VALID_TIKTOK_DOMAINS); + } + return $valid; + } + + static private function checkUrl(): void { + if (!isset($_GET['url'])) { + die('You need to send a URL'); + } + + if (!filter_var($_GET['url'], FILTER_VALIDATE_URL) || !self::isValidDomain($_GET['url'])) { + die('Not a valid URL'); + } + + } + + static private function getFilename(string $id, string $user): string { + $filename = 'tiktok-video-' . $id . '-' . $user; + return $filename; + } } diff --git a/composer.json b/composer.json index ab5eb57..b6654a1 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "pablouser1/proxitok", "description": "An alternative frontend for TikTok", - "version": "2.4.4.2", + "version": "2.4.4.3", "license": "AGPL-3.0-or-later", "type": "project", "authors": [ diff --git a/composer.lock b/composer.lock index cde1627..9cc1f04 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c6c6c5ecb586c3f4701ffb57ccf385e4", + "content-hash": "acb47eb00001b55dbf6825b0ce79cd0b", "packages": [ { "name": "bramus/router", @@ -263,16 +263,16 @@ }, { "name": "pablouser1/tikscraper", - "version": "v2.3.3.4", + "version": "v2.3.3.5", "source": { "type": "git", "url": "https://github.com/pablouser1/TikScraperPHP.git", - "reference": "065cd740373f6f423d366d73ea94437041ec85cd" + "reference": "d3b51e6e0fab4cacce27dbbdf76bcb6fa8bf41ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/065cd740373f6f423d366d73ea94437041ec85cd", - "reference": "065cd740373f6f423d366d73ea94437041ec85cd", + "url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/d3b51e6e0fab4cacce27dbbdf76bcb6fa8bf41ef", + "reference": "d3b51e6e0fab4cacce27dbbdf76bcb6fa8bf41ef", "shasum": "" }, "require": { @@ -305,9 +305,9 @@ "description": "Get data from TikTok API", "support": { "issues": "https://github.com/pablouser1/TikScraperPHP/issues", - "source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.3.3.4" + "source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.3.3.5" }, - "time": "2023-01-25T14:17:57+00:00" + "time": "2023-01-26T16:19:23+00:00" }, { "name": "php-webdriver/webdriver",