From bf5e88c3cf4c316180c6fed0cce6e39b00d3883a Mon Sep 17 00:00:00 2001 From: Okky Mabruri <57498478+okkymabruri@users.noreply.github.com> Date: Sat, 26 Mar 2022 09:04:00 +0700 Subject: [PATCH] fix - KeyError: 'profile_banner_url' refer to twintproject/twint#1329 --- twint/user.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/twint/user.py b/twint/user.py index 6fb1e58..9391451 100644 --- a/twint/user.py +++ b/twint/user.py @@ -28,6 +28,9 @@ def User(ur): _usr.username = ur['data']['user']['legacy']['screen_name'] _usr.bio = ur['data']['user']['legacy']['description'] _usr.location = ur['data']['user']['legacy']['location'] + _usr.url = "" + if 'url' in ur['data']['user']['legacy']: + _usr.url = ur['data']['user']['legacy']['url'] _usr.url = ur['data']['user']['legacy']['url'] # parsing date to user-friendly format _dt = ur['data']['user']['legacy']['created_at'] @@ -46,7 +49,9 @@ def User(ur): _usr.is_private = ur['data']['user']['legacy']['protected'] _usr.is_verified = ur['data']['user']['legacy']['verified'] _usr.avatar = ur['data']['user']['legacy']['profile_image_url_https'] - _usr.background_image = ur['data']['user']['legacy']['profile_banner_url'] + _usr.background_image = "" + if 'profile_banner_url' in ur['data']['user']['legacy']: + _usr.background_image = ur['data']['user']['legacy']['profile_banner_url'] # TODO : future implementation # legacy_extended_profile is also available in some cases which can be used to get DOB of user return _usr