diff options
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/catalog.class.php | 2 | ||||
-rw-r--r-- | lib/class/song.class.php | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 21d725db..39c2c7ea 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -2299,7 +2299,7 @@ class Catalog { $result .= xml_from_array($xml,1,'itunes'); } - return $result; + return $result; } diff --git a/lib/class/song.class.php b/lib/class/song.class.php index b7c59621..0ad9af68 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -706,6 +706,38 @@ class Song { } // format /** + * format_pattern + * This reformates the song information based on the catalog + * rename patterns + */ + public function format_pattern() { + + $catalog = new Catalog($this->catalog); + + $extension = ltrim(substr($this->file,strlen($this->file)-4,4),"."); + + /* Create the filename that this file should have */ + $album = $this->f_album_full; + $artist = $this->f_artist_full; + $genre = $this->f_genre; + $track = $this->track; + $title = $this->title; + $year = $this->year; + + /* Start replacing stuff */ + $replace_array = array('%a','%A','%t','%T','%y','%g'); + $content_array = array($artist,$album,$title,$track,$year,$genre); + + $rename_pattern = str_replace($replace_array,$content_array,$catalog->rename_pattern); + + $rename_pattern = preg_replace("[\-\:\!]","_",$rename_pattern); + + $this->f_pattern = $rename_pattern; + $this->f_file = $rename_pattern . "." . $extension; + + } // format_pattern + + /** * @function get_rel_path * @discussion returns the path of the song file stripped of the catalog path * used for mpd playback |