More details of user or tag
This commit is contained in:
parent
31e3aafbd7
commit
493f56a052
|
@ -15,41 +15,6 @@ function isValidDomain(string $url): bool {
|
||||||
return count($host_split) === 3 && in_array($host_split[1] . '.' . $host_split[2], $valid_domains);
|
return count($host_split) === 3 && in_array($host_split[1] . '.' . $host_split[2], $valid_domains);
|
||||||
}
|
}
|
||||||
|
|
||||||
Route::add('/images', function () {
|
|
||||||
if (!isset($_GET['url'])) {
|
|
||||||
die('You need to send a url!');
|
|
||||||
}
|
|
||||||
$url = $_GET['url'];
|
|
||||||
if (!filter_var($url, FILTER_VALIDATE_URL) || !isValidDomain($url)) {
|
|
||||||
die('Not a valid URL');
|
|
||||||
}
|
|
||||||
$img = file_get_contents($url, false, stream_context_create(['http' => ['ignore_errors' => true]]));
|
|
||||||
if ($img) {
|
|
||||||
header('Content-Type: image/jpeg');
|
|
||||||
return $img;
|
|
||||||
} else {
|
|
||||||
return 'Error while getting image!';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::add('/audios', function () {
|
|
||||||
if (!isset($_GET['url'])) {
|
|
||||||
die('You need to send a url!');
|
|
||||||
}
|
|
||||||
$url = $_GET['url'];
|
|
||||||
|
|
||||||
if (!filter_var($url, FILTER_VALIDATE_URL) || !isValidDomain($url)) {
|
|
||||||
die('Not a valid URL');
|
|
||||||
}
|
|
||||||
$audio = file_get_contents($url, false, stream_context_create(['http' => ['ignore_errors' => true]]));
|
|
||||||
if ($audio) {
|
|
||||||
header('Content-Type: audio/mp3');
|
|
||||||
return $audio;
|
|
||||||
} else {
|
|
||||||
return 'Error while getting audio!';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::add('/stream', function () {
|
Route::add('/stream', function () {
|
||||||
if (!isset($_GET['url'])) {
|
if (!isset($_GET['url'])) {
|
||||||
die('You need to send a url!');
|
die('You need to send a url!');
|
||||||
|
@ -61,9 +26,9 @@ Route::add('/stream', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['download'])) {
|
if (isset($_GET['download'])) {
|
||||||
// Download
|
// Download (video only)
|
||||||
$downloader = new \Sovit\TikTok\Download();
|
$downloader = new \Sovit\TikTok\Download();
|
||||||
$downloader->url($url,"tiktok-video",'mp4');
|
$downloader->url($url, "tiktok-video", 'mp4');
|
||||||
} else {
|
} else {
|
||||||
// Stream
|
// Stream
|
||||||
$streamer = new \Sovit\TikTok\Stream();
|
$streamer = new \Sovit\TikTok\Stream();
|
||||||
|
|
|
@ -29,6 +29,20 @@ function getLatte(): \Latte\Engine {
|
||||||
$path = "{$subdir}/{$name}";
|
$path = "{$subdir}/{$name}";
|
||||||
return $path;
|
return $path;
|
||||||
});
|
});
|
||||||
|
// https://stackoverflow.com/a/36365553
|
||||||
|
$latte->addFunction('number', function (int $x) {
|
||||||
|
if($x > 1000) {
|
||||||
|
$x_number_format = number_format($x);
|
||||||
|
$x_array = explode(',', $x_number_format);
|
||||||
|
$x_parts = array('K', 'M', 'B', 'T');
|
||||||
|
$x_count_parts = count($x_array) - 1;
|
||||||
|
$x_display = $x;
|
||||||
|
$x_display = $x_array[0] . ((int) $x_array[1][0] !== 0 ? '.' . $x_array[1][0] : '');
|
||||||
|
$x_display .= $x_parts[$x_count_parts - 1];
|
||||||
|
return $x_display;
|
||||||
|
}
|
||||||
|
return $x;
|
||||||
|
});
|
||||||
return $latte;
|
return $latte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,15 @@
|
||||||
data-video_width="{$item->video->width}"
|
data-video_width="{$item->video->width}"
|
||||||
data-video_height="{$item->video->height}"
|
data-video_height="{$item->video->height}"
|
||||||
data-music_title="{$item->music->title}"
|
data-music_title="{$item->music->title}"
|
||||||
data-music_url="{path('audios?url=' . urlencode($item->music->playUrl))}">
|
data-music_url="{path('stream?url=' . urlencode($item->music->playUrl))}">
|
||||||
<img loading="lazy" src="{path('images?url=' . urlencode($item->video->originCover))}"/>
|
<img loading="lazy" src="{path('stream?url=' . urlencode($item->video->originCover))}"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a n:ifset="$_GET['cursor']" class="button is-danger" href="?cursor=0">First</a>
|
<a n:ifset="$_GET['cursor']" class="button is-danger" href="?cursor=0">First</a>
|
||||||
<a class="button is-danger" href="javascript:history.back()">Back</a>
|
<a class="button is-danger" href="?cursor={$feed->minCursor}">Back</a>
|
||||||
{if $feed->hasMore}
|
{if $feed->hasMore}
|
||||||
<a n-if="$feed->hasMore" class="button is-success" href="?cursor={$feed->maxCursor}">Next</a>
|
<a n-if="$feed->hasMore" class="button is-success" href="?cursor={$feed->maxCursor}">Next</a>
|
||||||
{else}
|
{else}
|
||||||
|
@ -26,6 +26,8 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- MODAL -->
|
||||||
<div id="modal" class="modal">
|
<div id="modal" class="modal">
|
||||||
<div id="modal-background" class="modal-background"></div>
|
<div id="modal-background" class="modal-background"></div>
|
||||||
<div class="modal-card">
|
<div class="modal-card">
|
||||||
|
@ -38,7 +40,7 @@
|
||||||
</section>
|
</section>
|
||||||
<footer class="modal-card-foot has-text-centered">
|
<footer class="modal-card-foot has-text-centered">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a id="download_button" target="_blank" class="button is-info" href="" download>Download</a>
|
<a id="download_button" target="_blank" class="button is-info" download>Download</a>
|
||||||
<p id="audio_title"></p>
|
<p id="audio_title"></p>
|
||||||
<audio id="audio" controls preload="none"></audio>
|
<audio id="audio" controls preload="none"></audio>
|
||||||
<div class="buttons is-centered">
|
<div class="buttons is-centered">
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
{include 'components/navbar.latte'}
|
{include 'components/navbar.latte'}
|
||||||
<section class="hero is-primary">
|
<section class="hero is-primary">
|
||||||
<div class="hero-body">
|
<div class="hero-body">
|
||||||
<div class="container">
|
<div class="container has-text-centered">
|
||||||
<p class="title">{$feed->info->detail->challenge->title}</p>
|
<p class="title">{$feed->info->detail->challenge->title}</p>
|
||||||
<p class="subtitle">{$feed->info->detail->challenge->desc}</p>
|
<p class="subtitle">{$feed->info->detail->challenge->desc}</p>
|
||||||
|
<p>Videos: {number($feed->info->detail->stats->videoCount)} / Views: {number($feed->info->detail->stats->viewCount)}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
{include 'components/navbar.latte'}
|
{include 'components/navbar.latte'}
|
||||||
<section class="hero is-primary">
|
<section class="hero is-primary">
|
||||||
<div class="hero-body">
|
<div class="hero-body">
|
||||||
<div class="container">
|
<div class="container has-text-centered">
|
||||||
<p class="title">Trending page</p>
|
<p class="title">Trending page</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,9 +7,14 @@
|
||||||
{include 'components/navbar.latte'}
|
{include 'components/navbar.latte'}
|
||||||
<section class="hero is-primary">
|
<section class="hero is-primary">
|
||||||
<div class="hero-body">
|
<div class="hero-body">
|
||||||
<div class="container">
|
<div class="container has-text-centered">
|
||||||
|
<figure class="figure is-96x96">
|
||||||
|
<img src="{path('stream?url=' . urlencode($feed->info->detail->user->avatarThumb))}" />
|
||||||
|
</figure>
|
||||||
<p class="title">{$feed->info->detail->user->uniqueId}'s profile</p>
|
<p class="title">{$feed->info->detail->user->uniqueId}'s profile</p>
|
||||||
<p class="subtitle">{$feed->info->detail->user->signature}</p>
|
<p class="subtitle">{$feed->info->detail->user->signature}</p>
|
||||||
|
<p>Following: {number($feed->info->detail->stats->followingCount)} / Followers: {number($feed->info->detail->stats->followerCount)}</p>
|
||||||
|
<p>Hearts: {number($feed->info->detail->stats->heartCount)} / Videos: {$feed->info->detail->stats->videoCount}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in a new issue