Skip to content

Instantly share code, notes, and snippets.

@ibnux
Created May 4, 2020 18:14
Show Gist options
  • Save ibnux/9a2d451d2390a66cb8533f9b498df939 to your computer and use it in GitHub Desktop.
Save ibnux/9a2d451d2390a66cb8533f9b498df939 to your computer and use it in GitHub Desktop.
convert KeyGen Music Pack on mac using VLC command line
<?php
// php -f convertKeyGenMusic.php
$path = "KEYGENMUSiC/";
$command = '/Applications/VLC.app/Contents/MacOS/VLC -I dummy -vvv --sout \
"#transcode{acodec=MP3,ab=128}:std{access=file,mux=wav,dst="/Users/ibnux/Desktop/KeyGenMusic_MusicPack_2020-03-full/MUSICKEYGEN/[DEST]"}" \
"/Users/ibnux/Desktop/KeyGenMusic_MusicPack_2020-03-full/[SOURCE]" vlc://quit';
scanDirectory($path);
function scanDirectory($path){
global $command;
$folder = scandir($path);
foreach($folder as $file){
if(!in_array($file,['.','..','DS_Store'])){
if(is_dir($path.$file)){
scanDirectory($path.$file."/");
}else{
echo exec(str_replace('[SOURCE]',$path.$file,str_replace('[DEST]',str_replace('_-_','-',str_replace(' ','_',stripText($file.".mp3"))),$command)));
//echo str_replace('[SOURCE]',$path.$file,str_replace('[DEST]',str_replace('_-_','-',str_replace(' ','_',stripText($file.".mp3"))),$command))."\n";
}
}
}
}
function stripText($text) {
return preg_replace("[^A-Za-z0-9 ]", "", $text );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment