instance_url = $this->opts->invidious_instance_for_video_results; $query = urlencode($this->query); return "$this->instance_url/api/v1/search?q=$query"; } public function parse_results($response) { $results = array(); $json_response = json_decode($response, true); foreach ($json_response ?: [] as $response) { if ($response["type"] == "video") { $title = $response["title"]; $url = "https://youtube.com/watch?v=" . $response["videoId"]; $uploader = $response["author"]; $views = $response["viewCountText"]; $date = $response["publishedText"]; $lengthSeconds = $response["lengthSeconds"]; $thumbnail = $this->instance_url . "/vi/" . explode("/vi/" ,$response["videoThumbnails"][4]["url"])[1]; array_push($results, array ( "title" => htmlspecialchars($title), "url" => htmlspecialchars($url), // base_url is to be removed in the future, see #47 "base_url" => htmlspecialchars(get_base_url($url)), "uploader" => htmlspecialchars($uploader), "views" => htmlspecialchars($views), "date" => htmlspecialchars($date), "lengthSeconds" => htmlspecialchars($lengthSeconds), "thumbnail" => htmlspecialchars($thumbnail) ) ); } } return $results; } public static function print_results($results, $opts) { echo "