summaryrefslogtreecommitdiffstats
path: root/lib/class/catalog.class.php
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2012-09-21 10:48:37 -0400
committerPaul Arthur <paul.arthur@flowerysong.com>2012-09-21 10:52:47 -0400
commita24b711143080d3819034e831aaed6c44cb5b9b0 (patch)
treefdf0f16400ebeb7d2abdf1c51f2a9cb182415334 /lib/class/catalog.class.php
parentc9dab7bf4e63ae29d40e6252c3e4fbf810f34315 (diff)
downloadampache-a24b711143080d3819034e831aaed6c44cb5b9b0.tar.gz
ampache-a24b711143080d3819034e831aaed6c44cb5b9b0.tar.bz2
ampache-a24b711143080d3819034e831aaed6c44cb5b9b0.zip
Some cleanup of the playlist import code
Global variables are ugly and unnecessary.
Diffstat (limited to 'lib/class/catalog.class.php')
-rw-r--r--lib/class/catalog.class.php32
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 9367c925..1d33da76 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -1245,7 +1245,8 @@ class Catalog extends database_object {
// Foreach Playlists we found
foreach ($this->_playlists as $full_file) {
- if ($this->import_m3u($full_file)) {
+ $result = $this->import_m3u($full_file);
+ if ($result['success']) {
$file = basename($full_file);
if ($verbose) {
echo "&nbsp;&nbsp;&nbsp;" . T_('Added Playlist From') . " $file . . . .<br />\n";
@@ -2263,7 +2264,6 @@ class Catalog extends database_object {
* listed in the m3u
*/
public function import_m3u($filename) {
- global $reason, $playlist_id;
$m3u_handle = fopen($filename,'r');
@@ -2307,30 +2307,34 @@ class Catalog extends database_object {
} // end foreach line
- debug_event('m3u_parse',"Parsing $filename - Found: " . count($songs) . " Songs",'5');
+ debug_event('m3u_parse', "Parsed $filename, found " . count($songs) . " songs", 5);
if (count($songs)) {
$name = "M3U - " . basename($filename,'.m3u');
$playlist_id = Playlist::create($name,'public');
if (!$playlist_id) {
- $reason = T_('Playlist creation error.');
- return false;
+ return array(
+ 'success' => false,
+ 'error' => 'Failed to create playlist.',
+ );
}
/* Recreate the Playlist */
$playlist = new Playlist($playlist_id);
$playlist->add_songs($songs, true);
- $reason = sprintf(T_ngettext('Playlist Import and Recreate Successful. Total: %d Song',
- 'Playlist Import and Recreate Successful. Total: %d Songs',
- count($songs)), count($songs));
- return true;
+
+ return array(
+ 'success' => true,
+ 'id' => $playlist_id,
+ 'count' => count($songs)
+ );
}
- /* HINT: filename */
- $reason = sprintf(T_ngettext('Parsing %s - Not Found: %d Song. Please check your m3u file.',
- 'Parsing %s - Not Found: %d Songs. Please check your m3u file.',
- count($songs)), $filename, count($songs));
- return false;
+
+ return array(
+ 'success' => false,
+ 'error' => 'No valid songs found in M3U.'
+ );
} // import_m3u