fixed bing images failing to load, added flickr

This commit is contained in:
lolcat
2025-04-17 19:54:34 -04:00
committed by ngn
parent 50d6e88365
commit 886037492c
4 changed files with 151 additions and 33 deletions

View File

@@ -1944,10 +1944,41 @@ class ddg{
private function bingimg($url){
$parse = parse_url($url);
parse_str($parse["query"], $parts);
$image = parse_url($url);
return "https://" . $parse["host"] . "/th?id=" . urlencode($parts["id"]);
$id = null;
if(isset($image["query"])){
parse_str($image["query"], $str);
if(isset($str["id"])){
$id = $str["id"];
}
}
if($id === null){
// fallback to getting ID from path
$id = explode("/", $image["path"]);
for($i=count($id) - 1; $i>0; $i--){
if(trim($id[$i]) != ""){
$id = $id[$i];
break;
}
}
}
if(is_array($id)){
// fuck off, let proxy.php deal with it
return $url;
}
return "https://" . $image["host"] . "/th/id/" . $id;
}
private function bingratio($width, $height){