diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-12-31 03:20:29 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-12-31 03:20:29 +0000 |
commit | 748e50ade1b0c7034eddaadbe2285e5bf3a20fc6 (patch) | |
tree | 759b02a66ea840abc91419c9d7d00a08b2fceb8c /lib/class | |
parent | 4e716204e84fc7546372bdae79121e47b92412bc (diff) | |
download | ampache-748e50ade1b0c7034eddaadbe2285e5bf3a20fc6.tar.gz ampache-748e50ade1b0c7034eddaadbe2285e5bf3a20fc6.tar.bz2 ampache-748e50ade1b0c7034eddaadbe2285e5bf3a20fc6.zip |
added ability to do add new on other elements of song edit (Thx picasso) added export catalog to csv
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/catalog.class.php | 88 | ||||
-rw-r--r-- | lib/class/song.class.php | 13 |
2 files changed, 54 insertions, 47 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 0320c1d6..fffcb302 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -2362,11 +2362,11 @@ class Catalog { } // remove_songs - /*! - @function exports the catalog - @discussion it exports all songs in the database to the given export type. - */ - function export($type){ + /** + * exports the catalog + * it exports all songs in the database to the given export type. + */ + public function export($type) { // Select all songs in catalog if($this->id) { @@ -2375,43 +2375,49 @@ class Catalog { $sql = "SELECT id FROM song ORDER BY album,track"; } $db_results = Dba::query($sql); - - if ($type=="itunes"){ - - echo xml_get_header('itunes'); - - while ($results = Dba::fetch_assoc($db_results)) { - $song = new Song($results['id']); - $song->format(); - - $xml = array(); - $xml['key']= $results['id']; - $xml['dict']['Track ID']= intval($results['id']); - $xml['dict']['Name'] = $song->title; - $xml['dict']['Artist'] = $song->f_artist_full; - $xml['dict']['Album'] = $song->f_album_full; - $xml['dict']['Genre'] = $song->f_genre; - $xml['dict']['Total Time'] = intval($song->time) * 1000; // iTunes uses milliseconds - $xml['dict']['Track Number'] = intval($song->track); - $xml['dict']['Year'] = intval($song->year); - $xml['dict']['Date Added'] = date("Y-m-d\TH:i:s\Z",$song->addition_time); - $xml['dict']['Bit Rate'] = intval($song->bitrate/1000); - $xml['dict']['Sample Rate'] = intval($song->rate); - $xml['dict']['Play Count'] = intval($song->played); - $xml['dict']['Track Type'] = "URL"; - $xml['dict']['Location'] = $song->get_url(); - - echo xml_from_array($xml,1,'itunes'); - - // flush output buffer - ob_flush(); - flush(); - } // while result - - echo xml_get_footer('itunes'); - - } // itunes + switch ($type) { + case 'itunes': + echo xml_get_header('itunes'); + + while ($results = Dba::fetch_assoc($db_results)) { + $song = new Song($results['id']); + $song->format(); + + $xml = array(); + $xml['key']= $results['id']; + $xml['dict']['Track ID']= intval($results['id']); + $xml['dict']['Name'] = $song->title; + $xml['dict']['Artist'] = $song->f_artist_full; + $xml['dict']['Album'] = $song->f_album_full; + $xml['dict']['Genre'] = $song->f_genre; + $xml['dict']['Total Time'] = intval($song->time) * 1000; // iTunes uses milliseconds + $xml['dict']['Track Number'] = intval($song->track); + $xml['dict']['Year'] = intval($song->year); + $xml['dict']['Date Added'] = date("Y-m-d\TH:i:s\Z",$song->addition_time); + $xml['dict']['Bit Rate'] = intval($song->bitrate/1000); + $xml['dict']['Sample Rate'] = intval($song->rate); + $xml['dict']['Play Count'] = intval($song->played); + $xml['dict']['Track Type'] = "URL"; + $xml['dict']['Location'] = $song->get_url(); + echo xml_from_array($xml,1,'itunes'); + // flush output buffer + } // while result + echo xml_get_footer('itunes'); + + break; + case 'csv': + echo "ID,Title,Artist,Album,Genre,Length,Track,Year,Date Added,Bitrate,Played,File\n"; + while ($results = Dba::fetch_assoc($db_results)) { + $song = new Song($results['id']); + $song->format(); + echo '"' . $song->id . '","' . $song->title . '","' . $song->artist_full . '","' . $song->album_full . + '","' . $song->f_genre . '","' . $song->f_time . '","' . $song->f_track . '","' . $song->year . + '","' . date("Y-m-d\TH:i:s\Z",$song->addition_time) . '","' . $song->f_bitrate . + '","' . $song->played . '","' . $song->file . "\n"; + } + break; + } // end switch } // export diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 19c5c0cf..62054464 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -395,9 +395,6 @@ class Song { foreach ($data as $key=>$value) { switch ($key) { case 'title': - #case 'album': - case 'artist': - case 'genre': case 'track': // Check to see if it needs to be updated if ($value != $this->$key) { @@ -407,14 +404,18 @@ class Song { $updated = 1; } break; + case 'artist': case 'album': + case 'genre': if ($value != $this->$key) { if ($value == -1) { - // Add new album based on album_name - $value = Catalog::check_album($data['album_name']); + // Add new data + $fn = "check_$key"; + $value = Catalog::$fn($data["{$key}_name"]); } if ($value) { - self::update_album($value, $this->id); + $fn = "update_$key"; + self::$fn($value, $this->id); $this->$key = $value; $updated = 1; } |