mirror of https://git.lolcat.ca/lolcat/4get.git
Compare commits
3 Commits
96f4fc927a
...
f8d46df1e8
Author | SHA1 | Date |
---|---|---|
lolcat | f8d46df1e8 | |
lolcat | bad8d7ad50 | |
lolcat | f2eb164d40 |
|
@ -453,6 +453,8 @@ class qwant{
|
|||
switch($item["type"]){ // ignores ads
|
||||
|
||||
case "web":
|
||||
|
||||
$first_iteration = true;
|
||||
foreach($item["items"] as $result){
|
||||
|
||||
if(isset($result["thumbnailUrl"])){
|
||||
|
@ -483,6 +485,25 @@ class qwant{
|
|||
}
|
||||
}
|
||||
|
||||
// detect gibberish results
|
||||
if(
|
||||
$first_iteration &&
|
||||
preg_match(
|
||||
"/^" .
|
||||
preg_quote(
|
||||
$this->trimdots(
|
||||
$result["source"]
|
||||
),
|
||||
"/"
|
||||
) .
|
||||
"/",
|
||||
$result["url"]
|
||||
) !== 1
|
||||
){
|
||||
|
||||
throw new Exception("Qwant returned gibberish results");
|
||||
}
|
||||
|
||||
$out["web"][] = [
|
||||
"title" => $this->trimdots($result["title"]),
|
||||
"description" => $this->trimdots($result["desc"]),
|
||||
|
@ -493,6 +514,8 @@ class qwant{
|
|||
"sublink" => $sublinks,
|
||||
"table" => []
|
||||
];
|
||||
|
||||
$first_iteration = false;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -636,6 +659,11 @@ class qwant{
|
|||
throw new Exception("Qwant returned an API error");
|
||||
}
|
||||
|
||||
if(isset($json["data"]["result"]["items"]["mainline"])){
|
||||
|
||||
throw new Exception("Qwant returned gibberish results");
|
||||
}
|
||||
|
||||
$out = [
|
||||
"status" => "ok",
|
||||
"npt" => null,
|
||||
|
@ -731,6 +759,11 @@ class qwant{
|
|||
throw new Exception("Qwant returned an API error");
|
||||
}
|
||||
|
||||
if(isset($json["data"]["result"]["items"]["mainline"])){
|
||||
|
||||
throw new Exception("Qwant returned gibberish results");
|
||||
}
|
||||
|
||||
$out = [
|
||||
"status" => "ok",
|
||||
"npt" => null,
|
||||
|
@ -833,6 +866,11 @@ class qwant{
|
|||
throw new Exception("Qwant returned an API error");
|
||||
}
|
||||
|
||||
if(isset($json["data"]["result"]["items"]["mainline"])){
|
||||
|
||||
throw new Exception("Qwant returned gibberish results");
|
||||
}
|
||||
|
||||
$out = [
|
||||
"status" => "ok",
|
||||
"npt" => null,
|
||||
|
|
Loading…
Reference in New Issue