mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-28 22:28:51 +03:00
[TikTokBridge] Use another way to get videos infos to include video link (#3557)
* [TikTokBridge] Use another way to get videos infos to include video link * [TikTokBridge] Use cover if dynamicCover is empty * [TikTokBridge] Add support for the rest of item params
This commit is contained in:
parent
2ffb54c7c2
commit
663729cf19
1 changed files with 23 additions and 19 deletions
|
@ -33,32 +33,36 @@ class TikTokBridge extends BridgeAbstract
|
||||||
$title = $html->find('h1', 0)->plaintext ?? self::NAME;
|
$title = $html->find('h1', 0)->plaintext ?? self::NAME;
|
||||||
$this->feedName = htmlspecialchars_decode($title);
|
$this->feedName = htmlspecialchars_decode($title);
|
||||||
|
|
||||||
foreach ($html->find('div.tiktok-x6y88p-DivItemContainerV2') as $div) {
|
$SIGI_STATE_RAW = $html->find('script[id=SIGI_STATE]', 0)->innertext;
|
||||||
|
$SIGI_STATE = json_decode($SIGI_STATE_RAW);
|
||||||
|
|
||||||
|
foreach ($SIGI_STATE->ItemModule as $key => $value) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
|
||||||
// todo: find proper link to tiktok item
|
$link = 'https://www.tiktok.com/@' . $value->author . '/video/' . $value->id;
|
||||||
$link = $div->find('a', 0)->href;
|
$image = $value->video->dynamicCover;
|
||||||
|
if (empty($image)) {
|
||||||
$image = $div->find('img', 0)->src ?? '';
|
$image = $value->video->cover;
|
||||||
|
|
||||||
$views = $div->find('strong.video-count', 0)->plaintext;
|
|
||||||
|
|
||||||
if ($link === 'https://www.tiktok.com/') {
|
|
||||||
$link = $this->getURI();
|
|
||||||
}
|
}
|
||||||
|
$views = $value->stats->playCount;
|
||||||
|
$hastags = [];
|
||||||
|
foreach ($value->textExtra as $tag) {
|
||||||
|
$hastags[] = $tag->hashtagName;
|
||||||
|
}
|
||||||
|
$hastags_str = '';
|
||||||
|
foreach ($hastags as $tag) {
|
||||||
|
$hastags_str .= '<a href="https://www.tiktok.com/tag/' . $tag . '">#' . $tag . '</a> ';
|
||||||
|
}
|
||||||
|
|
||||||
$item['uri'] = $link;
|
$item['uri'] = $link;
|
||||||
|
$item['title'] = $value->desc;
|
||||||
$a = $div->find('a', 1);
|
$item['timestamp'] = $value->createTime;
|
||||||
if ($a) {
|
$item['author'] = '@' . $value->author;
|
||||||
$item['title'] = $a->plaintext;
|
|
||||||
} else {
|
|
||||||
$item['title'] = $this->getName();
|
|
||||||
}
|
|
||||||
$item['enclosures'][] = $image;
|
$item['enclosures'][] = $image;
|
||||||
|
$item['categories'] = $hastags;
|
||||||
$item['content'] = <<<EOD
|
$item['content'] = <<<EOD
|
||||||
<a href="{$link}"><img src="{$image}"/></a>
|
<a href="{$link}"><img src="{$image}"/></a>
|
||||||
<p>{$views} views<p>
|
<p>{$views} views<p><br/>Hashtags: {$hastags_str}
|
||||||
EOD;
|
EOD;
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
|
Loading…
Reference in a new issue