1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-05 02:39:47 +02:00

fixed up a few more problems

This commit is contained in:
Karl 'vollmerk' Vollmer 2005-12-31 05:23:07 +00:00
parent 50cfcbc99c
commit 9e5afd340f

View file

@ -51,6 +51,8 @@ while ($r = mysql_fetch_row($db_results)) {
$catalog = new Catalog($r['0']);
$songs = $catalog->get_catalog_files();
echo "Starting Catalog: $catalog->name\n";
/* Foreach through each file and find it a home! */
foreach ($songs as $song) {
/* Find this poor song a home */
@ -58,8 +60,14 @@ while ($r = mysql_fetch_row($db_results)) {
$directory = sort_find_home($song,$catalog->sort_pattern,$catalog->path);
$filename = sort_find_filename($song,$catalog->rename_pattern);
echo $directory . "/" . $filename . "\n";
$fullpath = $directory . "/" . $filename;
/* Check for Demo Mode */
if ($test_mode) {
/* We're just talking here... no work */
echo "Moving File:\n\tSource: $song->file\n\tDest: $fullpath\n";
flush();
}
} // end foreach song
} // end foreach catalogs
@ -73,6 +81,8 @@ while ($r = mysql_fetch_row($db_results)) {
*/
function sort_find_filename($song,$rename_pattern) {
$extension = ltrim(substr($song->file,strlen($song->file)-4,4),".");
/* Create the filename that this file should have */
$album = $song->f_album_full;
$artist = $song->f_artist_full;
@ -87,9 +97,9 @@ function sort_find_filename($song,$rename_pattern) {
$rename_pattern = str_replace($replace_array,$content_array,$rename_pattern);
$rename_pattern = preg_replace("/[^A-Za-z0-9\-\_\ \'\,]/","_",$rename_pattern);
$rename_pattern = preg_replace("[^A-Za-z0-9\-\_\ \'\,\(\)]","_",$rename_pattern);
return $rename_pattern;
return $rename_pattern . "." . $extension;
} // sort_find_filename
@ -111,7 +121,6 @@ function sort_find_home($song,$sort_pattern,$base) {
$title = $song->title;
$year = $song->year;
/* Do the various check */
$album_object = new Album($song->album);
if ($album_object->artist_count != '1') {
@ -135,7 +144,7 @@ function sort_find_home($song,$sort_pattern,$base) {
$sort_pattern = str_replace($replace_array,$content_array,$sort_pattern);
/* Remove non A-Z0-9 chars */
$sort_pattern = preg_replace("/[^A-Za-z0-9\-\_\ \'\,]/","_",$sort_pattern);
$sort_pattern = preg_replace("[^\\\/A-Za-z0-9\-\_\ \'\,\(\)]","_",$sort_pattern);
$home .= "/$sort_pattern";