aboutsummaryrefslogtreecommitdiffstats
path: root/scraper/ddg.php
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2025-04-17 19:54:34 -0400
committerlolcat <will@lolcat.ca>2025-04-17 19:54:34 -0400
commitff8b1addf7059a8289049e937475c289e1ba407d (patch)
tree3769d42e374d659f951440c25b522ff0099914d9 /scraper/ddg.php
parent3e2c3fc5d90a0b0f859358d1c5b2614ab26905a4 (diff)
fixed bing images failing to load, added flickr
Diffstat (limited to 'scraper/ddg.php')
-rw-r--r--scraper/ddg.php37
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){
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage