summaryrefslogtreecommitdiffstats
path: root/tv/2configs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2023-02-02 15:24:04 +0100
committertv <tv@krebsco.de>2023-02-02 15:25:55 +0100
commitbeab66db651b3f5d0c6f033221a8acda4531c4d1 (patch)
treede8383e5616f81914e61e03c8c8ebcc903b963b0 /tv/2configs
parent38062bf06659e3ad9b2427c2049aa3ccce47c24c (diff)
tv urlwatch exec: use dict-based filter list
Because string-based filter definitions are deprecated since 2.19 Refs https://urlwatch.readthedocs.io/en/latest/deprecated.html
Diffstat (limited to 'tv/2configs')
-rw-r--r--tv/2configs/urlwatch.nix21
1 files changed, 14 insertions, 7 deletions
diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix
index 7ba364ff3..e2cd19902 100644
--- a/tv/2configs/urlwatch.nix
+++ b/tv/2configs/urlwatch.nix
@@ -2,9 +2,10 @@ with import ./lib;
{ config, pkgs, ... }: let
exec = filename: args: url: {
inherit url;
- filter = "system:${
- concatMapStringsSep " " shell.escape ([filename] ++ toList args)
- }";
+ filter = singleton {
+ system =
+ concatMapStringsSep " " shell.escape ([filename] ++ toList args);
+ };
};
json = json' ["."];
json' = exec "${pkgs.jq}/bin/jq";
@@ -73,17 +74,23 @@ in {
import subprocess
import urlwatch
- class CaseFilter(urlwatch.filters.FilterBase):
+ class SystemFilter(urlwatch.filters.FilterBase):
"""Filter for piping data through an external process"""
__kind__ = 'system'
+ __supported_subfilters__ = {
+ 'command': 'shell command line to tranform data',
+ }
+
+ __default_subfilter__ = 'command'
+
def filter(self, data, subfilter=None):
- if subfilter is None:
- raise ValueError('The system filter needs a command')
+ if 'command' not in subfilter:
+ raise ValueError('{} filter needs a command'.format(self.__kind__))
proc = subprocess.Popen(
- subfilter,
+ subfilter['command'],
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,