Skip to content

Commit 7bd4ba5

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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 'English'
4552

4653

4754
def _extract_shelves(shelves, take):

0 commit comments

Comments
 (0)