Skip to content

Commit

Permalink
Merge hotfix-3-0-0-rc-4 (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketMan authored Nov 5, 2023
1 parent e87891f commit 8358ddb
Show file tree
Hide file tree
Showing 47 changed files with 1,043 additions and 170 deletions.
2 changes: 2 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ RewriteEngine on
RewriteRule ^zkrss\.php$ index.php?target=rss [QSA,L]
RewriteRule ^zk-feed-reader\.xslt$ controllers/RSS.xslt [QSA,L]
RewriteRule ^ssoLogin\.php$ index.php?target=sso [QSA,L]
RewriteCond %{REQUEST_URI} ^(.*)/tag/([0-9]+)$
RewriteRule .* %1/?action=search&s=byAlbumKey&n=%2 [R=302]
RewriteCond $0 !^\.mdhandler.php/.*$
RewriteRule ^(.+)\.md$ .mdhandler.php?asset=/$1.md [L]
RewriteRule ^zk$ - [R=404,L]
Expand Down
12 changes: 7 additions & 5 deletions api/Playlists.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public static function fromRecord($rec, $flags) {
})->onSpin(function($entry) use(&$events, $relations, $flags) {
$spin = $entry->asArray();
$spin["type"] = "spin";
$spin["artist"] = PlaylistEntry::swapNames($spin["artist"]);
if($spin["tag"])
$spin["artist"] = PlaylistEntry::swapNames($spin["artist"]);
$spin["created"] = $entry->getCreatedTime();
if($spin["tag"] && $flags & self::LINKS_ALBUMS) {
$tag = $spin["tag"];
Expand Down Expand Up @@ -317,11 +318,11 @@ public function fetchRelationship(RequestInterface $request): ResponseInterface
unset($attrs["tag"]);
unset($attrs["id"]);
$a->merge($attrs);
$a->set("artist", PlaylistEntry::swapNames($entry->getArtist()));
$a->set("created", $entry->getCreatedTime());

$tag = $entry->getTag();
if($tag) {
$a->set("artist", PlaylistEntry::swapNames($entry->getArtist()));
if($flags && sizeof($albums = Engine::api(ILibrary::class)->search(ILibrary::ALBUM_KEY, 0, 1, $tag)))
$res = Albums::fromArray($albums, $flags)[0];
else
Expand Down Expand Up @@ -665,7 +666,7 @@ public function addRelatedResources(RequestInterface $request): ResponseInterfac
// don't allow modification of album info if tag is set
$entry->setTag($album->id());
if(!$albumrec[0]["iscoll"])
$entry->setArtist(PlaylistEntry::swapNames($albumrec[0]["artist"]));
$entry->setArtist($albumrec[0]["artist"]);
$entry->setAlbum($albumrec[0]["album"]);
$entry->setLabel($albumrec[0]["name"]);
}
Expand Down Expand Up @@ -717,7 +718,8 @@ public function addRelatedResources(RequestInterface $request): ResponseInterfac
$list['id'] = $key;
if($entry->isType(PlaylistEntry::TYPE_SPIN)) {
$spin = $entry->asArray();
$spin['artist'] = PlaylistEntry::swapNames($spin['artist']);
if($spin['tag'])
$spin['artist'] = PlaylistEntry::swapNames($spin['artist']);
} else
$spin = null;

Expand Down Expand Up @@ -790,7 +792,7 @@ public function replaceRelatedResources(RequestInterface $request): ResponseInte
// don't allow modification of album info if tag is set
$entry->setTag($album->id());
if(!$albumrec[0]["iscoll"])
$entry->setArtist(PlaylistEntry::swapNames($albumrec[0]["artist"]));
$entry->setArtist($albumrec[0]["artist"]);
$entry->setAlbum($albumrec[0]["album"]);
$entry->setLabel($albumrec[0]["name"]);
}
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@
"react/datagram": "^1.5",
"react/http": "^1.2",
"ratchet/pawl": "^0.4.1",
"rocketman/pdf-label": "^1.6+rocketman.1",
"rocketman/pdf-label": "^1.6+rocketman.2",
"twig/twig": "^3.5.1",
"vstelmakh/url-highlight": "^3.0"
},
"suggest": {
"ext-intl": "Allows transliteration of Cyrillic and Greek to Latin"
}
}
23 changes: 14 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/controller_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'export' => ZK\Controllers\ExportPlaylist::class,
'afile' => ZK\Controllers\ExportAfile::class,
'opensearch' => ZK\Controllers\OpenSearch::class,
'artwork' => ZK\Controllers\ArtworkControl::class,
'cache' => ZK\Controllers\CacheControl::class,
'daily' => ZK\Controllers\RunDaily::class,
'print' => ZK\Controllers\PrintTags::class,
Expand Down
89 changes: 89 additions & 0 deletions controllers/ArtworkControl.php
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;
}
}
}
4 changes: 2 additions & 2 deletions controllers/ExportPlaylist.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function emitCSV() {
// emit the tracks
echo "Artist\tTrack\tAlbum\tTag\tLabel\tTimestamp\n";
$observer = (new PlaylistObserver())->onSpin(function($entry) {
echo $entry->getArtist()."\t".
echo ($entry->getTag() ? PlaylistEntry::swapNames($entry->getArtist()) : $entry->getArtist())."\t".
$entry->getTrack()."\t".
$entry->getAlbum()."\t".
$entry->getTag()."\t".
Expand Down Expand Up @@ -249,7 +249,7 @@ public function emitHTML() {
$break = true;
}
})->onSpin(function($entry) use(&$break) {
echo " <TR><TD ALIGN=LEFT VALIGN=TOP>".htmlentities(PlaylistEntry::swapNames($entry->getArtist())) . "</TD><TD ALIGN=LEFT VALIGN=TOP>" .
echo " <TR><TD ALIGN=LEFT VALIGN=TOP>".htmlentities($entry->getTag() ? PlaylistEntry::swapNames($entry->getArtist()) : $entry->getArtist()) . "</TD><TD ALIGN=LEFT VALIGN=TOP>" .
htmlentities($entry->getTrack()). "</TD><TD ALIGN=LEFT>" .
htmlentities($entry->getAlbum()). "<BR><FONT CLASS=\"sub\">" .
htmlentities($entry->getLabel()). "</FONT></TD><TD ALIGN=RIGHT VALIGN=TOP>";
Expand Down
Loading

0 comments on commit 8358ddb

Please sign in to comment.