-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for mic break in CSV import
- Loading branch information
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Zookeeper Online | ||
* | ||
* @author Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2025 Jim Mason <[email protected]> | ||
* @link https://zookeeper.ibinx.com/ | ||
* @license GPL-3.0 | ||
* | ||
|
@@ -58,6 +58,7 @@ class Playlists extends MenuItem { | |
|
||
private $action; | ||
private $subaction; | ||
private $break; | ||
|
||
public function getSubactions($action) { | ||
return self::$subactions; | ||
|
@@ -399,11 +400,28 @@ public function emitEditor() { | |
} | ||
|
||
private function insertTrack($playlistId, $tag, $artist, $track, $album, $label, $spinTime) { | ||
// $artist, $track, $album, and $label have already been trimmed | ||
if(empty($artist) && empty($track) && | ||
empty($album) && empty($label)) { | ||
// non-consecutive blank row inserts set separator | ||
if(!$this->break) { | ||
$entry = (new PlaylistEntry())->setSetSeparator(); | ||
if($spinTime) | ||
$entry->setCreated($spinTime->format(IPlaylist::TIME_FORMAT_SQL)); | ||
Engine::api(IPlaylist::class)->insertTrackEntry($playlistId, $entry, $status); | ||
$this->break = true; | ||
} | ||
return; | ||
} | ||
|
||
$id = 0; | ||
$status = ''; | ||
// Run the query | ||
$success = Engine::api(IPlaylist::class)->insertTrack($playlistId, | ||
$tag, $artist, $track, $album, $label, $spinTime, $id, $status); | ||
|
||
if($success) | ||
$this->break = false; | ||
} | ||
|
||
public function emitImportList() { | ||
|
@@ -643,6 +661,13 @@ public function emitImportList() { | |
$timestamp); // timestamp | ||
$count++; | ||
break; | ||
case 1: | ||
// fgetcsv returns array with single null on blank line | ||
if(is_null($line[0])) { | ||
// set separator | ||
$this->insertTrack($playlist, 0, '', '', '', '', null); | ||
} | ||
break; | ||
} | ||
} | ||
// echo "<B>Imported $count tracks.</B>\n"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters