From cdf958d29333d448f4521f4d2faa2592b58e9b27 Mon Sep 17 00:00:00 2001 From: lolcat Date: Sun, 10 Aug 2025 21:55:15 -0400 Subject: fix wikipedia crash --- music.php | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 music.php (limited to 'music.php') diff --git a/music.php b/music.php new file mode 100644 index 0000000..c49fc08 --- /dev/null +++ b/music.php @@ -0,0 +1,222 @@ +getscraperfilters("music"); + +$get = $frontend->parsegetfilters($_GET, $filters); + +/* + Captcha +*/ +include "lib/bot_protection.php"; +new bot_protection($frontend, $get, $filters, "music", true); + +$payload = [ + "timetaken" => microtime(true), + "class" => "", + "right-left" => "", + "right-right" => "", + "left" => "" +]; + +try{ + $results = $scraper->music($get); + +}catch(Exception $error){ + + $frontend->drawscrapererror($error->getMessage(), $get, "music", $payload["timetaken"]); +} + +$categories = [ + "song" => "", + "author" => "", + "playlist" => "", + "album" => "", + "podcast" => "", + "user" => "" +]; + +/* + Set the main container +*/ +$main = null; + +if(count($results["song"]) !== 0){ + + $main = "song"; + +}elseif(count($results["album"]) !== 0){ + + $main = "album"; + +}elseif(count($results["playlist"]) !== 0){ + + $main = "playlist"; + +}elseif(count($results["podcast"]) !== 0){ + + $main = "podcast"; + +}elseif(count($results["author"]) !== 0){ + + $main = "author"; + +}elseif(count($results["user"]) !== 0){ + + $main = "user"; + +}else{ + + // No results found! + echo + $frontend->drawerror( + "Nobody here but us chickens!", + 'Have you tried:' . + '' . + '' + ); + die(); +} + +/* + Generate list of songs +*/ +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"]) . " views"; + $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; + + $customhtml = null; + + if( + ( + $name == "song" || + $name == "podcast" + ) && + $item["stream"]["endpoint"] !== null + ){ + + $customhtml = + '