Code: Select all
<?
// Written by Jimmy Ruska (jimmyr.com) Aug 4 2007
// Backup your playlists before you use this. It's not recursive.
// Because the directory structure is different in linux I added commented out code.
/**********************************************************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************************************/
// $dir="/home/you/playlists/";
$dir = "C:\\Program Files\\VideoLan\\VLC\\";
$dh = opendir($dir) or die ("could not open dir");
while ( !(($file = readdir($dh)) === false)){
if (!(eregi("\.m3u$",$file))) continue;
$path="$dir\\$file";
@$handle = fopen("$path", "rb");
$contents = stream_get_contents($handle);
if (ereg("EXTINF",$contents)){
echo "Already Processed - $path\n";
continue;
}
// preg_match_all('|.*[^/]+\n|i', $contents, $return);
preg_match_all('|.*[^\\\]+\n|i', $contents, $return);
$numElements = count($return[0]);
$remade="";
for($counter=0; $counter < $numElements; $counter++)
{
if (ereg("^C\:",$return[0][$counter]))
$remade.=ereg_replace("_"," ",preg_replace("|.*\\\([^\\\]+)\.[A-z]{2,4}|i","#EXTINF:-1,\\1",$return[0][$counter]));
// $remade.=ereg_replace("_"," ",preg_replace("|.*/([^/]+)\.[A-z]{2,4}|i","#EXTINF:-1,\\1",$return[0][$counter]));
$remade.=$return[0][$counter];
}
$open = fopen($path, "wb");
fwrite($open, $remade);
fclose($open);
echo "Finished Processing - $path\n";
}
?>
Return to “VLC media player Feature Requests”
Users browsing this forum: No registered users and 4 guests