mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-06-20 20:05:42 +02:00
[GoComicsBridge] Add fallback when link to current comic is missing (#4589)
This commit is contained in:
parent
8dada08e69
commit
354cea09a7
1 changed files with 14 additions and 2 deletions
|
@ -32,8 +32,20 @@ class GoComicsBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
$link = $this->getURI();
|
$link = $this->getURI();
|
||||||
$landingpage = getSimpleHTMLDOM($link);
|
$landingpage = getSimpleHTMLDOM($link);
|
||||||
|
$element = $landingpage->find('div[data-post-url]', 0);
|
||||||
$link = $landingpage->find('div[data-post-url]', 0)->getAttribute('data-post-url');
|
if ($element) {
|
||||||
|
$link = $element->getAttribute('data-post-url');
|
||||||
|
} else { // fallback for comics without data-post-url (assumes daily comic)
|
||||||
|
$nextcomiclink = $landingpage->find('a[class*="ComicNavigation_controls__button_previous__"]', 0)->href;
|
||||||
|
preg_match('/(\d{4}\/\d{2}\/\d{2})/', $nextcomiclink, $nclmatches);
|
||||||
|
if (!empty($nclmatches[1])) {
|
||||||
|
$nextdate = new DateTime($nclmatches[1]);
|
||||||
|
$nextdate = $nextdate->modify('+1 day')->format('Y/m/d');
|
||||||
|
$link = $link . '/' . $nextdate;
|
||||||
|
} else {
|
||||||
|
throw new \Exception('Could not find the first comic URL. Please create a new GitHub issue.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < $this->getInput('limit'); $i++) {
|
for ($i = 0; $i < $this->getInput('limit'); $i++) {
|
||||||
$html = getSimpleHTMLDOM($link);
|
$html = getSimpleHTMLDOM($link);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue