mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-25 10:56:18 +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;
|
||||
$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 = [];
|
||||
|
||||
// todo: find proper link to tiktok item
|
||||
$link = $div->find('a', 0)->href;
|
||||
|
||||
$image = $div->find('img', 0)->src ?? '';
|
||||
|
||||
$views = $div->find('strong.video-count', 0)->plaintext;
|
||||
|
||||
if ($link === 'https://www.tiktok.com/') {
|
||||
$link = $this->getURI();
|
||||
$link = 'https://www.tiktok.com/@' . $value->author . '/video/' . $value->id;
|
||||
$image = $value->video->dynamicCover;
|
||||
if (empty($image)) {
|
||||
$image = $value->video->cover;
|
||||
}
|
||||
$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;
|
||||
|
||||
$a = $div->find('a', 1);
|
||||
if ($a) {
|
||||
$item['title'] = $a->plaintext;
|
||||
} else {
|
||||
$item['title'] = $this->getName();
|
||||
}
|
||||
$item['title'] = $value->desc;
|
||||
$item['timestamp'] = $value->createTime;
|
||||
$item['author'] = '@' . $value->author;
|
||||
$item['enclosures'][] = $image;
|
||||
|
||||
$item['categories'] = $hastags;
|
||||
$item['content'] = <<<EOD
|
||||
<a href="{$link}"><img src="{$image}"/></a>
|
||||
<p>{$views} views<p>
|
||||
<p>{$views} views<p><br/>Hashtags: {$hastags_str}
|
||||
EOD;
|
||||
|
||||
$this->items[] = $item;
|
||||
|
|
Loading…
Reference in a new issue