Skip to content

Instantly share code, notes, and snippets.

@xergio
Last active December 30, 2015 06:09
Show Gist options
  • Save xergio/7787129 to your computer and use it in GitHub Desktop.
Save xergio/7787129 to your computer and use it in GitHub Desktop.
<?php
// https://github.com/rg3/youtube-dl/
$playlist_id = "PL35E63D54FF7AAFC4";
//$playlist_id = "PL91D82848DC945315";
$max_results = 10;
$start_index = 1;
do {
$url = sprintf(
"https://gdata.youtube.com/feeds/api/playlists/%s?v=2&alt=json&max-results=%d&start-index=%d",
$playlist_id,
(int)$max_results,
(int)$start_index
);
$json = json_decode(file_get_contents($url), true);
foreach ($json["feed"]["entry"] as $entry) {
$cmd = sprintf(
'/home/salvarez/opt/youtube-dl -o "%%(title)s.%%(ext)s" %s --restrict-filenames -v --newline --buffer-size=10240 --extract-audio --audio-format=mp3 --add-metadata --audio-quality=0',
escapeshellarg($entry["media\$group"]["media\$player"]["url"])
);
passthru($cmd);
}
$start_index += $max_results;
} while ($start_index <= $json["feed"]["openSearch\$totalResults"]["\$t"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment