mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-30 06:43:38 +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) {
|
||||
if ($obj->wrapperType === 'collection') {
|
||||
$copyright = $obj->copyright ?? '';
|
||||
|
||||
$this->items[] = [
|
||||
'title' => $obj->artistName . ' - ' . $obj->collectionName,
|
||||
'uri' => $obj->collectionViewUrl,
|
||||
|
@ -49,7 +51,7 @@ class AppleMusicBridge extends BridgeAbstract
|
|||
. '><img src="' . $obj->artworkUrl100 . '" /></a><br><br>'
|
||||
. $obj->artistName . ' - ' . $obj->collectionName
|
||||
. '<br>'
|
||||
. $obj->copyright,
|
||||
. $copyright,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ class AskfmBridge extends BridgeAbstract
|
|||
|
||||
$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
|
||||
if ($visual = $element->find('div.streamItem_visual', 0)) {
|
||||
|
|
|
@ -23,8 +23,9 @@ class FeedReducerBridge extends FeedExpander
|
|||
|
||||
public function collectData()
|
||||
{
|
||||
if (preg_match('#^http(s?)://#i', $this->getInput('url'))) {
|
||||
$this->collectExpandableDatas($this->getInput('url'));
|
||||
$url = $this->getInput('url');
|
||||
if (preg_match('#^http(s?)://#i', $url)) {
|
||||
$this->collectExpandableDatas($url);
|
||||
} else {
|
||||
throw new Exception('URI must begin with http(s)://');
|
||||
}
|
||||
|
@ -35,7 +36,7 @@ class FeedReducerBridge extends FeedExpander
|
|||
$filteredItems = [];
|
||||
$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:
|
||||
// - 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
|
||||
|
@ -43,13 +44,13 @@ class FeedReducerBridge extends FeedExpander
|
|||
// $pseudoRandomInteger will be a 16 bit unsigned int mod 100.
|
||||
// This won't be uniformly distributed 1-100, but should be close enough.
|
||||
|
||||
$pseudoRandomInteger = unpack(
|
||||
'S', // unsigned 16-bit int
|
||||
hash('sha256', $thisItem['uri'] . '::' . $this->getInput('url'), true)
|
||||
)[1] % 100;
|
||||
$data = $item['uri'] . '::' . $this->getInput('url');
|
||||
$hash = hash('sha256', $data, true);
|
||||
// S = unsigned 16-bit int
|
||||
$pseudoRandomInteger = unpack('S', $hash)[1] % 100;
|
||||
|
||||
if ($pseudoRandomInteger < $intPercentage) {
|
||||
$filteredItems[] = $thisItem;
|
||||
$filteredItems[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,8 @@ class FourchanBridge extends BridgeAbstract
|
|||
$file = $element->find('.file', 0);
|
||||
|
||||
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;
|
||||
if (!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== false) {
|
||||
$item['imageThumb'] = 'http://i.imgur.com/eO0cxf9.jpg';
|
||||
|
|
|
@ -27,9 +27,10 @@ class GettrBridge extends BridgeAbstract
|
|||
|
||||
public function collectData()
|
||||
{
|
||||
$user = $this->getInput('user');
|
||||
$api = sprintf(
|
||||
'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)
|
||||
);
|
||||
$data = json_decode(getContents($api), false);
|
||||
|
|
|
@ -169,11 +169,19 @@ EOD;
|
|||
$stickerDiv->find('picture', 0)->style = '';
|
||||
|
||||
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>
|
||||
EOD;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
private function processPoll($messageDiv)
|
||||
|
|
|
@ -34,6 +34,9 @@ class TikTokBridge extends BridgeAbstract
|
|||
$this->feedName = htmlspecialchars_decode($title);
|
||||
|
||||
$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 = Json::decode($SIGI_STATE_RAW, false);
|
||||
|
||||
|
|
|
@ -144,6 +144,10 @@ abstract class BridgeAbstract implements BridgeInterface
|
|||
}
|
||||
|
||||
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) {
|
||||
if (isset($this->inputs[$context][$name]['value'])) {
|
||||
continue;
|
||||
|
|
Loading…
Add table
Reference in a new issue