mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-05 16:17:28 +02:00
feat: preserve and reproduce podcast feeds (itunes rss module) (#3759)
This commit is contained in:
@@ -16,6 +16,8 @@ class AtomFormat extends FormatAbstract
|
||||
|
||||
public function stringify()
|
||||
{
|
||||
$document = new \DomDocument('1.0', $this->getCharset());
|
||||
|
||||
$feedUrl = get_current_url();
|
||||
|
||||
$extraInfos = $this->getExtraInfos();
|
||||
@@ -25,7 +27,6 @@ class AtomFormat extends FormatAbstract
|
||||
$uri = $extraInfos['uri'];
|
||||
}
|
||||
|
||||
$document = new \DomDocument('1.0', $this->getCharset());
|
||||
$document->formatOutput = true;
|
||||
$feed = $document->createElementNS(self::ATOM_NS, 'feed');
|
||||
$document->appendChild($feed);
|
||||
@@ -81,6 +82,7 @@ class AtomFormat extends FormatAbstract
|
||||
$linkSelf->setAttribute('href', $feedUrl);
|
||||
|
||||
foreach ($this->getItems() as $item) {
|
||||
$itemArray = $item->toArray();
|
||||
$entryTimestamp = $item->getTimestamp();
|
||||
$entryTitle = $item->getTitle();
|
||||
$entryContent = $item->getContent();
|
||||
@@ -138,7 +140,19 @@ class AtomFormat extends FormatAbstract
|
||||
$entry->appendChild($id);
|
||||
$id->appendChild($document->createTextNode($entryID));
|
||||
|
||||
if (!empty($entryUri)) {
|
||||
if (isset($itemArray['itunes'])) {
|
||||
$feed->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:itunes', self::ITUNES_NS);
|
||||
foreach ($itemArray['itunes'] as $itunesKey => $itunesValue) {
|
||||
$itunesProperty = $document->createElementNS(self::ITUNES_NS, $itunesKey);
|
||||
$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']);
|
||||
} elseif (!empty($entryUri)) {
|
||||
$entryLinkAlternate = $document->createElement('link');
|
||||
$entry->appendChild($entryLinkAlternate);
|
||||
$entryLinkAlternate->setAttribute('rel', 'alternate');
|
||||
|
Reference in New Issue
Block a user