From ff8b1addf7059a8289049e937475c289e1ba407d Mon Sep 17 00:00:00 2001 From: lolcat Date: Thu, 17 Apr 2025 19:54:34 -0400 Subject: fixed bing images failing to load, added flickr --- scraper/ddg.php | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'scraper/ddg.php') diff --git a/scraper/ddg.php b/scraper/ddg.php index 2e543e1..95039fa 100644 --- a/scraper/ddg.php +++ b/scraper/ddg.php @@ -1943,10 +1943,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){ -- cgit v1.2.3