startpage fix
This commit is contained in:
1 parent
6bbb37d86e
commit
5d8c9a5798
1 file changed
+158
-16
+158
-16
@@ -545,10 +545,12 @@ class startpage{
|
|||||||
switch($category["display_type"]){
|
switch($category["display_type"]){
|
||||||
|
|
||||||
case "web-google":
|
case "web-google":
|
||||||
|
case "web-bing":
|
||||||
foreach($category["results"] as $result){
|
foreach($category["results"] as $result){
|
||||||
|
|
||||||
$sublinks = [];
|
$sublinks = [];
|
||||||
|
|
||||||
|
if(isset($result["siteLinks"])){
|
||||||
foreach($result["siteLinks"] as $sublink){
|
foreach($result["siteLinks"] as $sublink){
|
||||||
|
|
||||||
$sublinks[] = [
|
$sublinks[] = [
|
||||||
@@ -557,6 +559,7 @@ class startpage{
|
|||||||
"url" => $sublink["clickUrl"]
|
"url" => $sublink["clickUrl"]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$description =
|
$description =
|
||||||
explode(
|
explode(
|
||||||
@@ -596,6 +599,7 @@ class startpage{
|
|||||||
|
|
||||||
$out["web"][] = [
|
$out["web"][] = [
|
||||||
"title" =>
|
"title" =>
|
||||||
|
$this->remove_penguins(
|
||||||
$this->titledots(
|
$this->titledots(
|
||||||
html_entity_decode(
|
html_entity_decode(
|
||||||
$this->fuckhtml
|
$this->fuckhtml
|
||||||
@@ -603,8 +607,9 @@ class startpage{
|
|||||||
$result["title"]
|
$result["title"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
"description" => $description,
|
"description" => $this->remove_penguins($description),
|
||||||
"url" => $result["clickUrl"],
|
"url" => $result["clickUrl"],
|
||||||
"date" => $date,
|
"date" => $date,
|
||||||
"type" => "web",
|
"type" => "web",
|
||||||
@@ -619,8 +624,43 @@ class startpage{
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "images-qi-top":
|
case "images-qi-top":
|
||||||
|
case "images-bing-top":
|
||||||
foreach($category["results"] as $result){
|
foreach($category["results"] as $result){
|
||||||
|
|
||||||
|
if(isset($result["mdThumbnailWidth"])){
|
||||||
|
|
||||||
|
$thumb_width = $result["mdThumbnailWidth"];
|
||||||
|
}elseif(isset($result["thumbnailWidth"])){
|
||||||
|
|
||||||
|
$thumb_width = $result["thumbnailWidth"];
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$thumb_width = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($result["mdThumbnailHeight"])){
|
||||||
|
|
||||||
|
$thumb_height = $result["mdThumbnailHeight"];
|
||||||
|
}elseif(isset($result["thumbnailHeight"])){
|
||||||
|
|
||||||
|
$thumb_height = $result["thumbnailHeight"];
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$thumb_height = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($result["mdThumbnailUrl"])){
|
||||||
|
|
||||||
|
$thumb_source = $result["mdThumbnailUrl"];
|
||||||
|
}elseif(isset($result["thumbnailUrl"])){
|
||||||
|
|
||||||
|
$thumb_source = $result["thumbnailUrl"];
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// should not happen
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$out["image"][] = [
|
$out["image"][] = [
|
||||||
"title" =>
|
"title" =>
|
||||||
$this->titledots(
|
$this->titledots(
|
||||||
@@ -638,19 +678,17 @@ class startpage{
|
|||||||
"height" => (int)$result["height"]
|
"height" => (int)$result["height"]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"url" => $this->unshitimage($result["mdThumbnailUrl"]),
|
"url" => $this->unshitimage($thumb_source),
|
||||||
"width" => (int)$result["mdThumbnailWidth"],
|
"width" => (int)$thumb_width,
|
||||||
"height" => (int)$result["mdThumbnailHeight"]
|
"height" => (int)$thumb_height
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"url" =>
|
"url" => $result["altClickUrl"]
|
||||||
$result["altClickUrl"]
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "spellsuggest-google":
|
case "spellsuggest-google":
|
||||||
|
|
||||||
if(isset($category["results"][0]["query"])){
|
if(isset($category["results"][0]["query"])){
|
||||||
|
|
||||||
$out["spelling"] =
|
$out["spelling"] =
|
||||||
@@ -662,6 +700,60 @@ class startpage{
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "spelladjust-bing":
|
||||||
|
if(isset($category["results"][0]["alterationDisplayQuery"])){
|
||||||
|
|
||||||
|
$out["spelling"] =
|
||||||
|
[
|
||||||
|
"type" => "including",
|
||||||
|
"using" => $this->remove_penguins($category["results"][0]["alterationDisplayQuery"]),
|
||||||
|
"correction" => $category["results"][0]["originalQuery"]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "aylf-bing-top":
|
||||||
|
if(isset($category["results"][0]["query"])){
|
||||||
|
|
||||||
|
foreach($category["results"] as $ddm){
|
||||||
|
|
||||||
|
$out["related"][] = $ddm["query"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "video-bing-top":
|
||||||
|
if(isset($category["results"][0]["clickUrl"])){
|
||||||
|
|
||||||
|
foreach($category["results"] as $video){
|
||||||
|
|
||||||
|
if(isset($video["thumbnailUrl"])){
|
||||||
|
|
||||||
|
$thumb = [
|
||||||
|
"ratio" => "16:9",
|
||||||
|
"url" => $this->unshitimage($video["thumbnailUrl"])
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$thumb = [
|
||||||
|
"ratio" => null,
|
||||||
|
"url" => null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$out["video"][] = [
|
||||||
|
"title" => $video["title"],
|
||||||
|
"description" => $this->remove_penguins($video["description"]),
|
||||||
|
"date" => isset($video["date"]) ? strtotime($video["date"]) : null,
|
||||||
|
"duration" => (int)$video["duration"] !== 0 ? (int)$video["duration"] / 1000 : null,
|
||||||
|
"views" => $video["viewCount"],
|
||||||
|
"thumb" => $thumb,
|
||||||
|
"url" => $video["clickUrl"]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case "dictionary-qi":
|
case "dictionary-qi":
|
||||||
foreach($category["results"] as $result){
|
foreach($category["results"] as $result){
|
||||||
|
|
||||||
@@ -732,6 +824,36 @@ class startpage{
|
|||||||
$out["answer"][] = $answer;
|
$out["answer"][] = $answer;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "news-bing-top":
|
||||||
|
if(isset($category["results"][0]["clickUrl"])){
|
||||||
|
|
||||||
|
foreach($category["results"] as $news){
|
||||||
|
|
||||||
|
if(isset($news["thumbnailUrl"])){
|
||||||
|
|
||||||
|
$thumb = [
|
||||||
|
"ratio" => "16:9",
|
||||||
|
"url" => $news["thumbnailUrl"]
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$thumb = [
|
||||||
|
"ratio" => null,
|
||||||
|
"url" => null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$out["news"][] = [
|
||||||
|
"title" => $this->remove_penguins($news["title"]),
|
||||||
|
"description" => $news["description"],
|
||||||
|
"date" => isset($news["date"]) ? strtotime($news["date"]) : null,
|
||||||
|
"thumb" => $thumb,
|
||||||
|
"url" => $news["clickUrl"],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1246,14 +1368,10 @@ class startpage{
|
|||||||
// get npt
|
// get npt
|
||||||
$out["npt"] = $this->parse_npt($json, "news", $proxy, $cookies);
|
$out["npt"] = $this->parse_npt($json, "news", $proxy, $cookies);
|
||||||
|
|
||||||
|
//print_r($json);
|
||||||
|
|
||||||
foreach($json["render"]["presenter"]["regions"]["mainline"] as $category){
|
foreach($json["render"]["presenter"]["regions"]["mainline"] as $category){
|
||||||
|
|
||||||
if($category["display_type"] != "news-bing"){
|
|
||||||
|
|
||||||
// unsupported category
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($category["results"] as $news){
|
foreach($category["results"] as $news){
|
||||||
|
|
||||||
if(
|
if(
|
||||||
@@ -1276,10 +1394,10 @@ class startpage{
|
|||||||
$out["news"][] = [
|
$out["news"][] = [
|
||||||
"title" => $this->titledots($this->remove_penguins($news["title"])),
|
"title" => $this->titledots($this->remove_penguins($news["title"])),
|
||||||
"author" => $news["source"],
|
"author" => $news["source"],
|
||||||
"description" => $this->titledots($this->remove_penguins($news["description"])),
|
"description" => isset($news["description"]) ? $this->titledots($this->remove_penguins($news["description"])) : null,
|
||||||
"date" => (int)substr((string)$news["date"], 0, -3),
|
"date" => isset($news["date"]) ? strtotime($news["date"]) : null,
|
||||||
"thumb" => $thumb,
|
"thumb" => $thumb,
|
||||||
"url" => $news["clickUrl"]
|
"url" => $this->remove_tracking_link($news["clickUrl"])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1327,6 +1445,30 @@ class startpage{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function remove_tracking_link($url){
|
||||||
|
|
||||||
|
// https://api.airfind.com/stats/adrequest/v1?clientid=51776&type=click&adCampaign=organicNewsArticle-prg-top&provider=prg&redirectURL=https%3A%2F%2Fvancouverisland.ctvnews.ca%2Fvideo%2F2026%2F11%2F02%2Ftrump-claims-concept-of-a-deal-with-canada%2F&brand=startpage.udog
|
||||||
|
$query = parse_url($url);
|
||||||
|
|
||||||
|
if(
|
||||||
|
!isset($query["host"]) ||
|
||||||
|
$query["host"] != "api.airfind.com" ||
|
||||||
|
!isset($query["query"])
|
||||||
|
){
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_str($query["query"], $res);
|
||||||
|
|
||||||
|
if(isset($res["redirectURL"])){
|
||||||
|
|
||||||
|
return $res["redirectURL"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
private function unshitimage($url){
|
private function unshitimage($url){
|
||||||
|
|
||||||
$query = parse_url($url, PHP_URL_QUERY);
|
$query = parse_url($url, PHP_URL_QUERY);
|
||||||
|
|||||||
Reference in new issue
Block a user