Skip to content

Commit

Permalink
Try a bit harder with Language detection 🏴‍☠️
Browse files Browse the repository at this point in the history
  • Loading branch information
znedw committed Oct 20, 2020
1 parent 40d22b1 commit fb5ba59
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pythonbits/goodreads.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ def _extract_author(auth):


def _extract_language(alpha_3):
return pycountry.languages.get(alpha_3=alpha_3).name
try:
return pycountry.languages.get(alpha_3=alpha_3).name
except AttributeError:
try:
return pycountry.languages.get(alpha_2=alpha_3[:2]).name
except AttributeError:
# I give up
return input('Please specify the book\'s Language: ')


def _extract_shelves(shelves, take):
Expand Down

0 comments on commit fb5ba59

Please sign in to comment.