mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-17 23:59:55 +03:00
fix(tiktok): feed item link (#3511)
* fix(tiktok): feed item link * fix(tiktok): support entire url, for convenience
This commit is contained in:
parent
341649a8a4
commit
61b307a9f9
1 changed files with 23 additions and 15 deletions
|
@ -26,18 +26,6 @@ class TikTokBridge extends BridgeAbstract
|
||||||
|
|
||||||
private $feedName = '';
|
private $feedName = '';
|
||||||
|
|
||||||
public function detectParameters($url)
|
|
||||||
{
|
|
||||||
if (preg_match('/tiktok\.com\/(@[\w]+)/', $url, $matches) > 0) {
|
|
||||||
return [
|
|
||||||
'context' => 'By user',
|
|
||||||
'username' => $matches[1]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
$html = getSimpleHTMLDOM($this->getURI());
|
$html = getSimpleHTMLDOM($this->getURI());
|
||||||
|
@ -48,10 +36,15 @@ class TikTokBridge extends BridgeAbstract
|
||||||
foreach ($html->find('div.tiktok-x6y88p-DivItemContainerV2') as $div) {
|
foreach ($html->find('div.tiktok-x6y88p-DivItemContainerV2') as $div) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
|
||||||
|
// todo: find proper link to tiktok item
|
||||||
$link = $div->find('a', 0)->href;
|
$link = $div->find('a', 0)->href;
|
||||||
|
|
||||||
$image = $div->find('img', 0)->src;
|
$image = $div->find('img', 0)->src;
|
||||||
$views = $div->find('strong.video-count', 0)->plaintext;
|
$views = $div->find('strong.video-count', 0)->plaintext;
|
||||||
|
|
||||||
|
if ($link === 'https://www.tiktok.com/') {
|
||||||
|
$link = $this->getURI();
|
||||||
|
}
|
||||||
$item['uri'] = $link;
|
$item['uri'] = $link;
|
||||||
|
|
||||||
$a = $div->find('a', 1);
|
$a = $div->find('a', 1);
|
||||||
|
@ -93,10 +86,25 @@ EOD;
|
||||||
|
|
||||||
private function processUsername()
|
private function processUsername()
|
||||||
{
|
{
|
||||||
if (substr($this->getInput('username'), 0, 1) !== '@') {
|
$username = trim($this->getInput('username'));
|
||||||
return '@' . $this->getInput('username');
|
if (preg_match('#^https?://www\.tiktok\.com/@(.*)$#', $username, $m)) {
|
||||||
|
return '@' . $m[1];
|
||||||
|
}
|
||||||
|
if (substr($username, 0, 1) !== '@') {
|
||||||
|
return '@' . $username;
|
||||||
|
}
|
||||||
|
return $username;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getInput('username');
|
public function detectParameters($url)
|
||||||
|
{
|
||||||
|
if (preg_match('/tiktok\.com\/(@[\w]+)/', $url, $matches) > 0) {
|
||||||
|
return [
|
||||||
|
'context' => 'By user',
|
||||||
|
'username' => $matches[1]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue