From 23583ef7abfc7c4ade29891f3a6ef073b58e3cdb Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Mon, 24 Oct 2022 20:53:59 +0200 Subject: [PATCH] Fixed issue with download filename --- app/Controllers/ProxyController.php | 8 ++++---- app/Helpers/UrlBuilder.php | 4 ++-- app/Helpers/Wrappers.php | 4 ++-- components/themes/card.latte | 4 ++-- components/themes/common/download.latte | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/Controllers/ProxyController.php b/app/Controllers/ProxyController.php index bd27519..5f0a592 100644 --- a/app/Controllers/ProxyController.php +++ b/app/Controllers/ProxyController.php @@ -33,8 +33,7 @@ class ProxyController { } - static private function getFilename(string $url, string $user): string { - $id = Converter::urlToId($url); + static private function getFilename(string $id, string $user): string { $filename = 'tiktok-video-' . $id . '-' . $user; return $filename; } @@ -52,12 +51,13 @@ class ProxyController { $downloader = new \TikScraper\Download($method); // Params + $id = $_GET['id'] ?? ''; $watermark = isset($_GET['watermark']); $url = $_GET['url']; $user = $_GET['user'] ?? ''; // Filename - $filename = self::getFilename($url, $user); + $filename = self::getFilename($id, $user); // Running - $downloader->url($_GET['url'], $filename, $watermark); + $downloader->url($url, $filename, $watermark); } } diff --git a/app/Helpers/UrlBuilder.php b/app/Helpers/UrlBuilder.php index 96d3d89..62bff30 100644 --- a/app/Helpers/UrlBuilder.php +++ b/app/Helpers/UrlBuilder.php @@ -6,9 +6,9 @@ class UrlBuilder { return Misc::url('/stream?url=' . urlencode($url)); } - static public function download(string $url, string $username, bool $watermark): string { + static public function download(string $url, string $username, string $id, bool $watermark): string { // {path('/download?url=' . urlencode($playAddr) . '&id=' . $id . '&user=' . $uniqueId) . '&watermark=1'} - $down_url = Misc::url('/download?url=' . urlencode($url) . '&user=' . $username); + $down_url = Misc::url('/download?url=' . urlencode($url) . '&id=' . $id . '&user=' . $username); if ($watermark) $down_url .= '&watermark=1'; return $down_url; } diff --git a/app/Helpers/Wrappers.php b/app/Helpers/Wrappers.php index 49ba9d5..1c8f10f 100644 --- a/app/Helpers/Wrappers.php +++ b/app/Helpers/Wrappers.php @@ -43,8 +43,8 @@ class Wrappers { $latte->addFunction('url_video_external', function (string $username, string $id): string { return UrlBuilder::video_external($username, $id); }); - $latte->addFunction('url_download', function (string $url, string $username, bool $watermark): string { - return UrlBuilder::download($url, $username, $watermark); + $latte->addFunction('url_download', function (string $url, string $username, string $id, bool $watermark): string { + return UrlBuilder::download($url, $username, $id, $watermark); }); // https://stackoverflow.com/a/36365553 $latte->addFunction('number', function (float $x) { diff --git a/components/themes/card.latte b/components/themes/card.latte index 23265a6..ce5629c 100644 --- a/components/themes/card.latte +++ b/components/themes/card.latte @@ -6,8 +6,8 @@ {do $share_url = url_video_external($item->author->uniqueId, $item->id)}