From 077692db4904df65302be05da64a0cbcddf18fbb Mon Sep 17 00:00:00 2001 From: lolcat Date: Thu, 17 Apr 2025 20:05:58 -0400 Subject: i fucking hate bing --- scraper/ddg.php | 20 ++++++-------------- scraper/qwant.php | 16 +++++++--------- 2 files changed, 13 insertions(+), 23 deletions(-) (limited to 'scraper') diff --git a/scraper/ddg.php b/scraper/ddg.php index 95039fa..2729028 100644 --- a/scraper/ddg.php +++ b/scraper/ddg.php @@ -1958,23 +1958,15 @@ class ddg{ if($id === null){ - // fallback to getting ID from path - $id = explode("/", $image["path"]); - - for($i=count($id) - 1; $i>0; $i--){ + $id = explode("/th/id/", $image["path"], 2); + + if(count($id) !== 2){ - if(trim($id[$i]) != ""){ - - $id = $id[$i]; - break; - } + // malformed + return $url; } - } - - if(is_array($id)){ - // fuck off, let proxy.php deal with it - return $url; + $id = $id[1]; } return "https://" . $image["host"] . "/th/id/" . $id; diff --git a/scraper/qwant.php b/scraper/qwant.php index 93a6607..da2afca 100644 --- a/scraper/qwant.php +++ b/scraper/qwant.php @@ -971,17 +971,15 @@ class qwant{ if($id === null){ - // fallback to getting ID from path - $id = explode("/", $image["path"]); - - for($i=count($id) - 1; $i>0; $i--){ + $id = explode("/th/id/", $image["path"], 2); + + if(count($id) !== 2){ - if(trim($id[$i]) != ""){ - - $id = $id[$i]; - break; - } + // malformed + return $url; } + + $id = $id[1]; } if(is_array($id)){ -- cgit v1.2.3