changed keyword order
This commit is contained in:
parent
e43580f3f9
commit
19a2066fc2
|
@ -6,7 +6,7 @@ use App\Helpers\Wrappers;
|
||||||
use App\Models\DiscoverTemplate;
|
use App\Models\DiscoverTemplate;
|
||||||
|
|
||||||
class DiscoverController {
|
class DiscoverController {
|
||||||
static public function get() {
|
public static function get() {
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$data = $api->discover();
|
$data = $api->discover();
|
||||||
if ($data->meta->success) {
|
if ($data->meta->success) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use App\Helpers\Wrappers;
|
||||||
use App\Models\VideoTemplate;
|
use App\Models\VideoTemplate;
|
||||||
|
|
||||||
class EmbedController {
|
class EmbedController {
|
||||||
static public function v2(int $id) {
|
public static function v2(int $id) {
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$video = $api->video($id);
|
$video = $api->video($id);
|
||||||
$video->feed();
|
$video->feed();
|
||||||
|
|
|
@ -7,7 +7,7 @@ use App\Helpers\Wrappers;
|
||||||
use App\Models\FullTemplate;
|
use App\Models\FullTemplate;
|
||||||
|
|
||||||
class MusicController {
|
class MusicController {
|
||||||
static public function get(string $music_id) {
|
public static function get(string $music_id) {
|
||||||
$cursor = Misc::getCursor();
|
$cursor = Misc::getCursor();
|
||||||
|
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ProxyController {
|
||||||
"tiktokcdn.com", "tiktokcdn-us.com", "tiktok.com"
|
"tiktokcdn.com", "tiktokcdn-us.com", "tiktok.com"
|
||||||
];
|
];
|
||||||
|
|
||||||
static public function stream() {
|
public static function stream() {
|
||||||
self::checkUrl();
|
self::checkUrl();
|
||||||
$url = $_GET['url'];
|
$url = $_GET['url'];
|
||||||
$config['user_agent'] = Misc::env("USER_AGENT", TikScraperUserAgents::DEFAULT);
|
$config['user_agent'] = Misc::env("USER_AGENT", TikScraperUserAgents::DEFAULT);
|
||||||
|
@ -18,7 +18,7 @@ class ProxyController {
|
||||||
$streamer->url($url);
|
$streamer->url($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function download() {
|
public static function download() {
|
||||||
self::checkUrl();
|
self::checkUrl();
|
||||||
$method = Cookies::downloader();
|
$method = Cookies::downloader();
|
||||||
$downloader = new \TikScraper\Download($method);
|
$downloader = new \TikScraper\Download($method);
|
||||||
|
|
|
@ -8,7 +8,7 @@ use App\Helpers\UrlBuilder;
|
||||||
* Used to be compatible with HTML forms
|
* Used to be compatible with HTML forms
|
||||||
*/
|
*/
|
||||||
class RedirectController {
|
class RedirectController {
|
||||||
static public function search() {
|
public static function search() {
|
||||||
$endpoint = '/';
|
$endpoint = '/';
|
||||||
if (isset($_GET['type'], $_GET['term'])) {
|
if (isset($_GET['type'], $_GET['term'])) {
|
||||||
$term = trim($_GET['term']);
|
$term = trim($_GET['term']);
|
||||||
|
@ -49,7 +49,7 @@ class RedirectController {
|
||||||
header("Location: {$url}");
|
header("Location: {$url}");
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function download() {
|
public static function download() {
|
||||||
if (!(isset($_GET['videoId'], $_GET['authorUsername'], $_GET['playAddr']))) {
|
if (!(isset($_GET['videoId'], $_GET['authorUsername'], $_GET['playAddr']))) {
|
||||||
ErrorHandler::showText(400, 'Request incomplete');
|
ErrorHandler::showText(400, 'Request incomplete');
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -7,11 +7,11 @@ use App\Helpers\Wrappers;
|
||||||
use App\Models\SettingsTemplate;
|
use App\Models\SettingsTemplate;
|
||||||
|
|
||||||
class SettingsController {
|
class SettingsController {
|
||||||
static public function index() {
|
public static function index() {
|
||||||
Wrappers::latte('settings', new SettingsTemplate());
|
Wrappers::latte('settings', new SettingsTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function general() {
|
public static function general() {
|
||||||
if (isset($_POST['theme'])) {
|
if (isset($_POST['theme'])) {
|
||||||
$theme = $_POST['theme'];
|
$theme = $_POST['theme'];
|
||||||
Cookies::set('theme', $theme);
|
Cookies::set('theme', $theme);
|
||||||
|
@ -19,7 +19,7 @@ class SettingsController {
|
||||||
self::redirect();
|
self::redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function api() {
|
public static function api() {
|
||||||
// TODO, ADD COUNT
|
// TODO, ADD COUNT
|
||||||
if (isset($_POST['api-test_endpoints'])) {
|
if (isset($_POST['api-test_endpoints'])) {
|
||||||
$test_endpoints = $_POST['api-test_endpoints'];
|
$test_endpoints = $_POST['api-test_endpoints'];
|
||||||
|
|
|
@ -9,7 +9,7 @@ use App\Models\FullTemplate;
|
||||||
use App\Models\RSSTemplate;
|
use App\Models\RSSTemplate;
|
||||||
|
|
||||||
class TagController {
|
class TagController {
|
||||||
static public function get(string $name) {
|
public static function get(string $name) {
|
||||||
$cursor = Misc::getCursor();
|
$cursor = Misc::getCursor();
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$hashtag = $api->hashtag($name);
|
$hashtag = $api->hashtag($name);
|
||||||
|
@ -23,7 +23,7 @@ class TagController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function rss(string $name) {
|
public static function rss(string $name) {
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$hashtag = $api->hashtag($name);
|
$hashtag = $api->hashtag($name);
|
||||||
$hashtag->feed();
|
$hashtag->feed();
|
||||||
|
|
|
@ -8,7 +8,7 @@ use App\Helpers\Wrappers;
|
||||||
use App\Models\RSSTemplate;
|
use App\Models\RSSTemplate;
|
||||||
|
|
||||||
class TrendingController {
|
class TrendingController {
|
||||||
static public function get() {
|
public static function get() {
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$cursor = Misc::getTtwid();
|
$cursor = Misc::getTtwid();
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class TrendingController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function rss() {
|
public static function rss() {
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$trending = $api->trending();
|
$trending = $api->trending();
|
||||||
$trending->feed();
|
$trending->feed();
|
||||||
|
|
|
@ -10,7 +10,7 @@ use App\Models\RSSTemplate;
|
||||||
use App\Models\VideoTemplate;
|
use App\Models\VideoTemplate;
|
||||||
|
|
||||||
class UserController {
|
class UserController {
|
||||||
static public function get(string $username) {
|
public static function get(string $username) {
|
||||||
$cursor = Misc::getCursor();
|
$cursor = Misc::getCursor();
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$user = $api->user($username);
|
$user = $api->user($username);
|
||||||
|
@ -24,7 +24,7 @@ class UserController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function video(string $username, string $video_id) {
|
public static function video(string $username, string $video_id) {
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$video = $api->video($video_id);
|
$video = $api->video($video_id);
|
||||||
$video->feed();
|
$video->feed();
|
||||||
|
@ -37,7 +37,7 @@ class UserController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function rss(string $username) {
|
public static function rss(string $username) {
|
||||||
$api = Wrappers::api();
|
$api = Wrappers::api();
|
||||||
$user = $api->user($username);
|
$user = $api->user($username);
|
||||||
$user->feed();
|
$user->feed();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
class VideoController {
|
class VideoController {
|
||||||
static public function get(string $video_id) {
|
public static function get(string $video_id) {
|
||||||
UserController::video('placeholder', $video_id);
|
UserController::video('placeholder', $video_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,14 @@ namespace App\Helpers;
|
||||||
use App\Constants\Themes;
|
use App\Constants\Themes;
|
||||||
|
|
||||||
class Cookies {
|
class Cookies {
|
||||||
static public function get(string $name, string $default_value = ''): string {
|
public static function get(string $name, string $default_value = ''): string {
|
||||||
if (isset($_COOKIE[$name]) && !empty($_COOKIE[$name])) {
|
if (isset($_COOKIE[$name]) && !empty($_COOKIE[$name])) {
|
||||||
return $_COOKIE[$name];
|
return $_COOKIE[$name];
|
||||||
}
|
}
|
||||||
return $default_value;
|
return $default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function theme(): string {
|
public static function theme(): string {
|
||||||
$theme = self::get('theme');
|
$theme = self::get('theme');
|
||||||
$ref = new \ReflectionClass(Themes::class);
|
$ref = new \ReflectionClass(Themes::class);
|
||||||
$themes = $ref->getConstants();
|
$themes = $ref->getConstants();
|
||||||
|
@ -21,20 +21,20 @@ class Cookies {
|
||||||
return 'default';
|
return 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function downloader(): string {
|
public static function downloader(): string {
|
||||||
$downloader = self::get('api-downloader', 'default');
|
$downloader = self::get('api-downloader', 'default');
|
||||||
return $downloader;
|
return $downloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function exists(string $name): bool {
|
public static function exists(string $name): bool {
|
||||||
return isset($_COOKIE[$name]);
|
return isset($_COOKIE[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function check(string $name, string $value): bool {
|
public static function check(string $name, string $value): bool {
|
||||||
return self::exists($name) && $_COOKIE[$name] === $value;
|
return self::exists($name) && $_COOKIE[$name] === $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function set(string $name, string $value) {
|
public static function set(string $name, string $value) {
|
||||||
setcookie($name, $value, time()+60*60*24*30, '/', '', isset($_SERVER['HTTPS']), true);
|
setcookie($name, $value, time()+60*60*24*30, '/', '', isset($_SERVER['HTTPS']), true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,12 +5,12 @@ use App\Models\ErrorTemplate;
|
||||||
use TikScraper\Models\Meta;
|
use TikScraper\Models\Meta;
|
||||||
|
|
||||||
class ErrorHandler {
|
class ErrorHandler {
|
||||||
static public function showMeta(Meta $meta) {
|
public static function showMeta(Meta $meta) {
|
||||||
http_response_code($meta->http_code);
|
http_response_code($meta->http_code);
|
||||||
Wrappers::latte('error', new ErrorTemplate($meta->http_code, $meta->tiktok_msg, $meta->tiktok_code));
|
Wrappers::latte('error', new ErrorTemplate($meta->http_code, $meta->tiktok_msg, $meta->tiktok_code));
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function showText(int $code, string $msg) {
|
public static function showText(int $code, string $msg) {
|
||||||
http_response_code($code);
|
http_response_code($code);
|
||||||
Wrappers::latte('error', new ErrorTemplate($code, $msg));
|
Wrappers::latte('error', new ErrorTemplate($code, $msg));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,33 +2,34 @@
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
class Misc {
|
class Misc {
|
||||||
static public function getCursor(): int {
|
public static function getCursor(): int {
|
||||||
return isset($_GET['cursor']) && is_numeric($_GET['cursor']) ? (int) $_GET['cursor'] : 0;
|
return isset($_GET['cursor']) && is_numeric($_GET['cursor']) ? (int) $_GET['cursor'] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getTtwid(): string {
|
public static function getTtwid(): string {
|
||||||
return isset($_GET['cursor']) ? $_GET['cursor'] : '';
|
return isset($_GET['cursor']) ? $_GET['cursor'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function url(string $endpoint = ''): string {
|
public static function url(string $endpoint = ''): string {
|
||||||
return self::env('APP_URL', '') . $endpoint;
|
return self::env('APP_URL', '') . $endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function env(string $key, $default_value) {
|
public static function env(string $key, $default_value) {
|
||||||
return $_ENV[$key] ?? $default_value;
|
return $_ENV[$key] ?? $default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns absolute path for view
|
* Returns absolute path for view
|
||||||
*/
|
*/
|
||||||
static public function getView(string $template): string {
|
public static function getView(string $template): string {
|
||||||
return __DIR__ . "/../../templates/views/{$template}.latte";
|
return __DIR__ . "/../../templates/views/{$template}.latte";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common method for rss feeds
|
* Common method for rss feeds
|
||||||
*/
|
*/
|
||||||
static public function rss(string $title) {
|
public static function rss(string $title) {
|
||||||
|
header('Content-Type: application/rss+xml');
|
||||||
header('Content-Disposition: attachment; filename="' . $title . '.rss' . '"');
|
header('Content-Disposition: attachment; filename="' . $title . '.rss' . '"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,29 +2,29 @@
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
class UrlBuilder {
|
class UrlBuilder {
|
||||||
static public function stream(string $url): string {
|
public static function stream(string $url): string {
|
||||||
return Misc::url('/stream?url=' . urlencode($url));
|
return Misc::url('/stream?url=' . urlencode($url));
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function download(string $url, string $username, string $id, bool $watermark): string {
|
public static function download(string $url, string $username, string $id, bool $watermark): string {
|
||||||
$down_url = Misc::url('/download?url=' . urlencode($url) . '&id=' . $id . '&user=' . $username);
|
$down_url = Misc::url('/download?url=' . urlencode($url) . '&id=' . $id . '&user=' . $username);
|
||||||
if ($watermark) $down_url .= '&watermark=1';
|
if ($watermark) $down_url .= '&watermark=1';
|
||||||
return $down_url;
|
return $down_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function user(string $username): string {
|
public static function user(string $username): string {
|
||||||
return Misc::url('/@' . $username);
|
return Misc::url('/@' . $username);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function tag(string $tag): string {
|
public static function tag(string $tag): string {
|
||||||
return Misc::url('/tag/' . $tag);
|
return Misc::url('/tag/' . $tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function video_internal(string $username, string $id): string {
|
public static function video_internal(string $username, string $id): string {
|
||||||
return Misc::url('/@' . $username . "/video/" . $id);
|
return Misc::url('/@' . $username . "/video/" . $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function video_external(string $username, string $id): string {
|
public static function video_external(string $username, string $id): string {
|
||||||
return "https://www.tiktok.com/@" . $username . "/video/" . $id;
|
return "https://www.tiktok.com/@" . $username . "/video/" . $id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Wrappers {
|
||||||
/**
|
/**
|
||||||
* Setup of Latte template engine
|
* Setup of Latte template engine
|
||||||
*/
|
*/
|
||||||
static public function latte(string $template, BaseTemplate $base) {
|
public static function latte(string $template, BaseTemplate $base) {
|
||||||
$latte = new \Latte\Engine;
|
$latte = new \Latte\Engine;
|
||||||
$cache_path = Misc::env('LATTE_CACHE', __DIR__ . '/../../cache/latte');
|
$cache_path = Misc::env('LATTE_CACHE', __DIR__ . '/../../cache/latte');
|
||||||
$latte->setTempDirectory($cache_path);
|
$latte->setTempDirectory($cache_path);
|
||||||
|
@ -131,7 +131,7 @@ class Wrappers {
|
||||||
/**
|
/**
|
||||||
* Setup of TikTok Api wrapper
|
* Setup of TikTok Api wrapper
|
||||||
*/
|
*/
|
||||||
static public function api(): \TikScraper\Api {
|
public static function api(): \TikScraper\Api {
|
||||||
$method = Misc::env('API_SIGNER', '');
|
$method = Misc::env('API_SIGNER', '');
|
||||||
$url = Misc::env('API_SIGNER_URL', '');
|
$url = Misc::env('API_SIGNER_URL', '');
|
||||||
if (!$method) {
|
if (!$method) {
|
||||||
|
|
Loading…
Reference in a new issue