commit cd4e2fcd157e35dc721dcd8279d144c34e690627 from: Aleksey Ryndin date: Tue Jan 21 20:40:15 2025 UTC Fix: use urljoin commit - 4b13045172da61f343703da08f5a86bc74de2b64 commit + cd4e2fcd157e35dc721dcd8279d144c34e690627 blob - d2323f0f665bcc0bbdce2d037cafcc38dc807bf9 blob + f8f591978487610ca7ea8a29c3c6eb41bc023484 --- capsule/vostok/atom2gemfeed.py +++ capsule/vostok/atom2gemfeed.py @@ -57,8 +57,6 @@ def _main(raw_url): print(f"43 Only links to `text/*` are allowed: {mime}\r") return - # gemini://geminiprotocol.net/docs/companion/subscription.gmi - m = Message() m['content-type'] = mime root = {} @@ -81,26 +79,21 @@ def _main(raw_url): _, _, tag = child.tag.rpartition('}') entry_dict[tag] = child.text if tag == "link" and child.attrib.get("rel") == "alternate": - gemini_link = child.attrib.get("href") + gemini_link = urljoin(raw_url, child.attrib.get("href", "")) if not _is_gemini_link(gemini_link): - gemini_link = entry_dict.get("id") - if not _is_gemini_link(gemini_link): continue - entry_date = "" - updated = entry_dict.get("updated") - if updated: - try: - entry_date = ( - datetime.fromisoformat(updated) - .date().strftime("%Y-%m-%d - ") - ) - except ValueError: - pass + try: + entry_date = ( + datetime.fromisoformat(entry_dict.get("updated", "")) + .date().strftime("%Y-%m-%d - ") + ) + except ValueError: + entry_date = "" - print(f"=> {gemini_link} {entry_date}{entry_dict.get('title') or ''}\r") + print(f"=> {gemini_link} {entry_date}{entry_dict.get('title') or gemini_link}\r") return