Feed date scraper for Gemini (protocol)
Url checking: only check gemini urls
Zach DeCook 2021-02-15
parent ccd4b73 · commit 05990f5
-rwxr-xr-xzachwalk.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/zachwalk.py b/zachwalk.py
index b45d333..a270850 100755
--- a/zachwalk.py
+++ b/zachwalk.py
@@ -55,15 +55,19 @@ def replaceDateIfNewer(desc, newestdate):
def main():
for line in fileinput.input(): #stdin or file from argv
if line[0:2] == '=>':
- # plz don't use multiple spaces.
- url = line.split(' ')[1]
+ # plz don't use multiple spaces.
+ url = line.split(' ')[1]
+ if isAbsGeminiUrl(url):
desc = getdesc(line)
olddate = gnd(url)
newestdate = getnewestdate(url)
desc = replaceDateIfNewer(desc, newestdate)
print(f'=> {url} {desc}')
- else:
- print(line.rstrip())
+ continue
+ print(line.rstrip())
+
+def isAbsGeminiUrl(url):
+ return url[0:9] == 'gemini://'
def getdesc(line):
return ' '.join(line.split(' ')[2:]).strip()