-
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.
- Loading branch information
Showing
47 changed files
with
1,043 additions
and
170 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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Zookeeper Online | ||
* | ||
* @author Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]> | ||
* @link https://zookeeper.ibinx.com/ | ||
* @license GPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License, | ||
* version 3, along with this program. If not, see | ||
* http://www.gnu.org/licenses/ | ||
* | ||
*/ | ||
|
||
namespace ZK\Controllers; | ||
|
||
use ZK\Engine\Engine; | ||
use ZK\Engine\IArtwork; | ||
use ZK\Engine\IPlaylist; | ||
use ZK\Engine\PlaylistEntry; | ||
use ZK\Engine\PlaylistObserver; | ||
|
||
class ArtworkControl implements IController { | ||
protected $verbose = false; | ||
|
||
protected function refreshList($playlist) { | ||
$count = 0; | ||
$imageApi = Engine::api(IArtwork::class); | ||
Engine::api(IPlaylist::class)->getTracksWithObserver($playlist, | ||
(new PlaylistObserver())->on('spin', function($entry) use($imageApi, &$count) { | ||
if(!$entry->getTag() && $entry->getCreated()) { | ||
$artist = $entry->getArtist(); | ||
if($this->verbose) | ||
echo " deleting $artist\n"; | ||
$imageApi->deleteArtistArt($artist); | ||
$count++; | ||
} | ||
}) | ||
); | ||
|
||
if($count) { | ||
echo "$count images queued for reload (please wait)\n"; | ||
PushServer::lazyLoadImages($playlist); | ||
} else | ||
echo "No artist artwork found. No change.\n"; | ||
} | ||
|
||
public function processRequest() { | ||
if(php_sapi_name() != "cli") { | ||
http_response_code(400); | ||
return; | ||
} | ||
|
||
// The heavy lifting is done by the push notification server. | ||
// If it is not enabled, there is no point in proceeding. | ||
if(!Engine::param('push_enabled', true)) { | ||
echo "Push notification is disabled. No change.\n"; | ||
return; | ||
} | ||
|
||
$this->verbose = $_REQUEST["verbose"] ?? false; | ||
|
||
switch($_REQUEST["action"] ?? "") { | ||
case "reload": | ||
if($tag = $_REQUEST["tag"] ?? null) { | ||
echo "Album queued for reload (please wait)\n"; | ||
PushServer::lazyReloadAlbum($tag, $_REQUEST["master"] ?? 1, $_REQUEST["skip"] ?? 0); | ||
break; | ||
} else if($list = $_REQUEST["list"] ?? null) { | ||
$this->refreshList($list); | ||
break; | ||
} | ||
// fall through... | ||
default: | ||
echo "Usage: zk artwork:reload {tag|list}=id [master=0] [skip=0]\n"; | ||
break; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.