mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-28 22:28:51 +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 = '';
|
||||
|
||||
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()
|
||||
{
|
||||
$html = getSimpleHTMLDOM($this->getURI());
|
||||
|
@ -48,10 +36,15 @@ class TikTokBridge extends BridgeAbstract
|
|||
foreach ($html->find('div.tiktok-x6y88p-DivItemContainerV2') as $div) {
|
||||
$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();
|
||||
}
|
||||
$item['uri'] = $link;
|
||||
|
||||
$a = $div->find('a', 1);
|
||||
|
@ -93,10 +86,25 @@ EOD;
|
|||
|
||||
private function processUsername()
|
||||
{
|
||||
if (substr($this->getInput('username'), 0, 1) !== '@') {
|
||||
return '@' . $this->getInput('username');
|
||||
$username = trim($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…
Reference in a new issue