Skip to content

Commit

Permalink
Update AnisearchBridge.php (RSS-Bridge#4025)
Browse files Browse the repository at this point in the history
* Update AnisearchBridge.php

added youtube trailer

* made trailers optional and reduced scraping to 5 articles if selected

* Update AnisearchBridge.php
  • Loading branch information
Tone866 committed Mar 29, 2024
1 parent be44575 commit e0be366
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions bridges/AnisearchBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,29 @@ class AnisearchBridge extends BridgeAbstract
'JP'
=> 'https://www.anisearch.de/anime/index/page-1?char=all&synchro=ja&sort=date&order=desc&view=4'
]
],
'trailers' => [
'name' => 'Trailers',
'type' => 'checkbox',
'title' => 'Will include trailes',
'defaultValue' => false
]
]];

public function collectData()
{
$baseurl = 'https://www.anisearch.de/';
$trailers = false;
$trailers = $this->getInput('trailers');
$limit = 10;
if ($trailers) {
$limit = 5;
}

$dom = getSimpleHTMLDOM($this->getInput('category'));

foreach ($dom->find('li.btype0') as $key => $li) {
if ($key > $limit) {
if ($key >= $limit) {
break;
}

Expand All @@ -44,10 +57,29 @@ public function collectData()
$headerimage = $domarticle->find('img#details-cover', 0);
$src = $headerimage->src;

foreach ($content->find('.hidden') as $element) {
$element->remove();
}

//get trailer
$ytlink = '';
if ($trailers) {
$trailerlink = $domarticle->find('section#trailers > div > div.swiper > ul.swiper-wrapper > li.swiper-slide > a', 0);
if (isset($trailerlink)) {
$trailersite = getSimpleHTMLDOM($baseurl . $trailerlink->href);
$trailer = $trailersite->find('div#player > iframe', 0);
$ytlink = <<<EOT
<br /><iframe width="560" height="315" src="' . $trailer->{'data-xsrc'} . '" title="YouTube video player"
frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>';
EOT;
}
}

$this->items[] = [
'title' => $title->plaintext,
'uri' => $url,
'content' => $headerimage . '<br />' . $content
'content' => $headerimage . '<br />' . $content . $ytlink
];
}
}
Expand Down

0 comments on commit e0be366

Please sign in to comment.