summaryrefslogtreecommitdiff
path: root/config/services/web/rss/FipAlbumsBridge.php
diff options
context:
space:
mode:
authorquentin@aristote.fr <quentin@aristote.fr>2026-11-29 17:24:18 +0100
committerquentin@aristote.fr <quentin@aristote.fr>2026-11-29 17:42:35 +0100
commitce831333a24011d0692f6871047fe74eab9fab8c (patch)
tree9bb971e2afe0a4b22c73274e8b8e8d05d014401d /config/services/web/rss/FipAlbumsBridge.php
downloadhermaphroditos-ce831333a24011d0692f6871047fe74eab9fab8c.tar.gz
hermaphroditos-ce831333a24011d0692f6871047fe74eab9fab8c.tar.bz2
hermaphroditos-ce831333a24011d0692f6871047fe74eab9fab8c.tar.xz
initial commit
Diffstat (limited to 'config/services/web/rss/FipAlbumsBridge.php')
-rw-r--r--config/services/web/rss/FipAlbumsBridge.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/config/services/web/rss/FipAlbumsBridge.php b/config/services/web/rss/FipAlbumsBridge.php
new file mode 100644
index 0000000..aa5e597
--- /dev/null
+++ b/config/services/web/rss/FipAlbumsBridge.php
@@ -0,0 +1,56 @@
+<?php
+
+$GLOBALS['DATE_FORMATTER'] = new IntlDateFormatter(
+ 'fr-FR',
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::SHORT,
+ 'Etc/UTC',
+ IntlDateFormatter::GREGORIAN,
+ "d MMMM y"
+);
+
+class FipAlbumsBridge extends XPathAbstract {
+ const NAME = 'Fip Albums Bridge';
+ const URI = 'https://www.radiofrance.fr/fip/albums/';
+ const DESCRIPTION = 'Albums promoted by Fip.';
+ const MAINTAINER = 'Quentin Aristote';
+ const CACHE_TIMEOUT = 86400; // 6h
+
+ const PARAMETERS = [
+ '' => [
+ 'category' => [
+ 'name' => 'Category',
+ 'type' => 'text',
+ 'description' => 'See examples for available options.',
+ 'exampleValue' => 'can be empty, "selections" or "album-jazz-de-la-semaine"'
+ ]
+ ]
+ ];
+
+ const XPATH_EXPRESSION_ITEM = '//div[starts-with(@class, "CardSide ")]';
+ const XPATH_EXPRESSION_ITEM_TITLE = './/a/@aria-label';
+ const XPATH_EXPRESSION_ITEM_CONTENT = './/img/@alt';
+ const XPATH_EXPRESSION_ITEM_URI = './/a/@href';
+ const XPATH_EXPRESSION_ITEM_AUTHOR = './/div[starts-with(@class, "title-zone ")]/p[2]/text()';
+ const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/div[starts-with(@class, "AdditionalInfos ")]/p[1]/text()';
+ const XPATH_EXPRESSION_ITEM_ENCLOSURES = './/img/@src';
+ const XPATH_EXPRESSION_ITEM_CATEGORIES = './/div[starts-with(@class, "AdditionalInfos ")]/p[2]/text()';
+
+ public function getSourceUrl() {
+ return self::URI . $this->getInput('category');
+ }
+
+ public function getIcon() {
+ return 'https://www.radiofrance.fr/dist/favicons/fip/favicon.png';
+ }
+
+ protected function formatItemTimestamp($value) {
+ $monthyear = explode(": ", $value)[1];
+ return $GLOBALS['DATE_FORMATTER']->parse('1 ' . $monthyear);
+ }
+
+ # enclosure links don't have an extension
+ protected function cleanMediaUrl($mediaUrl) {
+ return $mediaUrl;
+ }
+}