From 87ec6c1b5ae5c7dd6e896fc2965a81248a5f7171 Mon Sep 17 00:00:00 2001 From: pseusys Date: Thu, 2 Feb 2023 11:09:11 +0100 Subject: [PATCH] private profile info hidden -> error fixed --- main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 2cfd14d..f6577eb 100644 --- a/main.py +++ b/main.py @@ -442,10 +442,10 @@ def get_short_info(github): else: disk_usage = humanize.naturalsize(user_info.disk_usage) request = requests.get('https://github-contributions.vercel.app/api/v1/' + user_info.login) - if request.status_code == 200: - data = request.json() - total = data['years'][0]['total'] - year = data['years'][0]['year'] + if request.status_code == 200 and len(request.json()['years']) > 0: + this_year_data = request.json()['years'][0] + total = this_year_data['total'] + year = this_year_data['year'] string += '> 🏆 ' + translate['Contributions in the year'] % (humanize.intcomma(total), year) + '\n > \n' string += '> 📦 ' + translate["Used in GitHub's Storage"] % disk_usage + ' \n > \n'