Fixed issue with download filename
This commit is contained in:
parent
6fafcdcd11
commit
23583ef7ab
|
@ -33,8 +33,7 @@ class ProxyController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static private function getFilename(string $url, string $user): string {
|
static private function getFilename(string $id, string $user): string {
|
||||||
$id = Converter::urlToId($url);
|
|
||||||
$filename = 'tiktok-video-' . $id . '-' . $user;
|
$filename = 'tiktok-video-' . $id . '-' . $user;
|
||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
@ -52,12 +51,13 @@ class ProxyController {
|
||||||
$downloader = new \TikScraper\Download($method);
|
$downloader = new \TikScraper\Download($method);
|
||||||
|
|
||||||
// Params
|
// Params
|
||||||
|
$id = $_GET['id'] ?? '';
|
||||||
$watermark = isset($_GET['watermark']);
|
$watermark = isset($_GET['watermark']);
|
||||||
$url = $_GET['url'];
|
$url = $_GET['url'];
|
||||||
$user = $_GET['user'] ?? '';
|
$user = $_GET['user'] ?? '';
|
||||||
// Filename
|
// Filename
|
||||||
$filename = self::getFilename($url, $user);
|
$filename = self::getFilename($id, $user);
|
||||||
// Running
|
// Running
|
||||||
$downloader->url($_GET['url'], $filename, $watermark);
|
$downloader->url($url, $filename, $watermark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ class UrlBuilder {
|
||||||
return Misc::url('/stream?url=' . urlencode($url));
|
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'}
|
// {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';
|
if ($watermark) $down_url .= '&watermark=1';
|
||||||
return $down_url;
|
return $down_url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,8 @@ class Wrappers {
|
||||||
$latte->addFunction('url_video_external', function (string $username, string $id): string {
|
$latte->addFunction('url_video_external', function (string $username, string $id): string {
|
||||||
return UrlBuilder::video_external($username, $id);
|
return UrlBuilder::video_external($username, $id);
|
||||||
});
|
});
|
||||||
$latte->addFunction('url_download', function (string $url, string $username, bool $watermark): string {
|
$latte->addFunction('url_download', function (string $url, string $username, string $id, bool $watermark): string {
|
||||||
return UrlBuilder::download($url, $username, $watermark);
|
return UrlBuilder::download($url, $username, $id, $watermark);
|
||||||
});
|
});
|
||||||
// https://stackoverflow.com/a/36365553
|
// https://stackoverflow.com/a/36365553
|
||||||
$latte->addFunction('number', function (float $x) {
|
$latte->addFunction('number', function (float $x) {
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
{do $share_url = url_video_external($item->author->uniqueId, $item->id)}
|
{do $share_url = url_video_external($item->author->uniqueId, $item->id)}
|
||||||
<div class="column is-one-quarter clickable-img" id="{$item->id}" onclick="openVideo(this.id)"
|
<div class="column is-one-quarter clickable-img" id="{$item->id}" onclick="openVideo(this.id)"
|
||||||
data-video_url="{url_stream($item->video->playAddr)}"
|
data-video_url="{url_stream($item->video->playAddr)}"
|
||||||
data-video_download_watermark="{url_download($item->video->playAddr, $item->author->uniqueId, true)}"
|
data-video_download_watermark="{url_download($item->video->playAddr, $item->author->uniqueId, $item->id, true)}"
|
||||||
data-video_download_nowatermark="{url_download($item->video->playAddr, $item->author->uniqueId, false)}"
|
data-video_download_nowatermark="{url_download(url_video_external($item->author->uniqueId, $item->id), $item->author->uniqueId, $item->id, false)}"
|
||||||
data-video_share_url="{$share_url}"
|
data-video_share_url="{$share_url}"
|
||||||
data-desc="{$item->desc}"
|
data-desc="{$item->desc}"
|
||||||
data-createtime="{$item->createTime}"
|
data-createtime="{$item->createTime}"
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown-menu" role="menu">
|
<div class="dropdown-menu" role="menu">
|
||||||
<div class="dropdown-content">
|
<div class="dropdown-content">
|
||||||
<a target="_blank" href="{url_download($playAddr, $uniqueId, true)}" class="dropdown-item">Watermark</a>
|
<a target="_blank" href="{url_download($playAddr, $uniqueId, $id, true)}" class="dropdown-item">Watermark</a>
|
||||||
<a target="_blank" href="{url_download(url_video_external($uniqueId, $id), $uniqueId, false)}" class="dropdown-item">No watermark</a>
|
<a target="_blank" href="{url_download(url_video_external($uniqueId, $id), $uniqueId, $id, false)}" class="dropdown-item">No watermark</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue