Compare commits

..

3 Commits

Author SHA1 Message Date
ngn
d27bdeb710
ups: update to 8d50667
All checks were successful
docker / docker (push) Successful in 22s
2025-06-01 14:11:45 +03:00
lolcat
197f5dfbf3
handle imgur ip block 2025-06-01 14:11:18 +03:00
lolcat
3075f4d47a
fix startpage videos 2025-06-01 14:10:46 +03:00
3 changed files with 38 additions and 9 deletions

View File

@ -182,6 +182,23 @@ class imgur{
throw new Exception("Failed to fetch HTML");
}
$json = json_decode($html, true);
if($json){
// {"data":{"error":"Imgur is temporarily over capacity. Please try again later."},"success":false,"status":403}
if(isset($json["data"]["error"])){
if(stripos($json["data"]["error"], "capacity")){
throw new Exception("Imgur IP blocked this 4get instance or request proxy. Try again");
}
}
throw new Exception("Imgur returned an unknown error (IP ban?)");
}
$this->fuckhtml->load($html);
$posts =
@ -197,7 +214,14 @@ class imgur{
$image =
$this->fuckhtml
->getElementsByTagName("img")[0];
->getElementsByTagName("img");
if(count($image) === 0){
continue;
}
$image = $image[0];
$image_url = "https:" . substr($this->fuckhtml->getTextContent($image["attributes"]["src"]), 0, -5);

View File

@ -1225,11 +1225,16 @@ class startpage{
// get results
foreach($json["render"]["presenter"]["regions"]["mainline"] as $category){
if($category["display_type"] == "video-youtube"){
if(
preg_match(
'/^video-/i',
$category["display_type"]
)
){
foreach($category["results"] as $video){
if(
isset($video["thumbnailUrl"]) &&
$video["thumbnailUrl"] !== null
@ -1246,9 +1251,9 @@ class startpage{
"url" => null
];
}
$out["video"][] = [
"title" => $video["title"],
"title" => str_replace(["", ""], "", $video["title"]),
"description" => $this->limitstrlen($video["description"]),
"author" => [
"name" => $video["channelTitle"],
@ -1256,7 +1261,7 @@ class startpage{
"avatar" => null
],
"date" => strtotime($video["publishDate"]),
"duration" => $this->hms2int($video["duration"]),
"duration" => $this->hms2int($category["display_type"] == "video-youtube" ? $video["duration"] : $video["duration"] / 1000),
"views" => (int)$video["viewCount"],
"thumb" => $thumb,
"url" => $video["clickUrl"]

View File

@ -1,7 +1,7 @@
{
"upstream": "https://git.lolcat.ca/lolcat/4get",
"provider": "gitea",
"commit": "78aa2e198f11ca928891ec83ef97d2445147414a",
"commit": "8d50667b0d9c9f5d2e1603fa2cb3d7bfb89feb8b",
"scripts": [
"s/--- a\\//--- a\\/src\\//g",
"s/+++ b\\//+++ b\\/src\\//g"