Feed date scraper for Gemini (protocol)
description parsing: split at colon
Zach DeCook 2021-02-17
parent 05990f5 · commit 84f4b0b
-rwxr-xr-xtest_zachwalk.py1
-rwxr-xr-xzachwalk.py2
2 files changed, 2 insertions, 1 deletions
diff --git a/test_zachwalk.py b/test_zachwalk.py
index 3cbf5b2..42efc43 100755
--- a/test_zachwalk.py
+++ b/test_zachwalk.py
@@ -8,6 +8,7 @@ def main():
assert zachwalk.gnd([b'=> path.gmi 2021-01-31 - my post']) == parse('2021-01-31').date()
assert zachwalk.gnd([b'=> 2020/11/25/hello-gemini.gmi 2020-11-25 - Hello, Gemini!']) == parse('2020-11-25').date()
assert zachwalk.gnd([b'=> gemini://drewdevault.com/2020/09/21/Gemini-TOFU.gmi September 21, 2020: TOFU recommendations for Gemini']) == parse('2020-09-21').date()
+ assert zachwalk.gnd(['=> gemini://drewdevault.com/2021/02/15/Status-update-February-2021.gmi February 15, 2021: Status update, February 2021']) == parse('2021-02-15').date()
if __name__ == '__main__':
main()
diff --git a/zachwalk.py b/zachwalk.py
index a270850..1a15ddc 100755
--- a/zachwalk.py
+++ b/zachwalk.py
@@ -34,7 +34,7 @@ def gnd(fp):
if line.strip()[0:2] == '=>':
try:
desc =getdesc(line)
- desc=desc.replace(':',' :') #quirk for parse on drew's capsule
+ desc=desc.split(':')[0] #this should only have 1 'datey' part
date = parse(desc,fuzzy=True).date()
# todo: read lots of these and compare them
return date