Skip to content

Commit fb5ba59

Browse files
committed
Try a bit harder with Language detection 🏴‍☠️
1 parent 40d22b1 commit fb5ba59

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

pythonbits/goodreads.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ def _extract_author(auth):
4141

4242

4343
def _extract_language(alpha_3):
44-
return pycountry.languages.get(alpha_3=alpha_3).name
44+
try:
45+
return pycountry.languages.get(alpha_3=alpha_3).name
46+
except AttributeError:
47+
try:
48+
return pycountry.languages.get(alpha_2=alpha_3[:2]).name
49+
except AttributeError:
50+
# I give up
51+
return input('Please specify the book\'s Language: ')
4552

4653

4754
def _extract_shelves(shelves, take):

0 commit comments

Comments
 (0)