Instance-level proxy and test endpoint fix
This commit is contained in:
parent
279a4f50c6
commit
d60e4400a2
10
.env.example
10
.env.example
|
@ -2,8 +2,14 @@
|
|||
# LATTE_CACHE=/tmp/proxitok_api # Path for Latte cache, leave commented for ./cache/latte
|
||||
|
||||
# API CONFIG
|
||||
# USE_TEST_ENDPOINTS=1 # Discomment for usage of t.tiktok.com
|
||||
# SIGNER_URL="https://tiktok-sign.herokuapp.com/signature" # External signing service
|
||||
# USE_TEST_ENDPOINTS=1 # Discomment for usage of testing TikTok endpoints, may help sometimes
|
||||
# SIGNER_URL="https://example.com" # External signing service
|
||||
|
||||
# Proxy Config, will be used to make TikTok requests, useful if having VERIFY_CODE issues
|
||||
# PROXY_HOST=HOSTNAME
|
||||
# PROXY_PORT=8080
|
||||
# PROXY_USERNAME=USERNAME
|
||||
# PROXY_PASSWORD=PASSWORD
|
||||
# API_CACHE=redis # Cache engine for TikTok Api, (more info on README)
|
||||
|
||||
# Redis cache, used on Helpers\CacheEngines\RedisCache
|
||||
|
|
|
@ -8,7 +8,7 @@ use App\Models\SettingsTemplate;
|
|||
class SettingsController {
|
||||
static public function index() {
|
||||
$latte = Misc::latte();
|
||||
$latte->render(Misc::getView('settings'), new SettingsTemplate());
|
||||
$latte->render(Misc::getView('settings'), new SettingsTemplate);
|
||||
}
|
||||
|
||||
static public function proxy() {
|
||||
|
|
|
@ -13,8 +13,9 @@ class UserController {
|
|||
$feed = $api->getUserFeed($username, $cursor);
|
||||
if ($feed->meta->success) {
|
||||
if ($feed->info->detail->privateAccount) {
|
||||
http_response_code(400);
|
||||
http_response_code(403);
|
||||
echo 'Private account detected! Not supported';
|
||||
exit;
|
||||
}
|
||||
$latte = Misc::latte();
|
||||
$latte->render(Misc::getView('user'), new FeedTemplate($feed->info->detail->nickname, $feed));
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
namespace App\Helpers;
|
||||
|
||||
class Cookies {
|
||||
const PROXY = ['proxy-host', 'proxy-port', 'proxy-username', 'proxy-password'];
|
||||
const PROXY = ['host', 'port', 'user', 'password'];
|
||||
|
||||
static public function get(string $name): string {
|
||||
static public function get(string $name): ?string {
|
||||
if (isset($_COOKIE[$name]) && !empty($_COOKIE[$name])) {
|
||||
return $_COOKIE[$name];
|
||||
}
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
static public function exists(string $name): bool {
|
||||
|
|
|
@ -17,7 +17,7 @@ class Misc {
|
|||
return self::env('APP_URL', '') . $endpoint;
|
||||
}
|
||||
|
||||
static public function env(string $key, string $default_value): string {
|
||||
static public function env(string $key, $default_value) {
|
||||
return $_ENV[$key] ?? $default_value;
|
||||
}
|
||||
|
||||
|
@ -34,16 +34,23 @@ class Misc {
|
|||
static public function api(): \TikScraper\Api {
|
||||
$options = [
|
||||
'remote_signer' => self::env('SIGNER_URL', 'http://localhost:8080/signature'),
|
||||
'use_test_endpoints' => self::env('USE_TEST_ENDPOINTS', false)
|
||||
'use_test_endpoints' => self::env('USE_TEST_ENDPOINTS', false),
|
||||
// Instance level proxy config
|
||||
'proxy' => [
|
||||
'host' => self::env('PROXY_HOST', null),
|
||||
'port' => self::env('PROXY_PORT', null),
|
||||
'user' => self::env('PROXY_USER', null),
|
||||
'password' => self::env('PROXY_PASSWORD', null)
|
||||
]
|
||||
];
|
||||
$cacheEngine = false;
|
||||
// Proxy config
|
||||
// User level proxy config, will overwrite instance config
|
||||
foreach(Cookies::PROXY as $proxy_element) {
|
||||
if (isset($_COOKIE[$proxy_element])) {
|
||||
$options['proxy'][$proxy_element] = $_COOKIE[$proxy_element];
|
||||
}
|
||||
}
|
||||
// Cache config
|
||||
$cacheEngine = false;
|
||||
if (isset($_ENV['API_CACHE'])) {
|
||||
switch ($_ENV['API_CACHE']) {
|
||||
case 'json':
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<div class="tags">
|
||||
{if !empty($following)}
|
||||
{foreach $following as $user}
|
||||
<span class="tag">{$user}</span>
|
||||
{/foreach}
|
||||
{else}
|
||||
<p>None</p>
|
||||
{/if}
|
||||
</div>
|
|
@ -1,7 +1,7 @@
|
|||
<form action="{path('/settings/proxy')}" method="POST">
|
||||
{foreach $proxy_elements as $proxy_element}
|
||||
<div class="field">
|
||||
<label class="label">{$proxy_element}</label>
|
||||
<label class="label">{$proxy_element|firstUpper}</label>
|
||||
<div class="control">
|
||||
<input name="{$proxy_element}" class="input" value="{isset($_COOKIE[$proxy_element]) ? $_COOKIE[$proxy_element] : ''}" required />
|
||||
</div>
|
||||
|
|
12
composer.lock
generated
12
composer.lock
generated
|
@ -306,16 +306,16 @@
|
|||
},
|
||||
{
|
||||
"name": "pablouser1/tikscraper",
|
||||
"version": "v1.2.4",
|
||||
"version": "v1.2.5.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pablouser1/TikScraperPHP.git",
|
||||
"reference": "577e1c1d7945c87e2bad2000fec1f9a7c0b9cf68"
|
||||
"reference": "77b336877d942633dfbfe78d8e67875d0c9089f0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/577e1c1d7945c87e2bad2000fec1f9a7c0b9cf68",
|
||||
"reference": "577e1c1d7945c87e2bad2000fec1f9a7c0b9cf68",
|
||||
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/77b336877d942633dfbfe78d8e67875d0c9089f0",
|
||||
"reference": "77b336877d942633dfbfe78d8e67875d0c9089f0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -339,9 +339,9 @@
|
|||
"description": "Get data from TikTok API",
|
||||
"support": {
|
||||
"issues": "https://github.com/pablouser1/TikScraperPHP/issues",
|
||||
"source": "https://github.com/pablouser1/TikScraperPHP/tree/v1.2.4"
|
||||
"source": "https://github.com/pablouser1/TikScraperPHP/tree/v1.2.5.1"
|
||||
},
|
||||
"time": "2022-02-16T11:53:00+00:00"
|
||||
"time": "2022-02-20T15:16:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
{layout '../layouts/hero.latte'}
|
||||
|
||||
{block content}
|
||||
{do $item = $feed->items[0]}
|
||||
<div class="columns is-centered is-vcentered">
|
||||
<div class="column">
|
||||
<video controls poster="{path('/stream?url=' . urlencode($feed->items[0]->video->originCover))}">
|
||||
<source src="{path('/stream?url=' . urlencode($feed->items[0]->video->playAddr))}" type="video/mp4" />
|
||||
<video controls poster="{path('/stream?url=' . urlencode($item->video->originCover))}">
|
||||
<source src="{path('/stream?url=' . urlencode($item->video->playAddr))}" type="video/mp4" />
|
||||
</video>
|
||||
</div>
|
||||
<div class="column has-text-centered">
|
||||
<div class="box">
|
||||
<p class="title">Video by <a href="{path('/@'.$feed->info->detail->uniqueId)}">{$feed->info->detail->uniqueId}</a></p>
|
||||
<p class="subtitle">{$feed->items[0]->desc}</p>
|
||||
<p class="subtitle">{$item->desc}</p>
|
||||
<p>Played {number($feed->info->stats->playCount)} times</p>
|
||||
<p>Shared {number($feed->info->stats->shareCount)} times / {number($feed->info->stats->commentCount)} comments</p>
|
||||
<hr />
|
||||
<a href="{path('/stream?url=' . urlencode($feed->items[0]->video->playAddr) . '&download=1')}" class="button is-info">Download video</a>
|
||||
<p>{$feed->items[0]->music->title}</p>
|
||||
<audio src="{path('/stream?url=' . urlencode($feed->items[0]->music->playUrl))}" controls preload="none"></audio>
|
||||
<div class="buttons is-centered">
|
||||
<a href="{path('/stream?url=' . urlencode($item->video->playAddr) . '&download=1&id=' . $item->id . '&user=' . $item->author->uniqueId) . '&watermark='}" class="button is-info">Download watermark</a>
|
||||
<a href="{path('/stream?download=1&id=' . $item->id . '&user=' . $feed->info->detail->uniqueId)}" class="button is-info">Download no watermark</a>
|
||||
</div>
|
||||
<p>{$item->music->title}</p>
|
||||
<audio src="{path('/stream?url=' . urlencode($item->music->playUrl))}" controls preload="none"></audio>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue