diff options
Diffstat (limited to 'app/Models/Entry.php')
| -rw-r--r-- | app/Models/Entry.php | 22 |
1 files changed, 22 insertions, 0 deletions
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, '<p class="enclosure-content') !== false) { + $dom = new DOMDocument(); + $dom->loadHTML($this->content, LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING); + $xpath = new DOMXpath($dom); + $enclosures = $xpath->query('//div[@class="enclosure"]/p[@class="enclosure-content"]/*[@src]'); + foreach ($enclosures as $enclosure) { + $results[] = [ + 'url' => $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; } |
