summaryrefslogtreecommitdiff
path: root/config/services/web/rss
diff options
context:
space:
mode:
Diffstat (limited to 'config/services/web/rss')
-rw-r--r--config/services/web/rss/MubiBridge.php68
-rw-r--r--config/services/web/rss/WhatsOnMubiBridge.php49
-rw-r--r--config/services/web/rss/default.nix4
3 files changed, 51 insertions, 70 deletions
diff --git a/config/services/web/rss/MubiBridge.php b/config/services/web/rss/MubiBridge.php
deleted file mode 100644
index 992f463..0000000
--- a/config/services/web/rss/MubiBridge.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-function tryGetDescription($obj) {
- if (property_exists($obj, 'primary_film_group')
- && !is_null($obj->primary_film_group)) {
- return $obj->primary_film_group->description_html . '<br>';
- } else {
- return '';
- }
-}
-
-class MubiBridge extends XPathAbstract {
- const NAME = 'Mubi Bridge';
- const URI = 'https://mubi.com';
- const DESCRIPTION = 'Mubi\'s film of the day.';
- const MAINTAINER = 'Quentin Aristote';
- const CACHE_TIMEOUT = 21600; // 6h
-
- const PARAMETERS = [
- '' => [
- 'language' => [
- 'name' => 'Language',
- 'type' => 'text',
- 'exampleValue' => 'en / de / es / fr / it / nl / pt / tr',
- 'defaultValue' => 'en'
- ]
- ]
- ];
-
- public function getIcon() {
- return 'https://mubi.com/favicon.ico';
- }
-
- public function getUri() {
- return self::URI . '/' . $this->getInput('language') . '/film-of-the-day';
- }
-
- public function collectData() {
- $dataJsonStr = extractFromDelimiters(
- getSimpleHTMLDOMCached($this->getUri()),
- '<script id="__NEXT_DATA__" type="application/json">',
- '</script>');
- $data = json_decode($dataJsonStr)->props->initialState;
- foreach ($data->filmProgramming->filmProgrammings as $filmProgramming) {
- $id = $filmProgramming->filmId;
- $film = $data->film->films->{$id};
- $item = [
- 'title' => $filmProgramming->email_subject,
- 'uri' => 'https://mubi.com/' . $this->getInput('language') . '/films/' . $film->slug,
- 'timestamp' => strtotime($filmProgramming->available_at),
- 'author' => $film->directors[0]->name,
- 'content' => (
- $filmProgramming->our_take_html . '<br>' .
- tryGetDescription($filmProgramming) .
- $film->short_synopsis_html . '<br>' .
- $film->default_editorial_html
- ),
- 'enclosures' => [
- $film->stills->standard,
- $film->trailer_url
- ],
- 'categories' => $film->genres,
- 'uid' => $id . $filmProgramming->available_at
- ];
- $this->items[] = $item;
- }
- }
-}
diff --git a/config/services/web/rss/WhatsOnMubiBridge.php b/config/services/web/rss/WhatsOnMubiBridge.php
new file mode 100644
index 0000000..4cf7718
--- /dev/null
+++ b/config/services/web/rss/WhatsOnMubiBridge.php
@@ -0,0 +1,49 @@
+<?php
+
+class WhatsOnMubiBridge extends XPathAbstract {
+ const NAME = 'What\'s on Mubi Bridge';
+ const URI = 'https://whatsonmubi.com/?catalogue=ns&sort=expires-desc';
+ const DESCRIPTION = 'Movies currently showing on Mubi.';
+ const MAINTAINER = 'Quentin Aristote';
+ const CACHE_TIMEOUT = 21800; // 6h
+
+ const PARAMETERS = [
+ '' => [
+ 'country' => [
+ 'name' => 'Country',
+ 'type' => 'text',
+ 'exampleValue' => 'fr',
+ 'defaultValue' => 'fr',
+ ]
+ ]
+ ];
+
+ const XPATH_EXPRESSION_ITEM = '//div[@class="film"]';
+ const XPATH_EXPRESSION_ITEM_TITLE = './/h2';
+ const XPATH_EXPRESSION_ITEM_CONTENT = './/div[@class="film_details flex flex-col flex-1"]';
+ const XPATH_EXPRESSION_ITEM_URI = './/a[@class="relative film_thumbnail"]/@href';
+ const XPATH_EXPRESSION_ITEM_AUTHOR = './@data-directors';
+ const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/p[@class="hidden film-expires"]';
+ const XPATH_EXPRESSION_ITEM_ENCLOSURES = './/a[@class="relative film_thumbnail"]/img/@src';
+ const XPATH_EXPRESSION_ITEM_CATEGORIES = './/div[@class="film_details flex flex-col flex-1"]//div[@class="mt-3 flex flex-wrap"]';
+
+ public function getSourceUrl() {
+ return self::URI . '&showing=' . $this->getInput('country');
+ }
+
+ public function getIcon() {
+ return 'https://whatsonmubi.com/favicon.ico';
+ }
+
+ protected function formatItemTimestamp($value) {
+ return strtotime('today +' . $value);
+ }
+
+ protected function formatItemContent($value) {
+ $text = preg_replace("/\s{2}\s+/", "\n", $value);
+ $lines = array_map("trim", explode("\n", $text));
+ $title = $lines[0];
+ $director = $lines[1];
+ return $director . ' ' . $title;
+ }
+}
diff --git a/config/services/web/rss/default.nix b/config/services/web/rss/default.nix
index 8975d14..2c5d515 100644
--- a/config/services/web/rss/default.nix
+++ b/config/services/web/rss/default.nix
@@ -9,7 +9,7 @@ let
pushd $out/bridges
ln -sf ${./ParisJazzClubBridge.php} ParisJazzClubBridge.php
ln -sf ${./MaisonDeLaRadioBridge.php} MaisonDeLaRadioBridge.php
- ln -sf ${./MubiBridge.php} MubiBridge.php
+ ln -sf ${./WhatsOnMubiBridge.php} WhatsOnMubiBridge.php
popd
'' + lib.optionalString debug ''
touch $out/DEBUG
@@ -18,7 +18,7 @@ let
in {
services.rss-bridge = {
enable = true;
- whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "Mubi" ];
+ whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "WhatsOnMubi" ];
virtualHost = "rss";
};