Animarr/src/Animarr/Source/SourceList.php

38 lines
750 B
PHP

<?php
namespace Animarr\Source;
class SourceList implements Source{
private $sources = [];
public function find($query, $maxResults = -1, $extraQuery = ""){
$results = [];
foreach($this->sources as $source){
if($query !== null and !$source->canSearch()){
continue;
}
if($query === null){
\Animarr\Downloader::log("Polling " . $source->getName(), "POLL");
}
try{
$results = array_merge($results, $source->find($query, $maxResults, $extraQuery));
}catch(\Throwable $e){
echo $e . PHP_EOL;
}
}
return $results;
}
public function getName(){
return "SourceList";
}
public function canSearch(){
return true;
}
public function addSource(Source $source){
$this->sources[] = $source;
}
}