diff options
Diffstat (limited to 'scraper/ddg.php')
| -rw-r--r-- | scraper/ddg.php | 37 |
1 files changed, 34 insertions, 3 deletions
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){ |
