From 658391263ebdbd8614cefeb63eb43e3ea521e5b6 Mon Sep 17 00:00:00 2001 From: Teemu Ikonen Date: Thu, 19 Oct 2023 18:02:53 +0300 Subject: [PATCH] Add 'itunes:duration' tag for items with duration (#3774) * [{Atom,Mrss}Format] Allow itunes tags on items without enclosure * [Arte7Bridge] Add $item['itunes']['duration'] value --- bridges/Arte7Bridge.php | 4 ++++ formats/AtomFormat.php | 12 +++++++----- formats/MrssFormat.php | 12 +++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 239fc6ad..5898e881 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -156,6 +156,10 @@ class Arte7Bridge extends BridgeAbstract . $element['mainImage']['url'] . '" />'; + $item['itunes'] = [ + 'duration' => $durationSeconds, + ]; + $this->items[] = $item; } } diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index d59e42fe..07ca7272 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -147,11 +147,13 @@ class AtomFormat extends FormatAbstract $entry->appendChild($itunesProperty); $itunesProperty->appendChild($document->createTextNode($itunesValue)); } - $itunesEnclosure = $document->createElement('enclosure'); - $entry->appendChild($itunesEnclosure); - $itunesEnclosure->setAttribute('url', $itemArray['enclosure']['url']); - $itunesEnclosure->setAttribute('length', $itemArray['enclosure']['length']); - $itunesEnclosure->setAttribute('type', $itemArray['enclosure']['type']); + if (isset($itemArray['enclosure'])) { + $itunesEnclosure = $document->createElement('enclosure'); + $entry->appendChild($itunesEnclosure); + $itunesEnclosure->setAttribute('url', $itemArray['enclosure']['url']); + $itunesEnclosure->setAttribute('length', $itemArray['enclosure']['length']); + $itunesEnclosure->setAttribute('type', $itemArray['enclosure']['type']); + } } elseif (!empty($entryUri)) { $entryLinkAlternate = $document->createElement('link'); $entry->appendChild($entryLinkAlternate); diff --git a/formats/MrssFormat.php b/formats/MrssFormat.php index 4fd06439..5b96a6a7 100644 --- a/formats/MrssFormat.php +++ b/formats/MrssFormat.php @@ -135,11 +135,13 @@ class MrssFormat extends FormatAbstract $entry->appendChild($itunesProperty); $itunesProperty->appendChild($document->createTextNode($itunesValue)); } - $itunesEnclosure = $document->createElement('enclosure'); - $entry->appendChild($itunesEnclosure); - $itunesEnclosure->setAttribute('url', $itemArray['enclosure']['url']); - $itunesEnclosure->setAttribute('length', $itemArray['enclosure']['length']); - $itunesEnclosure->setAttribute('type', $itemArray['enclosure']['type']); + if (isset($itemArray['enclosure'])) { + $itunesEnclosure = $document->createElement('enclosure'); + $entry->appendChild($itunesEnclosure); + $itunesEnclosure->setAttribute('url', $itemArray['enclosure']['url']); + $itunesEnclosure->setAttribute('length', $itemArray['enclosure']['length']); + $itunesEnclosure->setAttribute('type', $itemArray['enclosure']['type']); + } } if (!empty($itemUri)) { $entryLink = $document->createElement('link'); $entry->appendChild($entryLink);