From e0be3662589fbc86b944906713cd6ebfaaf43ccc Mon Sep 17 00:00:00 2001 From: Tone <66808319+Tone866@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:37:43 +0100 Subject: [PATCH] Update AnisearchBridge.php (#4025) * Update AnisearchBridge.php added youtube trailer * made trailers optional and reduced scraping to 5 articles if selected * Update AnisearchBridge.php --- bridges/AnisearchBridge.php | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/bridges/AnisearchBridge.php b/bridges/AnisearchBridge.php index 639d143feb5..d5aad1c9352 100644 --- a/bridges/AnisearchBridge.php +++ b/bridges/AnisearchBridge.php @@ -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; } @@ -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; + } + } + $this->items[] = [ 'title' => $title->plaintext, 'uri' => $url, - 'content' => $headerimage . '
' . $content + 'content' => $headerimage . '
' . $content . $ytlink ]; } }