diff --git a/app/Controllers/RedirectController.php b/app/Controllers/RedirectController.php index 41ce16f..7277ff0 100644 --- a/app/Controllers/RedirectController.php +++ b/app/Controllers/RedirectController.php @@ -15,7 +15,9 @@ class RedirectController { } else if (isset($_GET['music'])) { $endpoint = '/music/' . $_GET['music']; } else if (isset($_GET['video'])) { - $endpoint = '/video/' . $_GET['video']; + // The @username part is not used, but + // it is the schema that TikTok follows + $endpoint = '/@placeholder/video/' . $_GET['video']; } $url = Misc::url($endpoint); diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 3912f7d..6c27f39 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -24,6 +24,17 @@ class UserController { } } + static public function video(string $username, string $video_id) { + $api = Misc::api(); + $feed = $api->getVideoByID($video_id); + if ($feed->meta->success) { + $latte = Misc::latte(); + $latte->render(Misc::getView('video'), new FeedTemplate('Video', $feed)); + } else { + ErrorHandler::show($feed->meta); + } + } + static public function rss(string $username) { $api = Misc::api(); $feed = $api->getUserFeed($username); diff --git a/app/Controllers/VideoController.php b/app/Controllers/VideoController.php index 00ee453..2800d69 100644 --- a/app/Controllers/VideoController.php +++ b/app/Controllers/VideoController.php @@ -1,19 +1,11 @@ getVideoByID($video_id); - if ($feed->meta->success) { - $latte = Misc::latte(); - $latte->render(Misc::getView('video'), new FeedTemplate('Video', $feed)); - } else { - ErrorHandler::show($feed->meta); - } + UserController::video('placeholder', $video_id); } } diff --git a/composer.json b/composer.json index ed4b0d9..c3aa35a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "pablouser1/proxitok", "description": "An alternative frontend for TikTok", - "version": "2.1.0.0", + "version": "2.1.0.1", "license": "AGPL-3.0-or-later", "type": "project", "homepage": "https://github.com/pablouser1/ProxiTok", diff --git a/composer.lock b/composer.lock index aea5f21..062e8df 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": "dcd701a81d130026c44b63870c9a9f73", + "content-hash": "f6b066c447574f88ad9255a88892659e", "packages": [ { "name": "bramus/router", diff --git a/routes.php b/routes.php index 0ee6bd3..5052209 100644 --- a/routes.php +++ b/routes.php @@ -30,9 +30,13 @@ $router->mount('/trending', function () use ($router) { $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/id instead + */ $router->get('/video/(\w+)', 'VideoController@get'); $router->mount('/tag', function () use ($router) {