/video follows TikTok schema

This commit is contained in:
Pablo Ferreiro 2022-03-14 11:50:47 +01:00
parent c682432920
commit 6eee156541
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
6 changed files with 24 additions and 15 deletions

View file

@ -15,7 +15,9 @@ class RedirectController {
} else if (isset($_GET['music'])) { } else if (isset($_GET['music'])) {
$endpoint = '/music/' . $_GET['music']; $endpoint = '/music/' . $_GET['music'];
} else if (isset($_GET['video'])) { } 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); $url = Misc::url($endpoint);

View file

@ -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) { static public function rss(string $username) {
$api = Misc::api(); $api = Misc::api();
$feed = $api->getUserFeed($username); $feed = $api->getUserFeed($username);

View file

@ -1,19 +1,11 @@
<?php <?php
namespace App\Controllers; namespace App\Controllers;
use App\Helpers\ErrorHandler; /**
use App\Helpers\Misc; * @deprecated Please use UserController::video instead
use App\Models\FeedTemplate; */
class VideoController { class VideoController {
static public function get(string $video_id) { static public function get(string $video_id) {
$api = Misc::api(); UserController::video('placeholder', $video_id);
$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);
}
} }
} }

View file

@ -1,7 +1,7 @@
{ {
"name": "pablouser1/proxitok", "name": "pablouser1/proxitok",
"description": "An alternative frontend for TikTok", "description": "An alternative frontend for TikTok",
"version": "2.1.0.0", "version": "2.1.0.1",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"type": "project", "type": "project",
"homepage": "https://github.com/pablouser1/ProxiTok", "homepage": "https://github.com/pablouser1/ProxiTok",

2
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "dcd701a81d130026c44b63870c9a9f73", "content-hash": "f6b066c447574f88ad9255a88892659e",
"packages": [ "packages": [
{ {
"name": "bramus/router", "name": "bramus/router",

View file

@ -30,9 +30,13 @@ $router->mount('/trending', function () use ($router) {
$router->mount('/@([^/]+)', function () use ($router) { $router->mount('/@([^/]+)', function () use ($router) {
$router->get('/', 'UserController@get'); $router->get('/', 'UserController@get');
$router->get('/video/(\w+)', 'UserController@video');
$router->get('/rss', 'UserController@rss'); $router->get('/rss', 'UserController@rss');
}); });
/**
* @deprecated Please use /@username/video/id instead
*/
$router->get('/video/(\w+)', 'VideoController@get'); $router->get('/video/(\w+)', 'VideoController@get');
$router->mount('/tag', function () use ($router) { $router->mount('/tag', function () use ($router) {