From bdc4da6ad07f2f5dfa7cf397cf3a379199c0a2ed Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 16 Apr 2020 18:11:26 +0200 Subject: Expose podcast in API (#2898) * Expose podcast in API Expose RSS enclosures in our API, e.g. for clients supporting podcasts * PHP CS? * Annoying linter * Light optimisation --- p/api/greader.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'p') diff --git a/p/api/greader.php b/p/api/greader.php index 69962e9d5..d538ec429 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -508,6 +508,18 @@ function entriesToArray($entries) { //'htmlUrl' => $line['f_website'], ), ); + foreach ($entry->enclosures() as $enclosure) { + if (!empty($enclosure['url']) && !empty($enclosure['type'])) { + $media = [ + 'href' => $enclosure['url'], + 'type' => $enclosure['type'], + ]; + if (!empty($enclosure['length'])) { + $media['length'] = intval($enclosure['length']); + } + $item['enclosure'][] = $media; + } + } $author = $entry->authors(true); $author = trim($author, '; '); if ($author != '') { -- cgit v1.2.3