# HG changeset patch # User Henry S. Thompson # Date 1692621427 -3600 # Node ID 120d90b47d74a37f7a5aadbe0a622758b62d6652 # Parent fef49258d738fc823bd52183e17837b78a449748 include timestamp diff -r fef49258d738 -r 120d90b47d74 bin/lmh_warc.py --- a/bin/lmh_warc.py Sun Aug 20 00:28:43 2023 +0100 +++ b/bin/lmh_warc.py Mon Aug 21 13:37:07 2023 +0100 @@ -2,22 +2,32 @@ import re,warc,sys TUPAT=re.compile(b'^WARC-Target-URI: (.*?)\r',re.MULTILINE) +DPAT=re.compile(b'^WARC-Date: (.*?)\r',re.MULTILINE) LMPAT=re.compile(b'^Last-Modified: (.*?)\r',re.MULTILINE) +DTAB=bytearray(range(256)) +DDEL=b'TZ-:' + OUT=open(sys.stdout.fileno(),'wb') def showmeLMH(wtype,buf,part): - global URI + global URI, DATE if part==1: if (m:=TUPAT.search(buf)): URI=m[1] else: raise ValueError(b"No target URI in %s ??"%buf) + if (md:=DPAT.search(buf)): + DATE=md[1] + else: + raise ValueError(b"No date in %s ??"%buf) else: mm=LMPAT.search(buf) OUT.write(URI) if mm: OUT.write(b'\t') + OUT.write(DATE.translate(DTAB,DDEL)) + OUT.write(b'\t') OUT.write(mm[1]) OUT.write(b'\n')