mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-19 23:03:01 +02:00
fix(binance): plus some other tweaks (#3753)
This commit is contained in:
@@ -8,48 +8,27 @@ class BinanceBridge extends BridgeAbstract
|
||||
const MAINTAINER = 'thefranke';
|
||||
const CACHE_TIMEOUT = 3600; // 1h
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$url = 'https://www.binance.com/bapi/composite/v1/public/content/blog/list?category=&tag=&page=1&size=12';
|
||||
$json = getContents($url);
|
||||
$data = Json::decode($json, false);
|
||||
foreach ($data->data->blogList as $post) {
|
||||
$item = [];
|
||||
$item['title'] = $post->title;
|
||||
// Url slug not in json
|
||||
//$item['uri'] = $uri;
|
||||
$item['timestamp'] = $post->postTimeUTC / 1000;
|
||||
$item['author'] = 'Binance';
|
||||
$item['content'] = $post->brief;
|
||||
//$item['categories'] = $category;
|
||||
$item['uid'] = $post->idStr;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getIcon()
|
||||
{
|
||||
return 'https://bin.bnbstatic.com/static/images/common/favicon.ico';
|
||||
}
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not fetch Binance blog data.');
|
||||
|
||||
$appData = $html->find('script[id="__APP_DATA"]');
|
||||
$appDataJson = json_decode($appData[0]->innertext);
|
||||
$allposts = $appDataJson->routeProps->f3ac->blogListRes->list;
|
||||
|
||||
foreach ($allposts as $element) {
|
||||
$date = $element->releasedTime;
|
||||
$title = $element->title;
|
||||
$category = $element->category->name;
|
||||
|
||||
$suburl = strtolower($category);
|
||||
$suburl = str_replace(' ', '_', $suburl);
|
||||
|
||||
$uri = self::URI . '/' . $suburl . '/' . $element->idStr;
|
||||
|
||||
$contentHTML = getSimpleHTMLDOMCached($uri);
|
||||
$contentAppData = $contentHTML->find('script[id="__APP_DATA"]');
|
||||
$contentAppDataJson = json_decode($contentAppData[0]->innertext);
|
||||
$content = $contentAppDataJson->routeProps->a106->blogDetail->content;
|
||||
|
||||
$item = [];
|
||||
$item['title'] = $title;
|
||||
$item['uri'] = $uri;
|
||||
$item['timestamp'] = substr($date, 0, -3);
|
||||
$item['author'] = 'Binance';
|
||||
$item['content'] = $content;
|
||||
$item['categories'] = $category;
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
if (count($this->items) >= 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ class CssSelectorComplexBridge extends BridgeAbstract
|
||||
{
|
||||
if (!empty($url_pattern)) {
|
||||
$url_pattern = '/' . str_replace('/', '\/', $url_pattern) . '/';
|
||||
$links = array_filter($links, function ($url) {
|
||||
$links = array_filter($links, function ($url) use ($url_pattern) {
|
||||
return preg_match($url_pattern, $url) === 1;
|
||||
});
|
||||
}
|
||||
@@ -359,7 +359,7 @@ class CssSelectorComplexBridge extends BridgeAbstract
|
||||
$article_content = $entry_html->find($content_selector, 0);
|
||||
|
||||
if (is_null($article_content)) {
|
||||
returnClientError('Could not article content at URL: ' . $entry_url);
|
||||
returnClientError('Could not get article content at URL: ' . $entry_url);
|
||||
}
|
||||
|
||||
$article_content = defaultLinkTo($article_content, $entry_url);
|
||||
|
||||
@@ -85,7 +85,7 @@ class FallGuysBridge extends BridgeAbstract
|
||||
for ($i = 0; $i < count($mediaOptions); $i++) {
|
||||
if (property_exists($mediaOptions[$i], 'youtubeVideo')) {
|
||||
$videoUrl = 'https://youtu.be/' . $mediaOptions[$i]->youtubeVideo->contentId;
|
||||
$image = $mainContentOptions[$i]->image->src;
|
||||
$image = $mainContentOptions[$i]->image->src ?? '';
|
||||
|
||||
$content .= '<p>';
|
||||
|
||||
|
||||
@@ -121,6 +121,9 @@ class InstagramBridge extends BridgeAbstract
|
||||
$directLink = !is_null($this->getInput('direct_links')) && $this->getInput('direct_links');
|
||||
|
||||
$data = $this->getInstagramJSON($this->getURI());
|
||||
if (!$data) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_null($this->getInput('u'))) {
|
||||
$userMedia = $data->data->user->edge_owner_to_timeline_media->edges;
|
||||
@@ -286,9 +289,11 @@ class InstagramBridge extends BridgeAbstract
|
||||
$html = getContents($uri);
|
||||
$scriptRegex = '/window\._sharedData = (.*);<\/script>/';
|
||||
|
||||
preg_match($scriptRegex, $html, $matches, PREG_OFFSET_CAPTURE, 0);
|
||||
|
||||
return json_decode($matches[1][0]);
|
||||
$ret = preg_match($scriptRegex, $html, $matches, PREG_OFFSET_CAPTURE);
|
||||
if ($ret) {
|
||||
return json_decode($matches[1][0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ class MastodonBridge extends BridgeAbstract
|
||||
&& preg_match('/^http(s|):\/\//', $attachment['url'], $match)
|
||||
) {
|
||||
$item['content'] = $item['content'] . '<br /><img ';
|
||||
if ($attachment['name']) {
|
||||
if (isset($attachment['name'])) {
|
||||
$item['content'] .= sprintf('alt="%s" ', $attachment['name']);
|
||||
}
|
||||
$item['content'] .= sprintf('src="%s" />', $attachment['url']);
|
||||
|
||||
@@ -64,15 +64,20 @@ class PokemonTVBridge extends BridgeAbstract
|
||||
continue;
|
||||
}
|
||||
}
|
||||
switch ($element->{'media_type'}) {
|
||||
switch ($element->media_type) {
|
||||
case 'movie':
|
||||
$itemtitle = $element->{'channel_name'};
|
||||
case 'junior':
|
||||
case 'original':
|
||||
case 'non-animation':
|
||||
$itemtitle = $element->channel_name;
|
||||
break;
|
||||
case 'episode':
|
||||
$season = str_pad($mediaelement->{'season'}, 2, '0', STR_PAD_LEFT);
|
||||
$episode = str_pad($mediaelement->{'episode'}, 2, '0', STR_PAD_LEFT);
|
||||
$itemtitle = $element->{'channel_name'} . ' - S' . $season . 'E' . $episode;
|
||||
break;
|
||||
default:
|
||||
$itemtitle = '';
|
||||
}
|
||||
$streamurl = 'https://watch.pokemon.com/' . $this->getCountryCode() . '/#/player?id=' . $mediaelement->{'id'};
|
||||
$item = [];
|
||||
|
||||
Reference in New Issue
Block a user