From 8bdcd8f386ae9db4106ec4c0e2a766aec9b72be0 Mon Sep 17 00:00:00 2001 From: Nesswit Date: Thu, 4 May 2023 16:01:52 +0900 Subject: [PATCH] Add `mode` option --- README.md | 6 ++++-- morss/cli.py | 1 + morss/morss.py | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 99b1e25..8e0f613 100644 --- a/README.md +++ b/README.md @@ -395,8 +395,8 @@ usage: morss [-h] [--post STRING] [--xpath XPATH] [--indent] [--cache] [--force] [--proxy] [--order {first,last,newest,oldest}] [--firstlink] [--resolve] [--items XPATH] [--item_link XPATH] [--item_title XPATH] - [--item_content XPATH] [--item_time XPATH] [--nolink] [--noref] - [--silent] + [--item_content XPATH] [--item_time XPATH] + [--mode {xml,html,json}] [--nolink] [--noref] [--silent] url Get full-text RSS feeds @@ -440,6 +440,8 @@ custom feeds: --item_content XPATH entry's content --item_time XPATH entry's date & time (accepts a wide range of time formats) + --mode {xml,html,json} + parser to use for the custom feeds misc: --nolink drop links, but keeps links' inner text diff --git a/morss/cli.py b/morss/cli.py index 8a4a389..db970df 100644 --- a/morss/cli.py +++ b/morss/cli.py @@ -54,6 +54,7 @@ def cli_app(): group.add_argument('--item_title', action='store', type=str, metavar='XPATH', help='entry\'s title') group.add_argument('--item_content', action='store', type=str, metavar='XPATH', help='entry\'s content') group.add_argument('--item_time', action='store', type=str, metavar='XPATH', help='entry\'s date & time (accepts a wide range of time formats)') + group.add_argument('--mode', default=None, choices=('xml', 'html', 'json'), help='parser to use for the custom feeds') group = parser.add_argument_group('misc') group.add_argument('--nolink', action='store_true', help='drop links, but keeps links\' inner text') diff --git a/morss/morss.py b/morss/morss.py index c73d2ca..7a080a1 100644 --- a/morss/morss.py +++ b/morss/morss.py @@ -287,6 +287,9 @@ def FeedFetch(url, options): ruleset['items'] = options.items + if options.mode: + ruleset['mode'] = options.mode + ruleset['title'] = options.get('title', '//head/title') ruleset['desc'] = options.get('desc', '//head/meta[@name="description"]/@content')