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 --- app/Models/Entry.php | 22 ++++++++++++++++++++++ app/Models/Feed.php | 5 +++++ 2 files changed, 27 insertions(+) (limited to 'app/Models') diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 9540e0ed5..f4cd82288 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -59,6 +59,28 @@ class FreshRSS_Entry extends Minz_Model { public function content() { return $this->content; } + public function enclosures() { + $results = []; + try { + if (strpos($this->content, '

$enclosure->getAttribute('src'), + 'type' => $enclosure->getAttribute('data-type'), + 'length' => $enclosure->getAttribute('data-length'), + ]; + } + } + return $results; + } catch (Exception $ex) { + return $results; + } + } + public function link() { return $this->link; } diff --git a/app/Models/Feed.php b/app/Models/Feed.php index a41b35860..c0bc90b2d 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -373,13 +373,18 @@ class FreshRSS_Feed extends Minz_Model { $elinks[$elink] = true; $mime = strtolower($enclosure->get_type()); $medium = strtolower($enclosure->get_medium()); + $length = $enclosure->get_length(); if ($medium === 'image' || strpos($mime, 'image/') === 0) { $enclosureContent .= '

'; } elseif ($medium === 'audio' || strpos($mime, 'audio/') === 0) { $enclosureContent .= '

💾

'; } elseif ($medium === 'video' || strpos($mime, 'video/') === 0) { $enclosureContent .= '

💾

'; } elseif ($medium != '' || strpos($mime, 'application/') === 0 || strpos($mime, 'text/') === 0) { $enclosureContent .= '

💾

'; -- cgit v1.2.3