Răsfoiți Sursa

i fucking hate bing

lolcat 1 an în urmă
părinte
comite
077692db49
2 a modificat fișierele cu 13 adăugiri și 23 ștergeri
  1. 6 14
      scraper/ddg.php
  2. 7 9
      scraper/qwant.php

+ 6 - 14
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;

+ 7 - 9
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)){