diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-12-15 07:28:51 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-12-15 07:28:51 +0000 |
commit | 5d98a104bc750053e90da5f8dd9664e0433f900d (patch) | |
tree | cae71f304523d7d9572fe809d04210248cac49c0 /lib/class/song.class.php | |
parent | 454003fa93f4d511694fc7234d2f769194b13ede (diff) | |
download | ampache-5d98a104bc750053e90da5f8dd9664e0433f900d.tar.gz ampache-5d98a104bc750053e90da5f8dd9664e0433f900d.tar.bz2 ampache-5d98a104bc750053e90da5f8dd9664e0433f900d.zip |
made downloads counted in stats fixes ticket #12 tweaked filename to be reformated to match the catalog rename pattern
Diffstat (limited to 'lib/class/song.class.php')
-rw-r--r-- | lib/class/song.class.php | 32 |
1 files changed, 32 insertions, 0 deletions
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 |