Handle users with extensions but no label

Fixes #559
This commit is contained in:
JustAnotherArchivist
2022-10-16 21:13:46 +00:00
parent 59abeaf04c
commit 46a603053c

View File

@@ -1364,7 +1364,7 @@ class _TwitterAPIScraper(snscrape.base.Scraper):
kwargs['link'] = TextLink(text = entity.get('display_url'), url = entity.get('expanded_url', user['url']), tcourl = user['url'], indices = tuple(entity['indices']))
kwargs['profileImageUrl'] = user['profile_image_url_https']
kwargs['profileBannerUrl'] = user.get('profile_banner_url')
if 'ext' in user and (label := user['ext']['highlightedLabel']['r']['ok'].get('label')):
if 'ext' in user and 'highlightedLabel' in user['ext'] and (label := user['ext']['highlightedLabel']['r']['ok'].get('label')):
kwargs['label'] = self._user_label_to_user_label(label)
return User(**kwargs)