Revert "Added better og support"

This reverts commit fa3f1e0a7c.
This commit is contained in:
Pablo Ferreiro 2022-11-26 23:36:20 +01:00
parent fa3f1e0a7c
commit ee6e8b0593
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
15 changed files with 47 additions and 84 deletions

View file

@ -11,9 +11,8 @@ class EmbedController {
$video = $api->video($id); $video = $api->video($id);
$video->feed(); $video->feed();
if ($video->ok()) { if ($video->ok()) {
$item = $video->getFeed()->items[0]; $data = $video->getFull();
$info = $video->getInfo(); Wrappers::latte('video', new VideoTemplate($data->feed->items[0], $data->info->detail, true));
Wrappers::latte('video', new VideoTemplate($item, $info, true));
} else { } else {
ErrorHandler::showMeta($video->error()); ErrorHandler::showMeta($video->error());
} }

View file

@ -14,9 +14,8 @@ class MusicController {
$music = $api->music($music_id); $music = $api->music($music_id);
$music->feed($cursor); $music->feed($cursor);
if ($music->ok()) { if ($music->ok()) {
$info = $music->getInfo(); $data = $music->getFull();
$feed = $music->getFeed(); Wrappers::latte('music', new FullTemplate('Music', $data));
Wrappers::latte('music', new FullTemplate('Music', $info, $feed));
} else { } else {
ErrorHandler::showMeta($music->error()); ErrorHandler::showMeta($music->error());
} }

View file

@ -2,6 +2,7 @@
namespace App\Controllers; namespace App\Controllers;
use App\Helpers\Cookies; use App\Helpers\Cookies;
use TikScraper\Helpers\Converter;
class ProxyController { class ProxyController {
const VALID_TIKTOK_DOMAINS = [ const VALID_TIKTOK_DOMAINS = [

View file

@ -15,9 +15,8 @@ class TagController {
$hashtag = $api->hashtag($name); $hashtag = $api->hashtag($name);
$hashtag->feed($cursor); $hashtag->feed($cursor);
if ($hashtag->ok()) { if ($hashtag->ok()) {
$info = $hashtag->getInfo(); $data = $hashtag->getFull();
$feed = $hashtag->getFeed(); Wrappers::latte('tag', new FullTemplate($data->info->detail->title, $data));
Wrappers::latte('tag', new FullTemplate($info->detail->title, $info, $feed));
} else { } else {
ErrorHandler::showMeta($hashtag->error()); ErrorHandler::showMeta($hashtag->error());
} }

View file

@ -16,13 +16,12 @@ class UserController {
$user = $api->user($username); $user = $api->user($username);
$user->feed($cursor); $user->feed($cursor);
if ($user->ok()) { if ($user->ok()) {
$info = $user->getInfo(); $data = $user->getFull();
$feed = $user->getFeed(); if ($data->info->detail->privateAccount) {
if ($info->detail->privateAccount) {
ErrorHandler::showText(401, "Private account detected! Not supported"); ErrorHandler::showText(401, "Private account detected! Not supported");
return; return;
} }
Wrappers::latte('user', new FullTemplate($info->detail->nickname, $info, $feed)); Wrappers::latte('user', new FullTemplate($data->info->detail->nickname, $data));
} else { } else {
ErrorHandler::showMeta($user->error()); ErrorHandler::showMeta($user->error());
} }
@ -33,9 +32,8 @@ class UserController {
$video = $api->video($video_id); $video = $api->video($video_id);
$video->feed(); $video->feed();
if ($video->ok()) { if ($video->ok()) {
$item = $video->getFeed()->items[0]; $data = $video->getFull();
$info = $video->getInfo(); Wrappers::latte('video', new VideoTemplate($data->feed->items[0], $data->info->detail));
Wrappers::latte('video', new VideoTemplate($item, $info));
} else { } else {
ErrorHandler::showMeta($video->error()); ErrorHandler::showMeta($video->error());
} }

View file

@ -1,19 +1,16 @@
<?php <?php
namespace App\Models; namespace App\Models;
use TikScraper\Models\Feed; use TikScraper\Models\Full;
use TikScraper\Models\Info;
/** /**
* Base for templates with both info and feed * Base for templates with both info and feed
*/ */
class FullTemplate extends BaseTemplate { class FullTemplate extends BaseTemplate {
public Info $info; public Full $data;
public Feed $feed;
function __construct(string $title, Info $info, Feed $feed) { function __construct(string $title, Full $data) {
parent::__construct($title); parent::__construct($title);
$this->info = $info; $this->data = $data;
$this->feed = $feed;
} }
} }

View file

@ -1,20 +1,18 @@
<?php <?php
namespace App\Models; namespace App\Models;
use TikScraper\Models\Info;
/** /**
* Base for templates with a feed * Base for templates with a feed
*/ */
class VideoTemplate extends BaseTemplate { class VideoTemplate extends BaseTemplate {
public object $item; public object $item;
public Info $info; public object $detail;
public string $layout = 'hero'; public string $layout = 'hero';
function __construct(object $item, Info $info, bool $isEmbed = false) { function __construct(object $item, object $detail, bool $isEmbed = false) {
parent::__construct('Video'); parent::__construct('Video');
$this->item = $item; $this->item = $item;
$this->info = $info; $this->detail = $detail;
if ($isEmbed) { if ($isEmbed) {
$this->layout = 'embed'; $this->layout = 'embed';
} else { } else {

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.3.4", "version": "2.4.3.3",
"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": "5ed78859acc6f451f60b75dca1887104", "content-hash": "8100904920dbc589a80f80dd56cd6faf",
"packages": [ "packages": [
{ {
"name": "bramus/router", "name": "bramus/router",
@ -263,16 +263,16 @@
}, },
{ {
"name": "pablouser1/tikscraper", "name": "pablouser1/tikscraper",
"version": "v2.3.3.0", "version": "v2.3.2.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pablouser1/TikScraperPHP.git", "url": "https://github.com/pablouser1/TikScraperPHP.git",
"reference": "2da42296d97138acb75df5a3b70e7fd0a24ec270" "reference": "2016443571f87265ca8e37897d88009affdcd0b6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/2da42296d97138acb75df5a3b70e7fd0a24ec270", "url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/2016443571f87265ca8e37897d88009affdcd0b6",
"reference": "2da42296d97138acb75df5a3b70e7fd0a24ec270", "reference": "2016443571f87265ca8e37897d88009affdcd0b6",
"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.0" "source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.3.2.2"
}, },
"time": "2022-11-26T22:27:16+00:00" "time": "2022-11-22T19:43:57+00:00"
}, },
{ {
"name": "php-webdriver/webdriver", "name": "php-webdriver/webdriver",

View file

@ -6,26 +6,10 @@
<link rel="icon" type="image/png" sizes="32x32" href="{path('/favicon-32x32.png')}"> <link rel="icon" type="image/png" sizes="32x32" href="{path('/favicon-32x32.png')}">
<link rel="icon" type="image/png" sizes="16x16" href="{path('/favicon-16x16.png')}"> <link rel="icon" type="image/png" sizes="16x16" href="{path('/favicon-16x16.png')}">
<link rel="manifest" href="{path('/site.webmanifest')}"> <link rel="manifest" href="{path('/site.webmanifest')}">
{if isset($og, $og_content, $og_url)} <meta property="og:site_name" content="ProxiTok" />
<!-- Using TikTok's meta config -->
<meta property="og:title" content="{$og->title}" />
<meta property="og:description" content="{$og->description}" />
<meta property="og:url" content="{$og_url}" />
<meta property="og:image" content="{url_stream($og_content)}" />
<meta property="twitter:title" content="{$og->title}" />
<meta property="twitter:description" content="{$og->description}" />
<meta property="twitter:image" content="{url_stream($og_content)}" />
{else}
<!-- Using predifined ProxiTok config -->
<meta property="og:title" content="{$title}" /> <meta property="og:title" content="{$title}" />
<meta property="og:description" content="Alternative frontend for TikTok" /> <meta property="og:description" content="Alternative frontend for TikTok" />
<meta property="twitter:title" content="{$title}" />
<meta property="twitter:description" content="Alternative frontend for TikTok" />
{/if}
<meta property="og:site_name" content="ProxiTok" />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="twitter:card" content="summary" />
<meta property="twitter:site" content="ProxiTok" />
{if isset($has_rss)} {if isset($has_rss)}
<link rel="alternate" type="application/rss+xml" title="{$title}" href="{$_SERVER['REQUEST_URI'] . '/rss'}" /> <link rel="alternate" type="application/rss+xml" title="{$title}" href="{$_SERVER['REQUEST_URI'] . '/rss'}" />
{/if} {/if}

View file

@ -2,7 +2,7 @@
<noscript>JavaScript is required for this section to work!</noscript> <noscript>JavaScript is required for this section to work!</noscript>
<section class="section"> <section class="section">
<div class="columns is-multiline is-vcentered"> <div class="columns is-multiline is-vcentered">
{foreach $feed->items as $item} {foreach $data->feed->items as $item}
{do $share_url = url_video_external($item->author->uniqueId, $item->id)} {do $share_url = url_video_external($item->author->uniqueId, $item->id)}
<div class="column is-one-quarter clickable-img" id="{$item->id}" onclick="openVideo(this.id)" <div class="column is-one-quarter clickable-img" id="{$item->id}" onclick="openVideo(this.id)"
data-video_url="{url_stream($item->video->playAddr)}" data-video_url="{url_stream($item->video->playAddr)}"
@ -17,7 +17,7 @@
<img class="hidden" loading="lazy" data-src="{url_stream($item->video->dynamicCover)}" /> <img class="hidden" loading="lazy" data-src="{url_stream($item->video->dynamicCover)}" />
</div> </div>
{/foreach} {/foreach}
{if empty($feed->items)} {if empty($data->feed->items)}
<p class="title">No items sent by TikTok!</p> <p class="title">No items sent by TikTok!</p>
{/if} {/if}
</div> </div>

View file

@ -1,5 +1,5 @@
<div class="container"> <div class="container">
{foreach $feed->items as $item} {foreach $data->feed->items as $item}
<article class="media"> <article class="media">
<figure class="media-left"> <figure class="media-left">
<p class="image is-64x64"> <p class="image is-64x64">
@ -31,7 +31,7 @@
</div> </div>
</article> </article>
{/foreach} {/foreach}
{if empty($feed->items)} {if empty($data->feed->items)}
<p class="title">No items sent by TikTok!</p> <p class="title">No items sent by TikTok!</p>
{/if} {/if}
</div> </div>

View file

@ -2,19 +2,15 @@
{var $has_rss = true} {var $has_rss = true}
{var $og = $info->meta->og}
{var $og_content = $info->detail->profileLarger}
{var $og_url = url_tag($info->detail->title)}
{block header} {block header}
{if $info->detail->profileLarger !== ''} {if $data->info->detail->profileLarger !== ''}
<figure class="image is-inline-block is-128x128"> <figure class="image is-inline-block is-128x128">
<img class="is-rounded" src="{url_stream($info->detail->profileLarger)}" /> <img class="is-rounded" src="{url_stream($data->info->detail->profileLarger)}" />
</figure> </figure>
{/if} {/if}
<p class="title">{$info->detail->title}</p> <p class="title">{$data->info->detail->title}</p>
<p class="subtitle">{include '../components/rss.latte'}</p> <p class="subtitle">{include '../components/rss.latte'}</p>
<p>Videos: {number($info->stats->videoCount)} / Views: {number($info->stats->viewCount)}</p> <p>Videos: {number($data->info->stats->videoCount)} / Views: {number($data->info->stats->viewCount)}</p>
{/block} {/block}
{block content} {block content}

View file

@ -2,19 +2,15 @@
{var $has_rss = true} {var $has_rss = true}
{var $og = $info->meta->og}
{var $og_content = $info->detail->avatarLarger}
{var $og_url = url_user($info->detail->uniqueId)}
{block header} {block header}
<figure class="image is-inline-block is-128x128"> <figure class="image is-inline-block is-128x128">
<img class="is-rounded" src="{url_stream($info->detail->avatarLarger)}" /> <img class="is-rounded" src="{url_stream($data->info->detail->avatarLarger)}" />
</figure> </figure>
<p class="title">{$info->detail->uniqueId}</p> <p class="title">{$data->info->detail->uniqueId}</p>
<p class="subtitle">{include '../components/rss.latte'}</p> <p class="subtitle">{include '../components/rss.latte'}</p>
<p>{$info->detail->signature}</p> <p>{$data->info->detail->signature}</p>
<p>Following: {number($info->stats->followingCount)} / Followers: {number($info->stats->followerCount)}</p> <p>Following: {number($data->info->stats->followingCount)} / Followers: {number($data->info->stats->followerCount)}</p>
<p>Hearts: {number($info->stats->heartCount)} / Videos: {$info->stats->videoCount}</p> <p>Hearts: {number($data->info->stats->heartCount)} / Videos: {$data->info->stats->videoCount}</p>
{/block} {/block}
{block content} {block content}

View file

@ -1,9 +1,5 @@
{layout "../layouts/{$layout}.latte"} {layout "../layouts/{$layout}.latte"}
{var $og = $info->meta->og}
{var $og_content = $item->video->originCover}
{var $og_url = url_video_internal($info->detail->uniqueId, $item->id)}
{block content} {block content}
<div class="columns is-centered is-vcentered is-gapless"> <div class="columns is-centered is-vcentered is-gapless">
<div class="column has-text-centered"> <div class="column has-text-centered">
@ -16,14 +12,14 @@
<article class="media"> <article class="media">
<figure class="media-left"> <figure class="media-left">
<p class="image is-64x64"> <p class="image is-64x64">
<img src="{url_stream($info->detail->avatarThumb)}" /> <img src="{url_stream($detail->avatarThumb)}" />
</p> </p>
</figure> </figure>
<div class="media-content"> <div class="media-content">
<p> <p>
<strong>{$info->detail->nickname}</strong> <strong>{$detail->nickname}</strong>
<small> <small>
<a href="{url_user($info->detail->uniqueId)}">@{$info->detail->uniqueId}</a> <a href="{url_user($detail->uniqueId)}">@{$detail->uniqueId}</a>
</small> </small>
<small title="{date('M d, Y H:i:s e', $item->createTime)}">{date('M d, Y', $item->createTime)}</small> <small title="{date('M d, Y H:i:s e', $item->createTime)}">{date('M d, Y', $item->createTime)}</small>
</p> </p>
@ -34,8 +30,8 @@
<p n:ifcontent>{$item->desc}</p> <p n:ifcontent>{$item->desc}</p>
{include '../components/themes/common/stats.latte', playCount: $item->stats->playCount, diggCount: $item->stats->diggCount, commentCount: $item->stats->commentCount, shareCount: $item->stats->shareCount} {include '../components/themes/common/stats.latte', playCount: $item->stats->playCount, diggCount: $item->stats->diggCount, commentCount: $item->stats->commentCount, shareCount: $item->stats->shareCount}
<div class="has-text-centered"> <div class="has-text-centered">
{include '../components/themes/common/share.latte', uniqueId: $info->detail->uniqueId, id: $item->id} {include '../components/themes/common/share.latte', uniqueId: $detail->uniqueId, id: $item->id}
{include '../components/themes/common/download.latte', playAddr: $item->video->playAddr, id: $item->id, uniqueId: $info->detail->uniqueId} {include '../components/themes/common/download.latte', playAddr: $item->video->playAddr, id: $item->id, uniqueId: $detail->uniqueId}
</div> </div>
</div> </div>
</div> </div>