mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-20 00:59:56 +03:00
fix: various small fixes (#3580)
This commit is contained in:
parent
8b6eecea25
commit
7e4807530e
8 changed files with 35 additions and 14 deletions
|
@ -40,6 +40,8 @@ class AppleMusicBridge extends BridgeAbstract
|
||||||
|
|
||||||
foreach ($json->results as $obj) {
|
foreach ($json->results as $obj) {
|
||||||
if ($obj->wrapperType === 'collection') {
|
if ($obj->wrapperType === 'collection') {
|
||||||
|
$copyright = $obj->copyright ?? '';
|
||||||
|
|
||||||
$this->items[] = [
|
$this->items[] = [
|
||||||
'title' => $obj->artistName . ' - ' . $obj->collectionName,
|
'title' => $obj->artistName . ' - ' . $obj->collectionName,
|
||||||
'uri' => $obj->collectionViewUrl,
|
'uri' => $obj->collectionViewUrl,
|
||||||
|
@ -49,7 +51,7 @@ class AppleMusicBridge extends BridgeAbstract
|
||||||
. '><img src="' . $obj->artworkUrl100 . '" /></a><br><br>'
|
. '><img src="' . $obj->artworkUrl100 . '" /></a><br><br>'
|
||||||
. $obj->artistName . ' - ' . $obj->collectionName
|
. $obj->artistName . ' - ' . $obj->collectionName
|
||||||
. '<br>'
|
. '<br>'
|
||||||
. $obj->copyright,
|
. $copyright,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,8 @@ class AskfmBridge extends BridgeAbstract
|
||||||
|
|
||||||
$item['timestamp'] = strtotime($element->find('time', 0)->datetime);
|
$item['timestamp'] = strtotime($element->find('time', 0)->datetime);
|
||||||
|
|
||||||
$answer = trim($element->find('div.streamItem_content', 0)->innertext);
|
$var = $element->find('div.streamItem_content', 0);
|
||||||
|
$answer = trim($var->innertext ?? '');
|
||||||
|
|
||||||
// This probably should be cleaned up, especially for YouTube embeds
|
// This probably should be cleaned up, especially for YouTube embeds
|
||||||
if ($visual = $element->find('div.streamItem_visual', 0)) {
|
if ($visual = $element->find('div.streamItem_visual', 0)) {
|
||||||
|
|
|
@ -23,8 +23,9 @@ class FeedReducerBridge extends FeedExpander
|
||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
if (preg_match('#^http(s?)://#i', $this->getInput('url'))) {
|
$url = $this->getInput('url');
|
||||||
$this->collectExpandableDatas($this->getInput('url'));
|
if (preg_match('#^http(s?)://#i', $url)) {
|
||||||
|
$this->collectExpandableDatas($url);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('URI must begin with http(s)://');
|
throw new Exception('URI must begin with http(s)://');
|
||||||
}
|
}
|
||||||
|
@ -35,7 +36,7 @@ class FeedReducerBridge extends FeedExpander
|
||||||
$filteredItems = [];
|
$filteredItems = [];
|
||||||
$intPercentage = (int)preg_replace('/[^0-9]/', '', $this->getInput('percentage'));
|
$intPercentage = (int)preg_replace('/[^0-9]/', '', $this->getInput('percentage'));
|
||||||
|
|
||||||
foreach ($this->items as $thisItem) {
|
foreach ($this->items as $item) {
|
||||||
// The URL is included in the hash:
|
// The URL is included in the hash:
|
||||||
// - so you can change the output by adding a local-part to the URL
|
// - so you can change the output by adding a local-part to the URL
|
||||||
// - so items with the same URI in different feeds won't be correlated
|
// - so items with the same URI in different feeds won't be correlated
|
||||||
|
@ -43,13 +44,13 @@ class FeedReducerBridge extends FeedExpander
|
||||||
// $pseudoRandomInteger will be a 16 bit unsigned int mod 100.
|
// $pseudoRandomInteger will be a 16 bit unsigned int mod 100.
|
||||||
// This won't be uniformly distributed 1-100, but should be close enough.
|
// This won't be uniformly distributed 1-100, but should be close enough.
|
||||||
|
|
||||||
$pseudoRandomInteger = unpack(
|
$data = $item['uri'] . '::' . $this->getInput('url');
|
||||||
'S', // unsigned 16-bit int
|
$hash = hash('sha256', $data, true);
|
||||||
hash('sha256', $thisItem['uri'] . '::' . $this->getInput('url'), true)
|
// S = unsigned 16-bit int
|
||||||
)[1] % 100;
|
$pseudoRandomInteger = unpack('S', $hash)[1] % 100;
|
||||||
|
|
||||||
if ($pseudoRandomInteger < $intPercentage) {
|
if ($pseudoRandomInteger < $intPercentage) {
|
||||||
$filteredItems[] = $thisItem;
|
$filteredItems[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,8 @@ class FourchanBridge extends BridgeAbstract
|
||||||
$file = $element->find('.file', 0);
|
$file = $element->find('.file', 0);
|
||||||
|
|
||||||
if (!empty($file)) {
|
if (!empty($file)) {
|
||||||
$item['image'] = $element->find('.file a', 0)->href;
|
$var = $element->find('.file a', 0);
|
||||||
|
$item['image'] = $var->href ?? '';
|
||||||
$item['imageThumb'] = $element->find('.file img', 0)->src;
|
$item['imageThumb'] = $element->find('.file img', 0)->src;
|
||||||
if (!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== false) {
|
if (!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== false) {
|
||||||
$item['imageThumb'] = 'http://i.imgur.com/eO0cxf9.jpg';
|
$item['imageThumb'] = 'http://i.imgur.com/eO0cxf9.jpg';
|
||||||
|
|
|
@ -27,9 +27,10 @@ class GettrBridge extends BridgeAbstract
|
||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
|
$user = $this->getInput('user');
|
||||||
$api = sprintf(
|
$api = sprintf(
|
||||||
'https://api.gettr.com/u/user/%s/posts?offset=0&max=%s&dir=fwd&incl=posts&fp=f_uo',
|
'https://api.gettr.com/u/user/%s/posts?offset=0&max=%s&dir=fwd&incl=posts&fp=f_uo',
|
||||||
$this->getInput('user'),
|
$user,
|
||||||
min($this->getInput('limit'), 20)
|
min($this->getInput('limit'), 20)
|
||||||
);
|
);
|
||||||
$data = json_decode(getContents($api), false);
|
$data = json_decode(getContents($api), false);
|
||||||
|
|
|
@ -169,11 +169,19 @@ EOD;
|
||||||
$stickerDiv->find('picture', 0)->style = '';
|
$stickerDiv->find('picture', 0)->style = '';
|
||||||
|
|
||||||
return $stickerDiv;
|
return $stickerDiv;
|
||||||
} elseif (preg_match(self::BACKGROUND_IMAGE_REGEX, $stickerDiv->find('i', 0)->style, $sticker)) {
|
}
|
||||||
return <<<EOD
|
|
||||||
|
$var = $stickerDiv->find('i', 0);
|
||||||
|
if ($var) {
|
||||||
|
$style = $var->style;
|
||||||
|
if (preg_match(self::BACKGROUND_IMAGE_REGEX, $style, $sticker)) {
|
||||||
|
return <<<EOD
|
||||||
<a href="{$stickerDiv->children(0)->herf}"><img src="{$sticker[1]}"></a>
|
<a href="{$stickerDiv->children(0)->herf}"><img src="{$sticker[1]}"></a>
|
||||||
EOD;
|
EOD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processPoll($messageDiv)
|
private function processPoll($messageDiv)
|
||||||
|
|
|
@ -34,6 +34,9 @@ class TikTokBridge extends BridgeAbstract
|
||||||
$this->feedName = htmlspecialchars_decode($title);
|
$this->feedName = htmlspecialchars_decode($title);
|
||||||
|
|
||||||
$var = $html->find('script[id=SIGI_STATE]', 0);
|
$var = $html->find('script[id=SIGI_STATE]', 0);
|
||||||
|
if (!$var) {
|
||||||
|
throw new \Exception('Unable to find tiktok user data for ' . $this->processUsername());
|
||||||
|
}
|
||||||
$SIGI_STATE_RAW = $var->innertext;
|
$SIGI_STATE_RAW = $var->innertext;
|
||||||
$SIGI_STATE = Json::decode($SIGI_STATE_RAW, false);
|
$SIGI_STATE = Json::decode($SIGI_STATE_RAW, false);
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,10 @@ abstract class BridgeAbstract implements BridgeInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($contexts as $context) {
|
foreach ($contexts as $context) {
|
||||||
|
if (!isset(static::PARAMETERS[$context])) {
|
||||||
|
// unknown context provided by client, throw exception here? or continue?
|
||||||
|
}
|
||||||
|
|
||||||
foreach (static::PARAMETERS[$context] as $name => $properties) {
|
foreach (static::PARAMETERS[$context] as $name => $properties) {
|
||||||
if (isset($this->inputs[$context][$name]['value'])) {
|
if (isset($this->inputs[$context][$name]['value'])) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue