diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2025-04-27 19:24:27 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2025-04-27 19:24:27 +0300 |
| commit | 21d0a44fb02b7b4c064f5cbc3a0fbfde8161426d (patch) | |
| tree | 6580f0150b617af17bad992e9bca9b60a124dfbd | |
| parent | b482facc9e8f5599cad176885b06bba6eef055d3 (diff) | |
Add http method to JsonAPiSourcePlugin
| -rw-r--r-- | plugins/JsonApiSourcePlugin.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/plugins/JsonApiSourcePlugin.py b/plugins/JsonApiSourcePlugin.py index 5e32d04..c799a05 100644 --- a/plugins/JsonApiSourcePlugin.py +++ b/plugins/JsonApiSourcePlugin.py @@ -12,6 +12,7 @@ class Plugin(PluginInterface): def __init__(self, id: str, params: Params) -> None: super().__init__("JsonApiSourcePlugin", id, params) self.url: str = get_config(params, "url").strip("/") + self.method: str = get_config_or_default(params, "method", "get").strip().tolower() self.selector_post: str = get_config(params, "selector_post") self.selector_title: str | None = get_config_or_default( params, "selector_title", None @@ -53,7 +54,8 @@ class Plugin(PluginInterface): result_items: list[Item] = [] with requests.session() as session: - api_resp = session.get(self.url, allow_redirects=True) + fetch_fn = getattr(session, self.method) + api_resp = fetch_fn(self.url, allow_redirects=True) data = json.loads(api_resp.text) post_items = eval(self.selector_post, {"data": data}) |
