Skip to content

Commit

Permalink
Catch ValueError in to_int (closes #125)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Dec 18, 2020
1 parent 09a3007 commit 0ab4d41
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ytmusicapi/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0ab4d41

Please sign in to comment.