Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/gmaps_scraper/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def _extract_additional_list_header_owners(node: list[JSONValue]) -> list[ListOw
seen: set[tuple[str, str | None, str | None]] = set()

for index, value in enumerate(node):
if index in {3, 8}:
if index in {0, 3, 8}:
continue
for current, _ in _walk_json(value):
owner = _parse_list_owner(current)
Expand Down Expand Up @@ -375,7 +375,7 @@ def _merge_owner_lists(


def _parse_list_owner(node: JSONValue | None) -> ListOwner | None:
if not isinstance(node, list) or len(node) < 1 or len(node) > 3:
if not isinstance(node, list) or len(node) < 1:
return None

name = _clean_text(_safe_index(node, 0))
Expand Down
36 changes: 36 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,42 @@ def test_accepts_name_only_owner_records(self) -> None:
{"name": "Name Only Collaborator"},
)

def test_accepts_owner_records_with_extra_fields(self) -> None:
runtime_state = copy.deepcopy(["noise", _LIST_NODE])
runtime_state[1][3] = [
"Extra Field Owner",
"https://lh3.googleusercontent.com/a-/extra-field-owner",
"104356373423434804635",
"ignored_extra_field",
]
second_place = runtime_state[1][8][1]
assert isinstance(second_place, list)
second_place[12] = [
"Extra Field Collaborator",
"https://lh3.googleusercontent.com/a-/extra-field-collaborator",
"205678901234567890123",
"another_ignored_field",
]

parsed = parse_saved_list_artifacts(_LIST_URL, runtime_state=runtime_state)

self.assertEqual(
parsed.owner.to_dict() if parsed.owner else None,
{
"name": "Extra Field Owner",
"photo_url": "https://lh3.googleusercontent.com/a-/extra-field-owner",
"profile_id": "104356373423434804635",
},
)
self.assertEqual(
parsed.places[1].added_by.to_dict() if parsed.places[1].added_by else None,
{
"name": "Extra Field Collaborator",
"photo_url": "https://lh3.googleusercontent.com/a-/extra-field-collaborator",
"profile_id": "205678901234567890123",
},
)

def test_filters_sparse_owner_from_collaborators(self) -> None:
runtime_state = copy.deepcopy(["noise", _LIST_NODE])
first_place = runtime_state[1][8][0]
Expand Down