mirror of
https://github.com/pablouser1/ProxiTok.git
synced 2024-12-06 19:27:30 +01:00
docker
This commit is contained in:
+4
-4
@@ -1,18 +1,18 @@
|
||||
FROM trafex/php-nginx:3.4.0
|
||||
FROM trafex/php-nginx:3.6.0
|
||||
|
||||
# Add composer
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Copy config
|
||||
COPY ./misc/setup/docker/php.ini /etc/php82/conf.d/settings.ini
|
||||
COPY ./misc/setup/docker/php.ini /etc/php83/conf.d/settings.ini
|
||||
|
||||
USER root
|
||||
# Create cache folder
|
||||
RUN mkdir /cache && chown -R nobody:nogroup /cache
|
||||
# Install deps
|
||||
RUN apk add --no-cache php82-redis php82-zip php82-tokenizer
|
||||
USER nobody
|
||||
RUN apk add --no-cache php83-redis php83-zip php83-tokenizer
|
||||
|
||||
USER nobody
|
||||
# Copy source
|
||||
COPY --chown=nobody . /var/www/html
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ Apply to: Main window (address bar)
|
||||
```
|
||||
|
||||
## TODO / Known issues
|
||||
* Fix Heroku, still using old signer method
|
||||
* Replace placeholder favicon
|
||||
* Make video on /video fit screen and don't overflow
|
||||
* Fix embed styling
|
||||
|
||||
@@ -19,7 +19,7 @@ class ApcuCache implements ICache {
|
||||
return apcu_exists($cache_key);
|
||||
}
|
||||
|
||||
public function set(string $cache_key, string $data, $timeout = 3600): void {
|
||||
public function set(string $cache_key, string $data, int $timeout = 3600): void {
|
||||
apcu_store($cache_key, $data, $timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class JSONCache implements ICache {
|
||||
return is_file($filename);
|
||||
}
|
||||
|
||||
public function set(string $cache_key, string $data, $timeout = 3600) {
|
||||
public function set(string $cache_key, string $data, int $timeout = 3600) {
|
||||
file_put_contents($this->cache_path . '/' . $cache_key . '.json', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class RedisCache implements ICache {
|
||||
return $this->client->exists($cache_key);
|
||||
}
|
||||
|
||||
public function set(string $cache_key, string $data, $timeout = 3600) {
|
||||
public function set(string $cache_key, string $data, int $timeout = 3600) {
|
||||
$this->client->set($cache_key, $data, $timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Helpers\ErrorHandler;
|
||||
use App\Helpers\Wrappers;
|
||||
use App\Models\DiscoverTemplate;
|
||||
|
||||
class DiscoverController {
|
||||
public static function get() {
|
||||
$api = Wrappers::api();
|
||||
$data = $api->discover();
|
||||
if ($data->meta->success) {
|
||||
Wrappers::latte('discover', new DiscoverTemplate($data));
|
||||
} else {
|
||||
ErrorHandler::showMeta($data->meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,6 @@ class SettingsController {
|
||||
|
||||
public static function api() {
|
||||
// TODO, ADD COUNT
|
||||
if (isset($_POST['api-test_endpoints'])) {
|
||||
$test_endpoints = $_POST['api-test_endpoints'];
|
||||
Cookies::set('api-test_endpoints', $test_endpoints);
|
||||
}
|
||||
|
||||
if (isset($_POST['api-downloader'])) {
|
||||
$downloader = $_POST['api-downloader'];
|
||||
Cookies::set("api-downloader", $downloader);
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Helpers\Misc;
|
||||
use App\Models\FeedTemplate;
|
||||
use App\Helpers\ErrorHandler;
|
||||
use App\Helpers\Wrappers;
|
||||
use App\Models\RSSTemplate;
|
||||
|
||||
class TrendingController {
|
||||
public static function get() {
|
||||
$api = Wrappers::api();
|
||||
$cursor = Misc::getTtwid();
|
||||
|
||||
$trending = $api->trending();
|
||||
$trending->feed($cursor);
|
||||
|
||||
$feed = $trending->getFeed();
|
||||
if ($feed && $feed->meta->success) {
|
||||
Wrappers::latte('trending', new FeedTemplate('Trending', $feed));
|
||||
} else {
|
||||
ErrorHandler::showMeta($trending->error());
|
||||
}
|
||||
}
|
||||
|
||||
public static function rss() {
|
||||
$api = Wrappers::api();
|
||||
$trending = $api->trending();
|
||||
$trending->feed();
|
||||
|
||||
$feed = $trending->getFeed();
|
||||
if ($feed && $feed->meta->success) {
|
||||
Misc::rss('Trending');
|
||||
Wrappers::latte('rss', new RSSTemplate('Trending', 'Trending on TikTok', '', Misc::url('/trending'), $feed->items));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ use TikScraper\Constants\DownloadMethods;
|
||||
class SettingsTemplate extends BaseTemplate {
|
||||
public array $downloaders = [];
|
||||
public array $themes = [];
|
||||
public bool $isTestEndpoints = false;
|
||||
public string $currentDownloader;
|
||||
public string $currentTheme;
|
||||
public bool $isServiceWorker = false;
|
||||
@@ -25,7 +24,6 @@ class SettingsTemplate extends BaseTemplate {
|
||||
$ref = new \ReflectionClass(Themes::class);
|
||||
$this->themes = $ref->getConstants();
|
||||
// Cookies data
|
||||
$this->isTestEndpoints = Cookies::check('api-test_endpoints', 'yes');
|
||||
$this->currentDownloader = Cookies::downloader();
|
||||
$this->currentTheme = Cookies::theme();
|
||||
$this->isServiceWorker = Cookies::check('misc-sw', 'yes');
|
||||
|
||||
+3
-1
@@ -19,13 +19,15 @@
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"ext-redis": "^5.3.2|^6.0.0",
|
||||
"ext-mbstring": "*",
|
||||
"latte/latte": "^2.11",
|
||||
"bramus/router": "^1.6",
|
||||
"pablouser1/tikscraper": "^2.5",
|
||||
"josegonzalez/dotenv": "^4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-redis": "For using redis as a caching engine"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
|
||||
Generated
+1
-2
@@ -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": "3d653024838c167911e5ac51d28fac53",
|
||||
"content-hash": "98ad54f403100fdc789680d1e3704ef2",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bramus/router",
|
||||
@@ -1151,7 +1151,6 @@
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": "^8.1",
|
||||
"ext-redis": "^5.3.2|^6.0.0",
|
||||
"ext-mbstring": "*"
|
||||
},
|
||||
"platform-dev": [],
|
||||
|
||||
+12
-19
@@ -1,5 +1,3 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
web:
|
||||
container_name: proxitok-web
|
||||
@@ -11,13 +9,12 @@ services:
|
||||
- API_CACHE=redis
|
||||
- REDIS_HOST=proxitok-redis
|
||||
- REDIS_PORT=6379
|
||||
- API_SIGNER=remote
|
||||
- API_SIGNER_URL=http://proxitok-signer:8080/signature
|
||||
- API_CHROMEDRIVER=http://proxitok-chromedriver:9515
|
||||
volumes:
|
||||
- proxitok-cache:/cache
|
||||
depends_on:
|
||||
- redis
|
||||
- signer
|
||||
- chromedriver
|
||||
networks:
|
||||
- proxitok
|
||||
security_opt:
|
||||
@@ -28,10 +25,10 @@ services:
|
||||
- CHOWN
|
||||
- SETGID
|
||||
- SETUID
|
||||
|
||||
# Redis, used for caching
|
||||
redis:
|
||||
container_name: proxitok-redis
|
||||
image: redis:7-alpine
|
||||
image: redis:7.4-alpine
|
||||
command: redis-server --save 60 1 --loglevel warning
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
@@ -44,20 +41,16 @@ services:
|
||||
- /data:size=10M,mode=0770,uid=65534,gid=65534,noexec,nosuid,nodev
|
||||
cap_drop:
|
||||
- ALL
|
||||
|
||||
signer:
|
||||
container_name: proxitok-signer
|
||||
image: ghcr.io/pablouser1/signtok:master
|
||||
# Chromedriver instance, used for sending requests to TikTok
|
||||
chromedriver:
|
||||
container_name: proxitok-chromedriver
|
||||
image: zenika/alpine-chrome:with-chromedriver
|
||||
init: true
|
||||
networks:
|
||||
- proxitok
|
||||
user: nobody
|
||||
read_only: true
|
||||
shm_size: 1g
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
cap_drop:
|
||||
- ALL
|
||||
|
||||
- seccomp:./misc/setup/docker/chrome.json
|
||||
ports:
|
||||
- 9515:9515
|
||||
volumes:
|
||||
proxitok-cache:
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -56,19 +56,12 @@ $router->get('/download', 'ProxyController@download');
|
||||
$router->get('/redirect/search', 'RedirectController@search');
|
||||
$router->get('/redirect/download', 'RedirectController@download');
|
||||
|
||||
$router->mount('/trending', function () use ($router) {
|
||||
$router->get('/', 'TrendingController@get');
|
||||
$router->get('/rss', 'TrendingController@rss');
|
||||
});
|
||||
|
||||
$router->mount('/@([^/]+)', function () use ($router) {
|
||||
$router->get('/', 'UserController@get');
|
||||
$router->get('/video/(\w+)', 'UserController@video');
|
||||
$router->get('/rss', 'UserController@rss');
|
||||
});
|
||||
|
||||
// Deprecated, please use /@USERNAME/video/VIDEO_ID instead
|
||||
$router->get('/video/(\w+)', 'VideoController@get');
|
||||
// Workaround that allows /t endpoints
|
||||
$router->get('/t/([^/]+)', 'VideoController@get');
|
||||
|
||||
@@ -87,7 +80,5 @@ $router->mount('/settings', function () use ($router) {
|
||||
$router->post('/misc', 'SettingsController@misc');
|
||||
});
|
||||
|
||||
$router->get('/discover', 'DiscoverController@get');
|
||||
|
||||
// -- EMBED -- //
|
||||
$router->get('/embed/v2/(\d+)', 'EmbedController@v2');
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
{embed '../form.latte', path: '/settings/api', method: 'POST', submit: true}
|
||||
{block fields}
|
||||
<div class="field">
|
||||
<label class="label">Use test endpoints</label>
|
||||
<div class="control">
|
||||
<label class="radio">
|
||||
<input type="radio" name="api-test_endpoints" value="yes" n:attr="checked => $isTestEndpoints" />
|
||||
<span>Yes</span>
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="api-test_endpoints" value="no" n:attr="checked => !$isTestEndpoints" />
|
||||
<span>No</span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="help">This <i>may</i> help bypass rate limits</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Downloader</label>
|
||||
<div class="control">
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
{layout '../layouts/default.latte'}
|
||||
|
||||
{block header}
|
||||
<p class="title">Discover</p>
|
||||
{/block}
|
||||
|
||||
{block content}
|
||||
{foreach $data->items as $type => $items}
|
||||
<p class="title">{$type|firstUpper}</p>
|
||||
<div class="columns is-multiline is-vcentered">
|
||||
{foreach $items as $item}
|
||||
<div class="column is-one-quarter">
|
||||
{embed '../components/card.latte'}
|
||||
{block content}
|
||||
<div class="media">
|
||||
<!-- Show image if exists -->
|
||||
{if !empty($item->cardItem->cover)}
|
||||
<div class="media-left">
|
||||
<figure class="image is-96x96">
|
||||
<img loading="lazy" width="96" height="96" src="{path('/stream?url=' . urlencode($item->cardItem->cover))}" />
|
||||
</figure>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="media-content">
|
||||
<p class="title">{$item->cardItem->title}</p>
|
||||
<p class="subtitle">{$item->cardItem->subTitle}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>{$item->cardItem->description}</p>
|
||||
</div>
|
||||
{/block}
|
||||
{block footer}
|
||||
<a href="{path($item->cardItem->link)}" class="card-footer-item">Go</a>
|
||||
{/block}
|
||||
{/embed}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
{if !$iterator->last}
|
||||
<hr />
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/block}
|
||||
@@ -1,12 +0,0 @@
|
||||
{layout '../layouts/default.latte'}
|
||||
|
||||
{var $has_rss = true}
|
||||
|
||||
{block header}
|
||||
<p class="title">Trending</p>
|
||||
<p class="subtitle">{include '../components/rss.latte'}</p>
|
||||
{/block}
|
||||
|
||||
{block content}
|
||||
{include '../components/feed.latte'}
|
||||
{/block}
|
||||
Reference in New Issue
Block a user