fix: various small fixes (#3853)

This commit is contained in:
Dag 2023-12-21 09:24:22 +01:00 committed by GitHub
parent 4c5cf89725
commit f40f997405
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 14 deletions

View File

@ -63,11 +63,13 @@ class ARDAudiothekBridge extends BridgeAbstract
public function collectData() public function collectData()
{ {
$oldTz = date_default_timezone_get(); $path = $this->getInput('path');
$limit = $this->getInput('limit');
$oldTz = date_default_timezone_get();
date_default_timezone_set('Europe/Berlin'); date_default_timezone_set('Europe/Berlin');
$pathComponents = explode('/', $this->getInput('path')); $pathComponents = explode('/', $path);
if (empty($pathComponents)) { if (empty($pathComponents)) {
returnClientError('Path may not be empty'); returnClientError('Path may not be empty');
} }
@ -82,17 +84,21 @@ class ARDAudiothekBridge extends BridgeAbstract
} }
$url = self::APIENDPOINT . 'programsets/' . $showID . '/'; $url = self::APIENDPOINT . 'programsets/' . $showID . '/';
$rawJSON = getContents($url); $json1 = getContents($url);
$processedJSON = json_decode($rawJSON)->data->programSet; $data1 = Json::decode($json1, false);
$processedJSON = $data1->data->programSet;
if (!$processedJSON) {
throw new \Exception('Unable to find show id: ' . $showID);
}
$limit = $this->getInput('limit');
$answerLength = 1; $answerLength = 1;
$offset = 0; $offset = 0;
$numberOfElements = 1; $numberOfElements = 1;
while ($answerLength != 0 && $offset < $numberOfElements && (is_null($limit) || $offset < $limit)) { while ($answerLength != 0 && $offset < $numberOfElements && (is_null($limit) || $offset < $limit)) {
$rawJSON = getContents($url . '?offset=' . $offset); $json2 = getContents($url . '?offset=' . $offset);
$processedJSON = json_decode($rawJSON)->data->programSet; $data2 = Json::decode($json2, false);
$processedJSON = $data2->data->programSet;
$answerLength = count($processedJSON->items->nodes); $answerLength = count($processedJSON->items->nodes);
$offset = $offset + $answerLength; $offset = $offset + $answerLength;

View File

@ -9,8 +9,7 @@ class CarThrottleBridge extends BridgeAbstract
public function collectData() public function collectData()
{ {
$news = getSimpleHTMLDOMCached(self::URI . 'news') $news = getSimpleHTMLDOMCached(self::URI . 'news');
or returnServerError('could not retrieve page');
$this->items[] = []; $this->items[] = [];
@ -22,8 +21,7 @@ class CarThrottleBridge extends BridgeAbstract
$item['uri'] = self::URI . $titleElement->getAttribute('href'); $item['uri'] = self::URI . $titleElement->getAttribute('href');
$item['title'] = $titleElement->innertext; $item['title'] = $titleElement->innertext;
$articlePage = getSimpleHTMLDOMCached($item['uri']) $articlePage = getSimpleHTMLDOMCached($item['uri']);
or returnServerError('could not retrieve page');
$authorDiv = $articlePage->find('div.author div'); $authorDiv = $articlePage->find('div.author div');
if ($authorDiv) { if ($authorDiv) {

View File

@ -96,7 +96,7 @@ class EZTVBridge extends BridgeAbstract
protected function getItemFromTorrent($torrent) protected function getItemFromTorrent($torrent)
{ {
$item = []; $item = [];
$item['uri'] = $torrent->episode_url; $item['uri'] = $torrent->episode_url ?? $torrent->torrent_url;
$item['author'] = $torrent->imdb_id; $item['author'] = $torrent->imdb_id;
$item['timestamp'] = $torrent->date_released_unix; $item['timestamp'] = $torrent->date_released_unix;
$item['title'] = $torrent->title; $item['title'] = $torrent->title;

View File

@ -648,7 +648,7 @@ class TrelloBridge extends BridgeAbstract
$action->type $action->type
]; ];
if (isset($action->data->card)) { if (isset($action->data->card)) {
$item['categories'][] = $action->data->card->name; $item['categories'][] = $action->data->card->name ?? $action->data->card->id;
$item['uri'] = 'https://trello.com/c/' $item['uri'] = 'https://trello.com/c/'
. $action->data->card->shortLink . $action->data->card->shortLink
. '#action-' . '#action-'

View File

@ -164,7 +164,11 @@ class YoutubeBridge extends BridgeAbstract
$jsonData = $this->extractJsonFromHtml($html); $jsonData = $this->extractJsonFromHtml($html);
// TODO: this method returns only first 100 video items // TODO: this method returns only first 100 video items
// if it has more videos, playlistVideoListRenderer will have continuationItemRenderer as last element // if it has more videos, playlistVideoListRenderer will have continuationItemRenderer as last element
$jsonData = $jsonData->contents->twoColumnBrowseResultsRenderer->tabs[0]; $jsonData = $jsonData->contents->twoColumnBrowseResultsRenderer->tabs[0] ?? null;
if (!$jsonData) {
// playlist probably doesnt exists
throw new \Exception('Unable to find playlist: ' . $url_listing);
}
$jsonData = $jsonData->tabRenderer->content->sectionListRenderer->contents[0]->itemSectionRenderer; $jsonData = $jsonData->tabRenderer->content->sectionListRenderer->contents[0]->itemSectionRenderer;
$jsonData = $jsonData->contents[0]->playlistVideoListRenderer->contents; $jsonData = $jsonData->contents[0]->playlistVideoListRenderer->contents;
$item_count = count($jsonData); $item_count = count($jsonData);