From 0ab4d41e9d4a9f0993309c9f933f671888ad9401 Mon Sep 17 00:00:00 2001 From: sigma67 Date: Fri, 18 Dec 2020 12:43:44 +0100 Subject: [PATCH] Catch ValueError in to_int (closes #125) --- ytmusicapi/helpers.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ytmusicapi/helpers.py b/ytmusicapi/helpers.py index 47dd1ead..786a4e9f 100644 --- a/ytmusicapi/helpers.py +++ b/ytmusicapi/helpers.py @@ -67,8 +67,13 @@ def get_authorization(auth): def to_int(string): - number = string.split(' ')[0] - return locale.atoi(number) + number_string = string.split(' ')[0] + try: + int_value = locale.atoi(number_string) + except ValueError: + number_string = number_string.replace(',', '') + int_value = int(number_string) + return int_value def i18n(method):