diff options
| author | Zach DeCook <zachdecook@librem.one> | 2021-02-07 22:28:28 -0500 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2021-02-07 22:28:28 -0500 |
| commit | aea9eb5be60f2274ab4af702e3e8b1572244a18e (patch) | |
| tree | 3971efa7b5be1e9666af158db47e4635f57dc560 /zachwalk.py | |
| parent | a77672feb90517865f0c2bf9a85482176881635c (diff) | |
| download | zachwalk-aea9eb5be60f2274ab4af702e3e8b1572244a18e.tar.gz | |
getnewestdate: split into a tustable segment
Diffstat (limited to 'zachwalk.py')
| -rwxr-xr-x | zachwalk.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/zachwalk.py b/zachwalk.py index 9584cef..7965962 100755 --- a/zachwalk.py +++ b/zachwalk.py @@ -6,6 +6,8 @@ import socket import ssl from dateutil.parser import parse +DEFAULT = '1970-01-01' + def getnewestdate(url): """load the url, and find the newest date listed in a link""" # TODO: outsource to pre-installed cli program? @@ -21,6 +23,8 @@ def getnewestdate(url): header = fp.readline() header = header.decode("UTF-8").strip() # TODO: something special if status is not 2x + return gnd(fp) +def gnd(fp): for line in fp: line=line.decode('UTF-8') if line.strip()[0:2] == '=>': @@ -30,7 +34,7 @@ def getnewestdate(url): return date except: pass - return '1970-01-01' + return DEFAULT def main(argv): with open(argv[1]) as f: |
