Created
July 29, 2020 21:02
-
-
Save breadlesscode/72ad312d822bb3ca07242d37fdc0e13d to your computer and use it in GitHub Desktop.
Finds all YouTube and YT Music IDs and create playlist links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$matches = []; | |
$content = file_get_contents('inputfile.txt'); | |
$pattern = '#.*http[s]?:\/\/(music\.)?youtube\.com\/watch\?v=([[:alnum:]_-]{4,18}).*#'; | |
preg_match_all($pattern, $content, $matches); | |
echo count($matches[2])." Videos found\n\n"; | |
$chunks = array_chunk($matches[2], 50); | |
foreach ($chunks as $ids) { | |
echo "https://www.youtube.com/watch_videos?video_ids=".implode(',', $ids)."\n\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment