Skip to content

Commit

Permalink
only start parsing json after the first open brace
Browse files Browse the repository at this point in the history
  • Loading branch information
pirate committed Sep 4, 2023
1 parent eb97fd4 commit aaca74f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions archivebox/parsers/generic_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ def parse_generic_json_export(json_file: IO[str], **_kwargs) -> Iterable[Link]:
"""Parse JSON-format bookmarks export files (produced by pinboard.in/export/, or wallabag)"""

json_file.seek(0)
next(json_file)
links = json.load(json_file)

# sometimes the first line is a comment or filepath, so we get everything after the first {
json_file_json_str = '{' + json_file.read().split('{', 1)[-1]
links = json.loads(json_file_json_str)
json_date = lambda s: datetime.strptime(s, '%Y-%m-%dT%H:%M:%S%z')

for link in links:
Expand Down

0 comments on commit aaca74f

Please sign in to comment.