Skip to content

Commit

Permalink
Merge hotfix-3-0-0-rc-5 (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketMan authored Jan 8, 2024
1 parent 514623e commit 89200fb
Show file tree
Hide file tree
Showing 17 changed files with 198 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.2']
php-versions: ['7.4', '8.2', '8.3']

steps:
- name: Checkout source
Expand Down
10 changes: 5 additions & 5 deletions .mdhandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@

ob_start("ob_gzhandler");

echo "<!DOCTYPE html>\n<HTML lang=\"en\">\n<HEAD>\n";
echo "<LINK REL=\"stylesheet\" HREF=\"$stylesheet\">\n";
echo "<TITLE>".basename($_SERVER['REQUEST_URI'])."</TITLE>\n";
echo "</HEAD>\n<BODY>\n<DIV class='box'>\n";
echo "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n";
echo "<link rel=\"stylesheet\" href=\"$stylesheet\">\n";
echo "<title>".basename($_SERVER['REQUEST_URI'])."</title>\n";
echo "</head>\n<body>\n<div class='box'>\n";

ob_start(function($buffer) {
return (new Parsedown())->toHtml($buffer);
Expand All @@ -72,6 +72,6 @@

ob_end_flush(); // markdown

echo "\n</DIV>\n</BODY>\n</HTML>\n";
echo "\n</div>\n</body>\n</html>\n";

ob_end_flush(); // ob_gzhandler
2 changes: 1 addition & 1 deletion api/Playlists.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public function patchResource(RequestInterface $request): ResponseInterface {
}

$success = $attrs->isEmpty() ? true :
$api->updatePlaylist($key, $date, $time, $name, $aid);
$api->updatePlaylist($key, $date, $time, $name, $aid, true);

if($success) {
PushServer::sendAsyncNotification();
Expand Down
9 changes: 8 additions & 1 deletion config/config.kzsu.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,15 @@
'ws_endpoint' => 'ws://127.0.0.1:32080/push/onair',
'http_endpoints' => [
"filter" => function($msg) {
// don't proxy Zootopia events
// don't proxy initial (cached) event
$zootopia = preg_match('/zootopia/i', $msg);
if($this->initial ?? true) {
$this->initial = false;
$this->zootopia = $zootopia;
return;
}

// don't proxy Zootopia events
if($zootopia) {
if($this->zootopia ?? false)
return;
Expand Down
13 changes: 6 additions & 7 deletions controllers/ExportAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2021 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -59,17 +59,16 @@ public function processRequest() {
$albums = Engine::api(IChart::class)->getAdd($date)->asArray();

// Emit the albums
foreach($albums as $index => $row) {
foreach($albums as $row) {
// Add & pull dates
echo $row["adddate"] . "\t" .
$row["pulldate"] . "\t";

// Categories
$acats = explode(",", $row["afile_category"]);
foreach($acats as $index => $cat)
if($cat)
echo $cats[$cat-1]["code"];
echo "\t";
echo implode("", array_map(function($cat) use ($cats) {
return $cat ? $cats[$cat - 1]["code"] : "";
}, $acats)) . "\t";

// A-File Number
echo $row["afile_number"] . "\t";
Expand All @@ -96,7 +95,7 @@ public function processRequest() {
echo $artist . "\t" .
$row["album"] . "\t" .
$label . "\t" .
$row["tag" ] . $eol;
$row["tag"] . $eol;
}
}
}
16 changes: 14 additions & 2 deletions controllers/PushServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public function onOpen(ConnectionInterface $conn) {
* @returns false iff communications error, result otherwise (can be empty)
*/
protected function queryDiscogs($artist, $album = null) {
$artist = preg_replace('/(^The\s)|(,\sThe$)/', '', $artist);
$success = true;
$retval = new \stdClass();
$retval->imageUrl = $retval->infoUrl = $retval->resourceUrl = null;
Expand All @@ -238,7 +239,7 @@ protected function queryDiscogs($artist, $album = null) {
"release_title" => preg_replace('/\(.*$/', '', $album),
"per_page" => 40
] : [
"title" => $artist,
"query" => $artist,
"type" => "artist",
"per_page" => 40
];
Expand Down Expand Up @@ -279,8 +280,14 @@ function($carry, $item) {
}
} else {
// advance to the first artist with artwork
//
// now that the artist search is broader, ensure at
// least a portion of the artist's name is present
// to prevent spurious hits
$afrag = mb_substr($artist, 0, 4);
foreach($json->results as $r) {
if($r->cover_image &&
mb_strpos($r->title, $afrag) !== false &&
!preg_match('|/spacer.gif$|', $r->cover_image)) {
$result = $r;
break;
Expand Down Expand Up @@ -325,6 +332,7 @@ protected function queryDiscogsArtistByAlbum($artist, $album) {

if($json) {
$artists = $json->artists ?? null;
$artist = preg_replace('/(^The\s)|(,\sThe$)/', '', $artist);
if($artists && count($artists)) {
foreach($artists as $candidate) {
if(self::testArtist($candidate->name, $artist)) {
Expand Down Expand Up @@ -410,6 +418,8 @@ protected function injectImageData($msg) {
$entry['info_url'] = $infoUrl ?? null;
$entry['image_url'] = isset($imageUuid) ? $imageApi->getCachePath($imageUuid) : ($entry['info_url'] || $entry['track_tag'] ? "img/discogs.svg" : "img/blank.gif");
$msg = json_encode($entry);

DBO::release();
}
}

Expand Down Expand Up @@ -441,6 +451,8 @@ protected function processImageQueue() {
$imageUuid = $imageApi->insertArtistArt($artist, $result->imageUrl, $result->infoUrl);
}

DBO::release();

if(!$this->imageQ->isEmpty()) {
$this->loop->addTimer(self::QUERY_DELAY, function() {
$this->processImageQueue();
Expand Down Expand Up @@ -591,7 +603,7 @@ function($carry, $item) {
$infoUrl = self::DISCOGS_BASE . $result2->uri;
}

if($imageUrl) {
if(!empty($imageUrl)) {
$imageApi = Engine::api(IArtwork::class);
$imageApi->deleteAlbumArt($tag);
$uuid = $imageApi->insertAlbumArt($tag, $imageUrl, $infoUrl);
Expand Down
37 changes: 17 additions & 20 deletions controllers/RSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,13 @@ public function recentCharts() {
$this->params['limit'] = $top;
$this->params['dateSpec'] = UI::isUsLocale() ? 'l, F j, Y' : 'l, j F Y';
$this->params['MEDIA'] = ILibrary::MEDIA;
$weeks = Engine::api(IChart::class)->getChartDates($weeks);
$charts = [];
while($weeks && ($week = $weeks->fetch())) {
$chart = [];
$chart['endDate'] = $week['week'];
$chart['albums'] = $this->composeChartRSS($week['week'], $top);
$charts[] = $chart;
}
$weeks = Engine::api(IChart::class)->getChartDates($weeks)->asArray();
$charts = array_map(function($week) use ($top) {
return [
'endDate' => $week['week'],
'albums' => $this->composeChartRSS($week['week'], $top)
];
}, $weeks);
$this->params['charts'] = $charts;
$this->params['feeds'][] = 'charts';
}
Expand Down Expand Up @@ -118,11 +117,10 @@ public function composeAddRSS($addDate, $cats) {
if($results) {
while($row = $results->fetch()) {
// Categories
$codes = "";
$acats = explode(",", $row["afile_category"]);
foreach($acats as $index => $cat)
if($cat)
$codes .= $cats[$cat-1]["code"];
$codes = implode("", array_map(function($cat) use ($cats) {
return $cat ? $cats[$cat - 1]["code"] : "";
}, $acats));

if($codes == "")
$codes = "G";
Expand All @@ -139,15 +137,14 @@ public function recentAdds() {

$this->params['dateSpec'] = UI::isUsLocale() ? 'l, F j, Y' : 'l, j F Y';
$this->params['MEDIA'] = ILibrary::MEDIA;
$weeks = Engine::api(IChart::class)->getAddDates($weeks);
$weeks = Engine::api(IChart::class)->getAddDates($weeks)->asArray();
$cats = Engine::api(IChart::class)->getCategories();
$adds = [];
while($weeks && ($week = $weeks->fetch())) {
$add = [];
$add['addDate'] = $week["adddate"];
$add['albums'] = $this->composeAddRSS($week["adddate"], $cats);
$adds[] = $add;
}
$adds = array_map(function($week) use ($cats) {
return [
'addDate' => $week["adddate"],
'albums' => $this->composeAddRSS($week["adddate"], $cats)
];
}, $weeks);
$this->params['adds'] = $adds;
$this->params['feeds'][] = 'adds';
}
Expand Down
1 change: 1 addition & 0 deletions css/zoostyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ form.review .action-area-new {
/* layout */
div.box {
width: 900px;
padding: 0 10px;
margin-left: auto;
margin-right: auto;
}
Expand Down
Loading

0 comments on commit 89200fb

Please sign in to comment.