Force legacy mode, instance level and user level
This commit is contained in:
parent
db3799c344
commit
73dd93420f
|
@ -4,6 +4,7 @@
|
|||
# API CONFIG
|
||||
# USE_TEST_ENDPOINTS=1 # Discomment for usage of testing TikTok endpoints, may help sometimes
|
||||
# SIGNER_URL="https://example.com" # External signing service
|
||||
# FORCE_LEGACY=1 # Force legacy mode for wrapper
|
||||
|
||||
# Proxy Config, will be used to make TikTok requests, useful if having VERIFY_CODE issues
|
||||
# PROXY_HOST=HOSTNAME
|
||||
|
|
|
@ -20,4 +20,10 @@ class SettingsController {
|
|||
$url = Misc::url('/settings');
|
||||
header("Location: {$url}");
|
||||
}
|
||||
|
||||
static public function api() {
|
||||
$_POST['legacy'] ?? Cookies::set('api-legacy', '1');
|
||||
$url = Misc::url('/settings');
|
||||
header("Location: {$url}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,9 @@ class Misc {
|
|||
|
||||
/**
|
||||
* Setup of TikTok Api wrapper
|
||||
* @return \TikScraper\Api|\TikScraper\Legacy
|
||||
*/
|
||||
static public function api(): \TikScraper\Api {
|
||||
static public function api() {
|
||||
$options = [
|
||||
'remote_signer' => self::env('SIGNER_URL', 'http://localhost:8080/signature'),
|
||||
'use_test_endpoints' => self::env('USE_TEST_ENDPOINTS', false),
|
||||
|
@ -75,8 +76,12 @@ class Misc {
|
|||
break;
|
||||
}
|
||||
}
|
||||
$api = new \TikScraper\Api($options, $cacheEngine);
|
||||
return $api;
|
||||
|
||||
// Legacy mode
|
||||
$legacy = self::env('FORCE_LEGACY', false); // Instance level
|
||||
$_COOKIE['enable_legacy'] ?? $legacy = true; // User level
|
||||
|
||||
return $legacy === false ? new \TikScraper\Api($options, $cacheEngine) : new \TikScraper\Legacy($options, $cacheEngine);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
12
components/settings/api.latte
Normal file
12
components/settings/api.latte
Normal file
|
@ -0,0 +1,12 @@
|
|||
<form action="{path('/settings/api')}" method="POST">
|
||||
<div class="field">
|
||||
<label class="checkbox">
|
||||
<input name="api-legacy" type="checkbox" checked="{isset($_COOKIE['api-legacy']) ? 'true' : 'false'}">Enable legacy mode
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<button class="button is-success" type="submit">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "pablouser1/proxitok",
|
||||
"description": "An alternative frontend for TikTok",
|
||||
"version": "1.5.0",
|
||||
"version": "2.0.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"type": "project",
|
||||
"homepage": "https://github.com/pablouser1/ProxiTok",
|
||||
|
|
14
composer.lock
generated
14
composer.lock
generated
|
@ -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": "f5e451a254a58bf7d512421237641801",
|
||||
"content-hash": "f4a37c76a2ece697a18abfae8dcb6e9f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bramus/router",
|
||||
|
@ -306,16 +306,16 @@
|
|||
},
|
||||
{
|
||||
"name": "pablouser1/tikscraper",
|
||||
"version": "v1.2.6",
|
||||
"version": "v1.2.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pablouser1/TikScraperPHP.git",
|
||||
"reference": "1bd1d62a62d8dcca433df904162649fd04905114"
|
||||
"reference": "13f1f2d220cb2a6d833cd8249ddd1eeea269c149"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/1bd1d62a62d8dcca433df904162649fd04905114",
|
||||
"reference": "1bd1d62a62d8dcca433df904162649fd04905114",
|
||||
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/13f1f2d220cb2a6d833cd8249ddd1eeea269c149",
|
||||
"reference": "13f1f2d220cb2a6d833cd8249ddd1eeea269c149",
|
||||
"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.6"
|
||||
"source": "https://github.com/pablouser1/TikScraperPHP/tree/v1.2.7.1"
|
||||
},
|
||||
"time": "2022-03-11T17:16:37+00:00"
|
||||
"time": "2022-03-11T19:24:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
require __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
// LOAD DOTENV
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
|
||||
$dotenv->safeLoad();
|
||||
|
||||
// ROUTER
|
||||
|
|
|
@ -41,6 +41,7 @@ $router->get('/music/([^/]+)', 'MusicController@get');
|
|||
$router->mount('/settings', function () use ($router) {
|
||||
$router->get('/', 'SettingsController@index');
|
||||
$router->post('/proxy', 'SettingsController@proxy');
|
||||
$router->post('/api', 'SettingsController@api');
|
||||
});
|
||||
|
||||
$router->get('/discover', 'DiscoverController@get');
|
||||
|
|
|
@ -8,4 +8,7 @@
|
|||
<!-- Proxy settings -->
|
||||
<p class="title">Proxy</p>
|
||||
{include '../components/settings/proxy.latte'}
|
||||
<hr />
|
||||
<p class="title">Api</p>
|
||||
{include '../components/settings/api.latte'}
|
||||
{/block}
|
||||
|
|
Loading…
Reference in a new issue