소스 검색

Work around warcio not writing a block digest for warcinfo records (https://github.com/webrecorder/warcio/issues/87)

The length has to be set manually because otherwise warcio will automatically remove the header again.
tags/v0.2.0
JustAnotherArchivist 4 년 전
부모
커밋
f14a664b1c
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. +6
    -2
      qwarc/warc.py

+ 6
- 2
qwarc/warc.py 파일 보기

@@ -88,11 +88,15 @@ class WARC:
},
'extra': self._specDependencies.extra,
}
payload = io.BytesIO(json.dumps(data, indent = 2).encode('utf-8'))
digester = warcio.utils.Digester('sha1')
digester.update(payload.getvalue())
record = self._warcWriter.create_warc_record(
'urn:X-qwarc:warcinfo',
'warcinfo',
payload = io.BytesIO(json.dumps(data, indent = 2).encode('utf-8')),
warc_headers_dict = {'Content-Type': 'application/json; charset=utf-8'},
payload = payload,
warc_headers_dict = {'Content-Type': 'application/json; charset=utf-8', 'WARC-Block-Digest': str(digester)},
length = len(payload.getvalue()),
)
self._warcWriter.write_record(record)
return record.rec_headers.get_header('WARC-Record-ID')


불러오는 중...
취소
저장