1
0
Fork 0

Merge pull request #382 from cdvv7788/fallback-read-link

This commit is contained in:
Nick Sweeting 2020-07-22 15:46:41 -04:00 committed by GitHub
commit 36124f2dfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@ __package__ = 'archivebox.index'
import os
import sys
import json as pyjson
from pathlib import Path
from datetime import datetime
from typing import List, Optional, Iterator, Any
@ -49,7 +50,11 @@ def parse_json_main_index(out_dir: str=OUTPUT_DIR) -> Iterator[Link]:
with open(index_path, 'r', encoding='utf-8') as f:
links = pyjson.load(f)['links']
for link_json in links:
yield Link.from_json(link_json)
try:
yield Link.from_json(link_json)
except KeyError:
detail_index_path = Path(OUTPUT_DIR) / ARCHIVE_DIR_NAME / link_json['timestamp']
yield parse_json_link_details(str(detail_index_path))
return ()
@ -150,4 +155,3 @@ def to_json(obj: Any, indent: Optional[int]=4, sort_keys: bool=True, cls=Extende
return pyjson.dumps(obj, indent=indent, sort_keys=sort_keys, cls=ExtendedEncoder)