Fixed Trending and normalized Discover

This commit is contained in:
Pablo Ferreiro 2023-01-26 19:21:14 +01:00
parent 7d2f6e8fd6
commit 78fe44070c
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
7 changed files with 33 additions and 20 deletions

View file

@ -3,16 +3,16 @@ namespace App\Controllers;
use App\Helpers\ErrorHandler; use App\Helpers\ErrorHandler;
use App\Helpers\Wrappers; use App\Helpers\Wrappers;
use App\Models\FeedTemplate; use App\Models\DiscoverTemplate;
class DiscoverController { class DiscoverController {
static public function get() { static public function get() {
$api = Wrappers::api(); $api = Wrappers::api();
$feed = $api->discover(); $data = $api->discover();
if ($feed->meta->success) { if ($data->meta->success) {
Wrappers::latte('discover', new FeedTemplate('Discover', $feed)); Wrappers::latte('discover', new DiscoverTemplate($data));
} else { } else {
ErrorHandler::showMeta($feed->meta); ErrorHandler::showMeta($data->meta);
} }
} }
} }

View file

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use TikScraper\Models\Discover;
class DiscoverTemplate extends BaseTemplate {
public Discover $data;
function __construct(Discover $data) {
parent::__construct("Discover");
$this->data = $data;
}
}

View file

@ -1,16 +1,16 @@
<?php <?php
namespace App\Models; namespace App\Models;
use TikScraper\Models\Feed;
/** /**
* Base for templates with a feed * Base for templates with a feed
*/ */
class FeedTemplate extends BaseTemplate { class FeedTemplate extends BaseTemplate {
public object $data; public Feed $feed;
function __construct(string $title, object $feed) { function __construct(string $title, Feed $feed) {
parent::__construct($title); parent::__construct($title);
$this->data = (object) [ $this->feed = $feed;
'feed' => $feed
];
} }
} }

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.4.4.3", "version": "2.4.5.0",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"type": "project", "type": "project",
"authors": [ "authors": [

14
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": "acb47eb00001b55dbf6825b0ce79cd0b", "content-hash": "818a3e623705c076822f3d895a0d99ca",
"packages": [ "packages": [
{ {
"name": "bramus/router", "name": "bramus/router",
@ -263,16 +263,16 @@
}, },
{ {
"name": "pablouser1/tikscraper", "name": "pablouser1/tikscraper",
"version": "v2.3.3.5", "version": "v2.3.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pablouser1/TikScraperPHP.git", "url": "https://github.com/pablouser1/TikScraperPHP.git",
"reference": "d3b51e6e0fab4cacce27dbbdf76bcb6fa8bf41ef" "reference": "8ee7efd58892d0a6e536b7cc29de200202916394"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/d3b51e6e0fab4cacce27dbbdf76bcb6fa8bf41ef", "url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/8ee7efd58892d0a6e536b7cc29de200202916394",
"reference": "d3b51e6e0fab4cacce27dbbdf76bcb6fa8bf41ef", "reference": "8ee7efd58892d0a6e536b7cc29de200202916394",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -305,9 +305,9 @@
"description": "Get data from TikTok API", "description": "Get data from TikTok API",
"support": { "support": {
"issues": "https://github.com/pablouser1/TikScraperPHP/issues", "issues": "https://github.com/pablouser1/TikScraperPHP/issues",
"source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.3.3.5" "source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.3.4.0"
}, },
"time": "2023-01-26T16:19:23+00:00" "time": "2023-01-26T18:18:34+00:00"
}, },
{ {
"name": "php-webdriver/webdriver", "name": "php-webdriver/webdriver",

View file

@ -1,4 +1,4 @@
<div n:ifset="$info" class="buttons"> <div class="buttons">
{* is_numeric is used to avoid having a back button with ttwid cursors *} {* is_numeric is used to avoid having a back button with ttwid cursors *}
{if isset($_GET['cursor']) && is_numeric($_GET['cursor']) && $_GET['cursor'] != 0} {if isset($_GET['cursor']) && is_numeric($_GET['cursor']) && $_GET['cursor'] != 0}
<a class="button is-danger" href="?cursor=0">First</a> <a class="button is-danger" href="?cursor=0">First</a>

View file

@ -5,7 +5,7 @@
{/block} {/block}
{block content} {block content}
{foreach $data->feed->items as $type => $items} {foreach $data->items as $type => $items}
<p class="title">{$type|firstUpper}</p> <p class="title">{$type|firstUpper}</p>
<div class="columns is-multiline is-vcentered"> <div class="columns is-multiline is-vcentered">
{foreach $items as $item} {foreach $items as $item}