From 9c54385d89c07ab1d22d5cf131d64d637c70cbcf Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 10 Apr 2020 19:50:51 -0400 Subject: [PATCH] Fix JSON enclosure titles --- lib/Enclosure/Enclosure.php | 2 +- lib/Parser/JSON/Entry.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Enclosure/Enclosure.php b/lib/Enclosure/Enclosure.php index 9976832..c100513 100644 --- a/lib/Enclosure/Enclosure.php +++ b/lib/Enclosure/Enclosure.php @@ -8,8 +8,8 @@ namespace MensBeam\Lax\Enclosure; /** * @property \MensBeam\Lax\Url $url + * @property \MensBeam\Lax\Text $title * @property string $type - * @property string $title * @property int $height * @property int $width * @property int $duration diff --git a/lib/Parser/JSON/Entry.php b/lib/Parser/JSON/Entry.php index 9421c77..57492c1 100644 --- a/lib/Parser/JSON/Entry.php +++ b/lib/Parser/JSON/Entry.php @@ -163,17 +163,18 @@ class Entry implements \MensBeam\Lax\Parser\Entry { $m = new Enclosure; $m->url = $url; $m->type = $this->fetchType("mime_type", $url, $attachment); - $m->title = $this->fetchMember("title", "str", $attachment); + $m->title = $this->fetchText("title", $attachment); $m->size = $this->fetchMember("size_in_bytes", "int", $attachment); $m->duration = $this->fetchMember("duration_in_seconds", "int", $attachment); if (isset($m->title)) { // if the enclosure has a title, it should be part of a set // the set may need to be created - if (isset($titled[$m->title])) { - $titled[$m->title][] = $m; + $title = $m->title ? $m->title->plain : null; + if (isset($titled[$title])) { + $titled[$title][] = $m; } else { - $titled[$m->title] = new Enclosure($m); - $out[] = $titled[$m->title]; + $titled[$title] = new Enclosure($m); + $out[] = $titled[$title]; } } else { $out[] = $m;