fix: various fixes (#3136)

This commit is contained in:
Dag 2022-11-08 21:17:32 +01:00 committed by GitHub
parent 00ff0890bb
commit b64f8f2a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 15 deletions

View File

@ -64,7 +64,11 @@ TEXT;
}
// Sort by timestamp descending
usort($this->items, fn ($a, $b) => $b['timestamp'] <=> $a['timestamp']);
usort($this->items, function ($a, $b) {
$t1 = $a['timestamp'] ?? $a['uri'] ?? $a['title'];
$t2 = $b['timestamp'] ?? $b['uri'] ?? $b['title'];
return $t2 <=> $t1;
});
// Remove duplicates by using url as unique key
$items = [];

View File

@ -84,12 +84,16 @@ query VODList($channel: String!, $types: [BroadcastType!]) {
}
}
EOD;
$channel = $this->getInput('channel');
$type = $this->getInput('type');
$variables = [
'channel' => $this->getInput('channel'),
'types' => self::BROADCAST_TYPES[$this->getInput('type')]
'channel' => $channel,
'types' => self::BROADCAST_TYPES[$type]
];
$data = $this->apiRequest($query, $variables);
if ($data->user === null) {
throw new \Exception(sprintf('Unable to find channel `%s`', $channel));
}
$user = $data->user;
foreach ($user->videos->edges as $edge) {
$video = $edge->node;

View File

@ -49,20 +49,24 @@ class UsbekEtRicaBridge extends BridgeAbstract
$item['author'] = $author->plaintext;
}
$content = null;
$u = $article->find('a.card-img', 0);
$uri = $u->href;
if (substr($uri, 0, 1) === 'h') { // absolute uri
$item['uri'] = $uri;
} else { // relative uri
$item['uri'] = $this->getURI() . $uri;
if ($u) {
$uri = $u->href;
if (substr($uri, 0, 1) === 'h') {
// absolute uri
$item['uri'] = $uri;
} else {
// relative uri
$item['uri'] = $this->getURI() . $uri;
}
if ($fullarticle) {
$content = $this->loadFullArticle($item['uri']);
}
}
if ($fullarticle) {
$content = $this->loadFullArticle($item['uri']);
}
if ($fullarticle && !is_null($content)) {
if ($fullarticle && $content) {
$item['content'] = $content;
} else {
$excerpt = $article->find('div.card-excerpt', 0);