From c68243292008f1e777a65e709b930f3091d5056f Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Sun, 13 Mar 2022 23:18:10 +0100 Subject: [PATCH] Accept chromedriver url for sign and .env cleanup --- .env.example | 11 +-- README.md | 16 +++- app/Helpers/Misc.php | 10 ++- composer.json | 10 +-- composer.lock | 174 +++++++++++++++++++++++++++++++++++++++++-- setup/nginx.conf | 8 -- views/about.latte | 2 +- 7 files changed, 195 insertions(+), 36 deletions(-) delete mode 100644 setup/nginx.conf diff --git a/.env.example b/.env.example index 29e3e5c..3dfeb4e 100644 --- a/.env.example +++ b/.env.example @@ -1,17 +1,18 @@ # APP_URL="http://localhost:8000" # Full url path, PLEASE REPLACE TO YOUR OWN ONE +# LATTE_CACHE=/tmp/proxitok_api # Path for Latte cache, leave commented for ./cache/latte # 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 +# API_FORCE_LEGACY=1 # Force legacy mode for wrapper +# API_SIGNER_URL="https://example.com" # External signing service +# API_BROWSER_URL="http://localhost:4444" # chromedriver url +# API_TEST_ENDPOINTS=1 # Discomment for usage of testing TikTok endpoints, may help sometimes +# API_CACHE=redis # 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 -# LATTE_CACHE=/tmp/proxitok_api # Path for Latte cache, leave commented for ./cache/latte -# API_CACHE=redis # Cache engine for TikTok Api, (more info on README) # Redis cache, used on Helpers\CacheEngines\RedisCache (CHOOSE ONE) # REDIS_HOST=localhost # Host or path to unix socket diff --git a/README.md b/README.md index cd3eed1..aee1aeb 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,21 @@ Available cache engines: You don't have to do anything more ### Nginx -You can get a config example on /setup/nginx.conf +``` +location / { + try_files $uri $uri/ /index.php?$query_string; +} -## TODO +location /.env { + deny all; + return 404; +} +``` + +## TODO / Known issues +* Docker +* Full installation instructions * Add a NoJS version / Make the whole program without required JS -* Better error handling * Make video on /video fit screen and don't overflow * i18n diff --git a/app/Helpers/Misc.php b/app/Helpers/Misc.php index d678ca8..50042f6 100644 --- a/app/Helpers/Misc.php +++ b/app/Helpers/Misc.php @@ -34,14 +34,18 @@ class Misc { */ static public function 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('API_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) + ], + 'signer' => [ + 'remote_url' => self::env('API_SIGNER_URL', ''), + 'browser_url' => self::env('API_BROWSER_URL', ''), + 'close_when_done' => false ] ]; // User level proxy config, will overwrite instance config @@ -78,7 +82,7 @@ class Misc { } // Legacy mode - $legacy = self::env('FORCE_LEGACY', false) || isset($_COOKIE['api-legacy']) && $_COOKIE['api-legacy'] === 'on'; + $legacy = self::env('API_FORCE_LEGACY', false) || isset($_COOKIE['api-legacy']) && $_COOKIE['api-legacy'] === 'on'; return $legacy === false ? new \TikScraper\Api($options, $cacheEngine) : new \TikScraper\Legacy($options, $cacheEngine); } diff --git a/composer.json b/composer.json index f3af9e9..ed4b0d9 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "pablouser1/proxitok", "description": "An alternative frontend for TikTok", - "version": "2.0.0.3", + "version": "2.1.0.0", "license": "AGPL-3.0-or-later", "type": "project", "homepage": "https://github.com/pablouser1/ProxiTok", @@ -11,12 +11,6 @@ "homepage": "https://github.com/pablouser1" } ], - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/pablouser1/TikTok-API-PHP" - } - ], "require": { "ext-redis": "^5.3.2", "ext-mbstring": "*", @@ -24,7 +18,7 @@ "vlucas/phpdotenv": "^5.4", "bramus/router": "^1.6", "mibe/feedwriter": "^1.1", - "pablouser1/tikscraper": "^1.2" + "pablouser1/tikscraper": "^1.3" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index cf7f18e..aea5f21 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "cadd5f76328389373f21a069e55f8aae", + "content-hash": "dcd701a81d130026c44b63870c9a9f73", "packages": [ { "name": "bramus/router", @@ -306,20 +306,22 @@ }, { "name": "pablouser1/tikscraper", - "version": "v1.2.7.6", + "version": "v1.3.0.3", "source": { "type": "git", "url": "https://github.com/pablouser1/TikScraperPHP.git", - "reference": "e7e682726e76541dc47d14dd259a29b3c0364790" + "reference": "793dde26e17362af304b9f50890c7fc178387629" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/e7e682726e76541dc47d14dd259a29b3c0364790", - "reference": "e7e682726e76541dc47d14dd259a29b3c0364790", + "url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/793dde26e17362af304b9f50890c7fc178387629", + "reference": "793dde26e17362af304b9f50890c7fc178387629", "shasum": "" }, "require": { - "php": ">=7.3|^8.0" + "php": ">=7.3|^8.0", + "php-webdriver/webdriver": "^1.12", + "sapistudio/seleniumstealth": "^1.0" }, "type": "library", "autoload": { @@ -339,9 +341,74 @@ "description": "Get data from TikTok API", "support": { "issues": "https://github.com/pablouser1/TikScraperPHP/issues", - "source": "https://github.com/pablouser1/TikScraperPHP/tree/v1.2.7.6" + "source": "https://github.com/pablouser1/TikScraperPHP/tree/v1.3.0.3" }, - "time": "2022-03-12T18:27:40+00:00" + "time": "2022-03-13T20:53:27+00:00" + }, + { + "name": "php-webdriver/webdriver", + "version": "1.12.0", + "source": { + "type": "git", + "url": "https://github.com/php-webdriver/php-webdriver.git", + "reference": "99d4856ed7dffcdf6a52eccd6551e83d8d557ceb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/99d4856ed7dffcdf6a52eccd6551e83d8d557ceb", + "reference": "99d4856ed7dffcdf6a52eccd6551e83d8d557ceb", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-zip": "*", + "php": "^5.6 || ~7.0 || ^8.0", + "symfony/polyfill-mbstring": "^1.12", + "symfony/process": "^2.8 || ^3.1 || ^4.0 || ^5.0 || ^6.0" + }, + "replace": { + "facebook/webdriver": "*" + }, + "require-dev": { + "ondram/ci-detector": "^2.1 || ^3.5 || ^4.0", + "php-coveralls/php-coveralls": "^2.4", + "php-mock/php-mock-phpunit": "^1.1 || ^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpunit/phpunit": "^5.7 || ^7 || ^8 || ^9", + "squizlabs/php_codesniffer": "^3.5", + "symfony/var-dumper": "^3.3 || ^4.0 || ^5.0 || ^6.0" + }, + "suggest": { + "ext-SimpleXML": "For Firefox profile creation" + }, + "type": "library", + "autoload": { + "files": [ + "lib/Exception/TimeoutException.php" + ], + "psr-4": { + "Facebook\\WebDriver\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.", + "homepage": "https://github.com/php-webdriver/php-webdriver", + "keywords": [ + "Chromedriver", + "geckodriver", + "php", + "selenium", + "webdriver" + ], + "support": { + "issues": "https://github.com/php-webdriver/php-webdriver/issues", + "source": "https://github.com/php-webdriver/php-webdriver/tree/1.12.0" + }, + "time": "2021-10-14T09:30:02+00:00" }, { "name": "phpoption/phpoption", @@ -414,6 +481,36 @@ ], "time": "2021-12-04T23:24:31+00:00" }, + { + "name": "sapistudio/seleniumstealth", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/Sapistudio/SeleniumStealth.git", + "reference": "4b392077e3d609fed564b78ae2e8becb98f01957" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Sapistudio/SeleniumStealth/zipball/4b392077e3d609fed564b78ae2e8becb98f01957", + "reference": "4b392077e3d609fed564b78ae2e8becb98f01957", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "SapiStudio\\SeleniumStealth\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "support": { + "issues": "https://github.com/Sapistudio/SeleniumStealth/issues", + "source": "https://github.com/Sapistudio/SeleniumStealth/tree/1.0.3" + }, + "time": "2022-01-10T20:04:41+00:00" + }, { "name": "symfony/polyfill-ctype", "version": "v1.25.0", @@ -662,6 +759,67 @@ ], "time": "2022-03-04T08:16:47+00:00" }, + { + "name": "symfony/process", + "version": "v6.0.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "1ccceccc6497e96f4f646218f04b97ae7d9fa7a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/1ccceccc6497e96f4f646218f04b97ae7d9fa7a1", + "reference": "1ccceccc6497e96f4f646218f04b97ae7d9fa7a1", + "shasum": "" + }, + "require": { + "php": ">=8.0.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v6.0.5" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-30T18:19:12+00:00" + }, { "name": "vlucas/phpdotenv", "version": "v5.4.1", diff --git a/setup/nginx.conf b/setup/nginx.conf deleted file mode 100644 index 8096791..0000000 --- a/setup/nginx.conf +++ /dev/null @@ -1,8 +0,0 @@ -location / { - try_files $uri $uri/ /index.php?$query_string; -} - -location /.env { - deny all; - return 404; -} diff --git a/views/about.latte b/views/about.latte index 6516ff0..85be629 100644 --- a/views/about.latte +++ b/views/about.latte @@ -7,7 +7,7 @@ {block content}

About this instance

-

Forcing Legacy mode: {isset($_ENV['FORCE_LEGACY']) ? 'yes' : 'no'}

+

Forcing Legacy mode: {isset($_ENV['API_FORCE_LEGACY']) ? 'yes' : 'no'}

Instance-level Proxy: {isset($_ENV['PROXY_HOST']) ? 'yes' : 'no'}


Why would I want to use ProxiTok?