Compare commits
3 Commits
c1508af858
...
d27bdeb710
Author | SHA1 | Date | |
---|---|---|---|
d27bdeb710 | |||
![]() |
197f5dfbf3 | ||
![]() |
3075f4d47a |
@ -182,6 +182,23 @@ class imgur{
|
|||||||
throw new Exception("Failed to fetch HTML");
|
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);
|
$this->fuckhtml->load($html);
|
||||||
|
|
||||||
$posts =
|
$posts =
|
||||||
@ -197,7 +214,14 @@ class imgur{
|
|||||||
|
|
||||||
$image =
|
$image =
|
||||||
$this->fuckhtml
|
$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);
|
$image_url = "https:" . substr($this->fuckhtml->getTextContent($image["attributes"]["src"]), 0, -5);
|
||||||
|
|
||||||
|
@ -1225,11 +1225,16 @@ class startpage{
|
|||||||
|
|
||||||
// get results
|
// get results
|
||||||
foreach($json["render"]["presenter"]["regions"]["mainline"] as $category){
|
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){
|
foreach($category["results"] as $video){
|
||||||
|
|
||||||
if(
|
if(
|
||||||
isset($video["thumbnailUrl"]) &&
|
isset($video["thumbnailUrl"]) &&
|
||||||
$video["thumbnailUrl"] !== null
|
$video["thumbnailUrl"] !== null
|
||||||
@ -1246,9 +1251,9 @@ class startpage{
|
|||||||
"url" => null
|
"url" => null
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$out["video"][] = [
|
$out["video"][] = [
|
||||||
"title" => $video["title"],
|
"title" => str_replace(["", ""], "", $video["title"]),
|
||||||
"description" => $this->limitstrlen($video["description"]),
|
"description" => $this->limitstrlen($video["description"]),
|
||||||
"author" => [
|
"author" => [
|
||||||
"name" => $video["channelTitle"],
|
"name" => $video["channelTitle"],
|
||||||
@ -1256,7 +1261,7 @@ class startpage{
|
|||||||
"avatar" => null
|
"avatar" => null
|
||||||
],
|
],
|
||||||
"date" => strtotime($video["publishDate"]),
|
"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"],
|
"views" => (int)$video["viewCount"],
|
||||||
"thumb" => $thumb,
|
"thumb" => $thumb,
|
||||||
"url" => $video["clickUrl"]
|
"url" => $video["clickUrl"]
|
||||||
|
2
ups.json
2
ups.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"upstream": "https://git.lolcat.ca/lolcat/4get",
|
"upstream": "https://git.lolcat.ca/lolcat/4get",
|
||||||
"provider": "gitea",
|
"provider": "gitea",
|
||||||
"commit": "78aa2e198f11ca928891ec83ef97d2445147414a",
|
"commit": "8d50667b0d9c9f5d2e1603fa2cb3d7bfb89feb8b",
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"s/--- a\\//--- a\\/src\\//g",
|
"s/--- a\\//--- a\\/src\\//g",
|
||||||
"s/+++ b\\//+++ b\\/src\\//g"
|
"s/+++ b\\//+++ b\\/src\\//g"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user