From bca265aea67ec62499aaa113a6490ce9ec7fe730 Mon Sep 17 00:00:00 2001 From: lolcat Date: Sat, 22 Jul 2023 14:41:14 -0400 Subject: still missing things on google scraper --- videos.php | 241 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 videos.php (limited to 'videos.php') diff --git a/videos.php b/videos.php new file mode 100644 index 0000000..2842703 --- /dev/null +++ b/videos.php @@ -0,0 +1,241 @@ +getscraperfilters("videos"); + +$get = $frontend->parsegetfilters($_GET, $filters); + +$frontend->loadheader( + $get, + $filters, + "videos" +); + +$payload = [ + "class" => "", + "right-left" => "", + "right-right" => "", + "left" => "" +]; + +try{ + $results = $scraper->video($get); + +}catch(Exception $error){ + + echo + $frontend->drawerror( + "Shit", + 'This scraper returned an error:' . + '
' . htmlspecialchars($error->getMessage()) . '
' . + 'Things you can try:' . + '
' . + 'If the error persists, please contact the administrator.' + ); + die(); +} + +$categories = [ + "video" => "", + "author" => "", + "livestream" => "", + "playlist" => "", + "reel" => "" +]; + +/* + Set the main container +*/ +$main = null; + +if(count($results["video"]) !== 0){ + + $main = "video"; + +}elseif(count($results["playlist"]) !== 0){ + + $main = "playlist"; + +}elseif(count($results["livestream"]) !== 0){ + + $main = "livestream"; + +}elseif(count($results["author"]) !== 0){ + + $main = "author"; + +}elseif(count($results["reel"]) !== 0){ + + $main = "reel"; +}else{ + + // No results found! + echo + $frontend->drawerror( + "Nobody here but us chickens!", + 'Have you tried:' . + '' . + '' + ); + die(); +} + +/* + Generate list of videos +*/ +foreach($categories as $name => $data){ + + foreach($results[$name] as $item){ + + $greentext = []; + + if( + isset($item["date"]) && + $item["date"] !== null + ){ + + $greentext[] = date("jS M y @ g:ia", $item["date"]); + } + + if( + isset($item["views"]) && + $item["views"] !== null + ){ + + $views = number_format($item["views"]); + + if($name != "livestream"){ + + $views .= " views"; + }else{ + + $views .= " watching"; + } + + $greentext[] = $views; + } + + if( + isset($item["followers"]) && + $item["followers"] !== null + ){ + + $greentext[] = number_format($item["followers"]) . " followers"; + } + + if( + isset($item["author"]["name"]) && + $item["author"]["name"] !== null + ){ + + $greentext[] = $item["author"]["name"]; + } + + $greentext = implode(" • ", $greentext); + + if( + isset($item["duration"]) && + $item["duration"] !== null + ){ + + $duration = $frontend->s_to_timestamp($item["duration"]); + }else{ + + $duration = null; + } + + $tabindex = $name == $main ? true : false; + + $categories[$name] .= $frontend->drawtextresult($item, $greentext, $duration, $get["s"], $tabindex); + } +} + +$payload["left"] = $categories[$main]; + +// dont re-draw the category +unset($categories[$main]); + +/* + Populate right handside +*/ + +$i = 1; +foreach($categories as $name => $value){ + + if($value == ""){ + + continue; + } + + if($i % 2 === 1){ + + $write = "right-left"; + }else{ + + $write = "right-right"; + } + + $payload[$write] .= + '
' . + '' . + '
' . + '
' . + '

Playlists

'; + break; + + case "livestream": + $payload[$write] .= + '&feature=live">

Livestreams

'; + break; + + case "author": + $payload[$write] .= + '&type=channel">

Authors

'; + break; + + case "reel": + $payload[$write] .= + '&duration=short">

Reels

'; + break; + } + + $payload[$write] .= + '
' . + $categories[$name] . + '
' . + '
'; + + $i++; +} + +if($i !== 1){ + + $payload["class"] = " has-answer"; +} + +if($results["npt"] !== null){ + + $payload["left"] .= + 'Next page >'; +} + +echo $frontend->load("search.html", $payload); -- cgit v1.2.3