proxitok/routes.php

94 lines
2.8 KiB
PHP
Raw Normal View History

2022-01-30 18:02:52 -05:00
<?php
2022-03-11 12:56:19 -05:00
/** @var \Bramus\Router\Router $router */
2022-09-03 08:01:03 -04:00
use App\Helpers\ErrorHandler;
2022-11-27 08:26:35 -05:00
use App\Helpers\Misc;
use App\Helpers\Wrappers;
2022-01-30 18:02:52 -05:00
use App\Models\BaseTemplate;
2022-09-03 08:01:03 -04:00
$router->set404(function () {
ErrorHandler::showText(404, "That endpoint doesn't exist");
});
2022-01-30 18:02:52 -05:00
$router->get('/', function () {
2022-11-04 15:08:19 -04:00
Wrappers::latte('home', new BaseTemplate('Home'));
2022-01-30 18:02:52 -05:00
});
$router->get('/about', function () {
2022-11-04 15:08:19 -04:00
Wrappers::latte('about', new BaseTemplate('About'));
2022-01-30 18:02:52 -05:00
});
$router->get('/verify', function () {
2022-11-04 15:08:19 -04:00
Wrappers::latte('verify', new BaseTemplate('verify'));
});
2022-11-27 08:26:35 -05:00
$router->get('/manifest', function () {
header('Content-Type: application/json');
$data = [
"name" => "ProxiTok",
"short_name" => "ProxiTok",
"description" => "Use TikTok with a privacy-friendly alternative frontend",
"lang" => "en-US",
"theme_color" => "#4040ff",
"background_color" => "#ffffff",
"display" => "standalone",
"orientation" => "portrait-primary",
"icons" => [
[
"src" => Misc::url('/android-chrome-192x192.png'),
"sizes" => "192x192",
"type" => "image/png"
],
[
"src" => Misc::url('/android-chrome-512x512.png'),
"sizes" => "512x512",
"type" => "image/png"
]
],
"start_url" => Misc::url('/'),
"scope" => Misc::url('/')
];
echo json_encode($data, JSON_PRETTY_PRINT);
});
2022-01-30 18:02:52 -05:00
$router->get('/stream', 'ProxyController@stream');
2022-03-11 12:56:19 -05:00
$router->get('/download', 'ProxyController@download');
2023-01-25 09:00:52 -05:00
$router->get('/redirect/search', 'RedirectController@search');
$router->get('/redirect/download', 'RedirectController@download');
2022-01-30 18:02:52 -05:00
$router->mount('/trending', function () use ($router) {
$router->get('/', 'TrendingController@get');
$router->get('/rss', 'TrendingController@rss');
});
$router->mount('/@([^/]+)', function () use ($router) {
$router->get('/', 'UserController@get');
2022-03-14 06:50:47 -04:00
$router->get('/video/(\w+)', 'UserController@video');
2022-01-30 18:02:52 -05:00
$router->get('/rss', 'UserController@rss');
});
2022-06-12 06:50:16 -04:00
// Deprecated, please use /@USERNAME/video/VIDEO_ID instead
2022-01-30 18:02:52 -05:00
$router->get('/video/(\w+)', 'VideoController@get');
2022-06-12 06:50:16 -04:00
// Workaround that allows /t endpoints
$router->get('/t/([^/]+)', 'VideoController@get');
2022-01-30 18:02:52 -05:00
$router->mount('/tag/([^/]+)', function () use ($router) {
$router->get('/', 'TagController@get');
2022-01-30 18:02:52 -05:00
$router->get('/rss', 'TagController@rss');
});
$router->get('/music/([^/]+)', 'MusicController@get');
// -- Settings -- //
$router->mount('/settings', function () use ($router) {
$router->get('/', 'SettingsController@index');
$router->post('/general', 'SettingsController@general');
$router->post('/api', 'SettingsController@api');
2022-11-04 12:10:51 -04:00
$router->post('/misc', 'SettingsController@misc');
2022-01-30 18:02:52 -05:00
});
2022-02-05 18:58:30 -05:00
$router->get('/discover', 'DiscoverController@get');
2022-04-10 06:10:48 -04:00
// -- EMBED -- //
$router->get('/embed/v2/(\d+)', 'EmbedController@v2');