diff options
| author | Quentin Aristote <quentin@aristote.fr> | 2022-12-20 22:29:55 +0100 |
|---|---|---|
| committer | Quentin Aristote <quentin@aristote.fr> | 2022-12-20 22:29:55 +0100 |
| commit | 95644485ac1402a8dc84c520a3ded7b29720f950 (patch) | |
| tree | c124a795dba03106cadff1645c532f6251898f86 /config/services/web | |
| parent | 51df83cffaa45130f94bf5ab78b6b14fbb37ec4d (diff) | |
| parent | 9bde3c4624eb916bafcf9a18792edb42e3a25a17 (diff) | |
Merge branch 'master' into searx-engine-alternativeto
Diffstat (limited to 'config/services/web')
| -rw-r--r-- | config/services/web/quentin/default.nix | 2 | ||||
| -rw-r--r-- | config/services/web/rss/FipAlbumsBridge.php | 41 | ||||
| -rw-r--r-- | config/services/web/rss/ParisCineInfoBridge.php | 98 | ||||
| -rw-r--r-- | config/services/web/rss/WhatsOnMubiBridge.php | 49 | ||||
| -rw-r--r-- | config/services/web/rss/default.nix | 40 | ||||
| -rw-r--r-- | config/services/web/searx/searx/engines.nix | 30 |
6 files changed, 219 insertions, 41 deletions
diff --git a/config/services/web/quentin/default.nix b/config/services/web/quentin/default.nix index 8456565..f284071 100644 --- a/config/services/web/quentin/default.nix +++ b/config/services/web/quentin/default.nix @@ -3,7 +3,7 @@ { services.nginx.virtualHosts.quentin = { serverName = "quentin.${config.networking.domain}"; - locations."/".root = "${pkgs.personal.academic-webpage}"; + locations."/".root = "${pkgs.personal.webpage}"; forceSSL = true; enableACME = true; }; diff --git a/config/services/web/rss/FipAlbumsBridge.php b/config/services/web/rss/FipAlbumsBridge.php new file mode 100644 index 0000000..b8ec64d --- /dev/null +++ b/config/services/web/rss/FipAlbumsBridge.php @@ -0,0 +1,41 @@ +<?php + +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, "CardAlbum ")]'; + const XPATH_EXPRESSION_ITEM_TITLE = './/a/@title'; + const XPATH_EXPRESSION_ITEM_CONTENT = './/img/@alt'; + const XPATH_EXPRESSION_ITEM_URI = './/a/@href'; + const XPATH_EXPRESSION_ITEM_AUTHOR = './/div[starts-with(@class, "CardAlbum-details ")]/div[2]'; + const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/time/@datetime'; + const XPATH_EXPRESSION_ITEM_ENCLOSURES = './/img/@src'; + const XPATH_EXPRESSION_ITEM_CATEGORIES = './/div[starts-with(@class, "CardDetails-label ")]/span[2]'; + + 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) { + return strtotime('today +' . $value); + } +} diff --git a/config/services/web/rss/ParisCineInfoBridge.php b/config/services/web/rss/ParisCineInfoBridge.php new file mode 100644 index 0000000..5e418b4 --- /dev/null +++ b/config/services/web/rss/ParisCineInfoBridge.php @@ -0,0 +1,98 @@ +<?php + +class ParisCineInfoBridge extends BridgeAbstract { + const NAME = 'Paris-ciné.info Bridge'; + const URI = 'https://paris-cine.info/'; + const DESCRIPTION = 'Movies playing in Paris'; + const MAINTAINER = 'Quentin Aristote'; + const CACHE_TIMEOUT = 86400; // 24h + + const PARAMETERS = [ + 'Filters' => [ + // TODO add an option for choosing the reviewer + 'card' => [ + 'name' => 'Card', + 'type' => 'text', + 'title' => 'Fidelity / subscription card.', + 'exampleValue' => 'ugc', + 'defaultValue' => 'all' + ], + 'dayid' => [ + 'name' => 'Day of the week', + 'type' => 'text', + 'title' => 'Comma-separated list of integers (0 means everyday, 1 means Sunday, etc.)/', + 'exampleValue' => '1,3,6', + 'defaultValue' => '0' + ], + 'time' => [ + 'name' => 'Time of day', + 'type' => 'text', + 'title' => 'Morning (8AM-12AM), Afternoon (12AM-18PM), Evening (18PM-12PM).', + 'exampleValue' => 'soir', + 'defaultValue' => 'all' + ], + 'addr' => [ + 'name' => 'Location', + 'type' => 'text', + 'title' => 'Comma-separated list of districts or cities.', + 'exampleValue' => '13e,Châtillon', + 'defaultValue' => 'Paris' + ], + 'cine' => [ + 'name' => 'Theater', + 'type' => 'text', + 'title' => 'ID of a movie theater.', + 'exampleValue' => 'C0150', + ], + 'format' => [ + 'name' => 'Format', + 'type' => 'text', + 'title' => 'Movie format.', + 'exampleValue' => '3D' + ] + ] + ]; + + public function getSourceUrl() { + $query = ''; + foreach(self::PARAMETERS['Filters'] as $param => $val) { + $value = $this->getInput($param); + if ($value != '') { + $query = $query . 'sel' . $param . '=' . $value . '&'; + } + } + $selday = ['week', 'dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'][$this->getInput('dayid')]; + return self::URI . 'get_pcimovies.php?' . $query . 'selday=' . $selday; + } + + private function fetchData() { + return json_decode(getSimpleHTMLDOMCached($this->getSourceUrl()))->data; + } + + public function getIcon() { + return 'https://paris-cine.info/resources/img/favicon-16x16.png'; + } + + public function collectData() { + $data = $this->fetchData(); + foreach($data as $film) { + $item = [ + 'uri' => str_replace('\\/', '/', $film->sc_url), + 'title' => $film->title, + 'timestamp' => str_replace('/', '-', $film->released), + 'author' => $film->dir, + 'content' => ( + $film->year . ' - ' . + 'with ' . str_replace(',', ', ', $film->actors) . ' - ' . + $film->duration . ' - ' . + 'SC: ' . $film->sc_rating . '/10 - ' . + 'IMDB: ' . $film->imdbr . '/10' . ' ' + ), + 'enclosures' => [ $film->poster_url ], + 'categories' => explode(',', $film->genre), + 'id' => $film->id + ]; + $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 4d7dd18..f2b667b 100644 --- a/config/services/web/rss/default.nix +++ b/config/services/web/rss/default.nix @@ -1,28 +1,40 @@ { config, lib, pkgs, ... }: -let - cfg = config.services.rss-bridge; - debug = false; - rss-bridge = pkgs.rss-bridge.overrideAttrs (oldAttrs: - oldAttrs // { - installPhase = oldAttrs.installPhase + '' - ln -sf ${./ParisJazzClubBridge.php} $out/bridges/ParisJazzClubBridge.php - ln -sf ${./MaisonDeLaRadioBridge.php} $out/bridges/MaisonDeLaRadioBridge.php - '' + lib.optionalString debug '' - touch $out/DEBUG - ''; - }); +let cfg = config.services.rss-bridge; in { services.rss-bridge = { enable = true; - whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" ]; + extraBridges = [ + # Music + { + name = "FipAlbums"; + source = ./FipAlbumsBridge.php; + } + ## Concerts + { + name = "ParisJazzClub"; + source = ./ParisJazzClubBridge.php; + } + { + name = "MaisonDeLaRadio"; + source = ./MaisonDeLaRadioBridge.php; + } + # Cinema + { + name = "WhatsOnMubi"; + source = ./WhatsOnMubiBridge.php; + } + { + name = "ParisCineInfo"; + source = ./ParisCineInfoBridge.php; + } + ]; virtualHost = "rss"; }; services.nginx = lib.mkIf (cfg.virtualHost != null) { virtualHosts.${cfg.virtualHost} = { serverName = "rss.${config.networking.domain}"; - root = lib.mkForce "${rss-bridge}"; forceSSL = true; enableACME = true; }; diff --git a/config/services/web/searx/searx/engines.nix b/config/services/web/searx/searx/engines.nix index 67de025..9b51d16 100644 --- a/config/services/web/searx/searx/engines.nix +++ b/config/services/web/searx/searx/engines.nix @@ -29,9 +29,9 @@ let extraParameters = { fulltext = 1; }; }; results_xpath = ''//ul[@class="mw-search-results"]/li''; - url_xpath = ''./div[@class="mw-search-result-heading"]/a/@href''; - title_xpath = ''./div[@class="mw-search-result-heading"]/a''; - content_xpath = ''./div[@class="searchresult"]''; + url_xpath = ''.//div[@class="mw-search-result-heading"]/a/@href''; + title_xpath = ''.//div[@class="mw-search-result-heading"]/a/@title''; + content_xpath = ''.//div[@class="searchresult"]''; shortcut = "w${lang}"; categories = "general"; disabled = true; @@ -54,7 +54,7 @@ in { # files "btdigg" # images - "ccengine" + "openverse" "bing images" "library of congress" "qwant images" @@ -95,28 +95,6 @@ in { results = "HTML"; }; } - { # Emojipedia - name = "emojipedia"; - engine = "xpath"; - search_url = makeSearchUrl { - baseUrl = "https://emojipedia.org/search/"; - queryKeyword = "q"; - }; - results_xpath = ''//ol[@class="search-results"]/li/h2''; - url_xpath = "./a/@href"; - title_xpath = "./a"; - content_xpath = "../p"; - shortcut = "emoji"; - disabled = true; - about = { - website = "https://emojipedia.org/"; - wikidata_id = "Q22908129"; - official_api_documentation = ""; - use_official_api = false; - require_api_key = false; - results = "HTML"; - }; - } { name = "nlab"; engine = "xpath"; |
