diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2022-11-09 17:01:24 +0900 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2022-11-09 17:01:24 +0900 |
commit | fbbf13e2d6274c14b9d91d59248bb7d6f3833a84 (patch) | |
tree | 82e55d1970a3a6b2cb48b22606c1c26a2fa09448 /src/fead.py | |
parent | f10c6aa32650b58a4d69a71bedfc39f6d76699dd (diff) | |
download | fead-fbbf13e2d6274c14b9d91d59248bb7d6f3833a84.tar.gz |
Fallback Atom feed's link
RFC 4287 does not require atom:feed to contain a <link rel="alternate">.
Diffstat (limited to 'src/fead.py')
-rwxr-xr-x | src/fead.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/fead.py b/src/fead.py index 21f559d..d1ad794 100755 --- a/src/fead.py +++ b/src/fead.py @@ -16,7 +16,7 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. __doc__ = 'Advert generator from web feeds' -__version__ = '0.1.1' +__version__ = '0.1.2' from argparse import ArgumentParser, FileType, HelpFormatter from asyncio import gather, open_connection, run @@ -123,7 +123,7 @@ def parse_atom_entry(xml): return title, link, time, summary -def parse_atom(xml, title): +def parse_atom(xml, title, link): """Parse given Atom feed.""" entries = [] for child in xml: @@ -167,7 +167,8 @@ async def fetch(raw_url): assert xml[0].tag == 'channel' src_title, src_link, items = parse_rss(xml[0], url.hostname) elif xml.tag.endswith('Atom}feed'): - src_title, src_link, items = parse_atom(xml, url.hostname) + src_title, src_link, items = parse_atom(xml, url.hostname, + raw_url) else: raise ValueError(f'unsupported feed format at {raw_url}') return (Advert(src_title, urljoin(raw_url, src_link), |