|
From: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - 2007-09-07 17:11:17
|
Update of /cvsroot/xrns-php/xrns-php/scripts In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv8431 Modified Files: xrns_ogg.php Log Message: skip files smaller than 4096 bytes, fixed: extension of filenames with dots was not beign detected fixes: switch() was broken Index: xrns_ogg.php =================================================================== RCS file: /cvsroot/xrns-php/xrns-php/scripts/xrns_ogg.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** xrns_ogg.php 25 Aug 2007 15:20:24 -0000 1.3 --- xrns_ogg.php 7 Sep 2007 17:11:15 -0000 1.4 *************** *** 3,8 **** /* ! Requires: PHP5, Info-Zip (http://www.info-zip.org/), ! oggenc (http://www.rarewares.org/ogg-oggenc.php), and optionally flac (http://flac.sourceforge.net/) --- 3,8 ---- /* ! Requires: PHP5, Info-Zip (http://www.info-zip.org/), ! oggenc (http://www.rarewares.org/ogg-oggenc.php), and optionally flac (http://flac.sourceforge.net/) *************** *** 40,72 **** $path_to_oggenc = 'oggenc'; // oggenc assumed to be in path ! $path_to_flac = 'flac'; // flac assumed to be in path $array = scandir($source); ! ! foreach ($array as $file) { $fullpath = $source . '/' . $file; ! ! switch (preg_match('/(\.(.*)$)/i', $file, $matches)) { ! ! case (strtolower($matches[2]) == 'flac') : ! $command = $path_to_flac . ' -d --delete-input-file "'.$fullpath.'"'; $res = -1; // any nonzero value $UnusedArrayResult = array(); $UnusedStringResult = exec($command, $UnusedArrayResult, $res); ! if ($res != 0) echo "Warning: flac return_val was $res, there was a problem decompressing flac $file\n"; ! else $fullpath = str_replace(".flac", ".wav", $fullpath); ! ! case (strtolower($matches[2]) == 'wav' || (strtolower($matches[2]) == 'aif') || (strtolower($matches[2]) == 'aiff')): ! ! $command = $path_to_oggenc . " --quality $quality \"$fullpath\" "; ! $res = -1; // any nonzero value ! $UnusedArrayResult = array(); ! $UnusedStringResult = exec($command, $UnusedArrayResult, $res); ! if ($res != 0) echo "Warning: oggenc return_val was $res, there was a problem compressing $file\n"; ! else unlink($fullpath); ! ! } ! } } --- 40,76 ---- $path_to_oggenc = 'oggenc'; // oggenc assumed to be in path ! $path_to_flac = 'flac'; // flac assumed to be in path $array = scandir($source); ! ! foreach ($array as $file) { $fullpath = $source . '/' . $file; ! ! if (filesize($fullpath) <= 4096) continue; // Skip files smaller than 4096 bytes ! ! switch (strtolower(end(explode('.', $file)))) { ! ! case ('flac') : ! $command = $path_to_flac . ' -d --delete-input-file "'.$fullpath.'"'; $res = -1; // any nonzero value $UnusedArrayResult = array(); $UnusedStringResult = exec($command, $UnusedArrayResult, $res); ! if ($res != 0) echo "Warning: flac return_val was $res, there was a problem decompressing flac $file\n"; ! else $fullpath = str_replace(".flac", ".wav", $fullpath); ! ! case ('wav'): ! case ('aif'): ! case ('aiff'): ! ! $command = $path_to_oggenc . " --quality $quality \"$fullpath\" "; ! $res = -1; // any nonzero value ! $UnusedArrayResult = array(); ! $UnusedStringResult = exec($command, $UnusedArrayResult, $res); ! if ($res != 0) echo "Warning: oggenc return_val was $res, there was a problem compressing $file\n"; ! else unlink($fullpath); ! ! } ! } } *************** *** 104,108 **** // Quality ! if(ctype_digit($argv[3]) && $argv[3] > 0 && $argv[3] <= 10) $quality = $argv[3]; else $quality = 3; // default --- 108,112 ---- // Quality ! if(isset($argv[3]) && ctype_digit($argv[3]) && $argv[3] > 0 && $argv[3] <= 10) $quality = $argv[3]; else $quality = 3; // default *************** *** 121,125 **** if ((preg_match('/(\.xrni$)/i', $song1))) { $unzip1 = $tmp_dir . '/xrns_ogg_' . md5(uniqid(mt_rand(), true)) . '_Ins01/'; ! } else { $unzip1 = $tmp_dir . '/xrns_ogg_' . md5(uniqid(mt_rand(), true)) . '_Track01/'; --- 125,129 ---- if ((preg_match('/(\.xrni$)/i', $song1))) { $unzip1 = $tmp_dir . '/xrns_ogg_' . md5(uniqid(mt_rand(), true)) . '_Ins01/'; ! } else { $unzip1 = $tmp_dir . '/xrns_ogg_' . md5(uniqid(mt_rand(), true)) . '_Track01/'; *************** *** 139,156 **** // SampleData directory ! if (is_dir($unzip1 . 'SampleData/')) { // Xrni or Xrns? if (preg_match('/(\.xrni$)/i',$song1)) { ! $source = $unzip1 . 'SampleData/'; ogg_files($source, $quality); ! ! } ! else foreach(new DirectoryIterator($unzip1 . 'SampleData/') as $file) { ! ! if ($file == '.' || $file == '..') continue; // Skip these files ! ! $source = $unzip1 . 'SampleData/' . $file; ! if (is_dir($source)) ogg_files($source, $quality); } --- 143,160 ---- // SampleData directory ! if (is_dir($unzip1 . 'SampleData/')) { // Xrni or Xrns? if (preg_match('/(\.xrni$)/i',$song1)) { ! $source = $unzip1 . 'SampleData/'; ogg_files($source, $quality); ! ! } ! else foreach(new DirectoryIterator($unzip1 . 'SampleData/') as $file) { ! ! if ($file == '.' || $file == '..') continue; // Skip these files ! ! $source = $unzip1 . 'SampleData/' . $file; ! if (is_dir($source)) ogg_files($source, $quality); } |