Youtube
unknown
php
2 years ago
1.8 kB
7
Indexable
<?php require_once('../protect_this.php'); include "../header.php"; ini_set("display_errors",1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); function exception_error_handler($errno, $errstr, $errfile, $errline){ throw new ErrorException($errstr, $errno, 0, $errfile, $errline); } set_error_handler('exception_error_handler'); echo '<div align="center">'; echo '<h1>youtube playlists</h1>'; if (isset($_GET['playlist_name'])) { $playlist_name = $_GET['playlist_name']; $json = file_get_contents("playlists/" . $playlist_name . ".json"); $arr = json_decode($json, TRUE); $smaller_arrays = array_chunk($arr, 50); # youtube does not handle manual playlists with more than 50 elements if (count($smaller_arrays) > 1) { echo 'You selected "' . $playlist_name . '" playlist, which contains more than 50 videos.<br>Which part do you want (each part contains 50 videos)?<br><br>'; } $chunk_number = 1; foreach($smaller_arrays as $smaller_array) { $youtube_url = "https://www.youtube.com/watch_videos?video_ids="; foreach ($smaller_array as $video) { $video_id = $video["contentDetails"]["videoId"]; $youtube_url = $youtube_url . $video_id . ","; } if (count($smaller_arrays) == 1) { echo "<script type='text/javascript'>window.open('".$youtube_url."', '_blank');</script>"; } else { echo '<a href="' . $youtube_url . '" target="_blank"> Part ' . $chunk_number . '</a><br>'; } $chunk_number++; } } $all_playlists = scandir("playlists/"); echo '<h2>all playlists</h2>'; echo '<p>'; foreach ($all_playlists as $playlist_filename) { if (strpos($playlist_filename, "json") != false) { $playlist_name = explode(".json", $playlist_filename)[0]; echo '<a href="?playlist_name=' . $playlist_name . '">' . $playlist_name . '</a><br>'; } } echo '</p>'; echo '</div>'; ?>
Editor is loading...