diff --git a/akarpov/music/services/db.py b/akarpov/music/services/db.py index 6899249..4cd3ba1 100644 --- a/akarpov/music/services/db.py +++ b/akarpov/music/services/db.py @@ -2,7 +2,11 @@ import re import requests -from deep_translator import GoogleTranslator + +try: + from deep_translator import GoogleTranslator # TODO: move to another service +except requests.exceptions.JSONDecodeError: + print("Failed to initialize GoogleTranslator due to external API issues.") from django.core.files import File from django.db import transaction from django.utils.text import slugify diff --git a/akarpov/music/services/info.py b/akarpov/music/services/info.py index 8f2b94b..9177b00 100644 --- a/akarpov/music/services/info.py +++ b/akarpov/music/services/info.py @@ -3,7 +3,11 @@ import requests import spotipy -from deep_translator import GoogleTranslator + +try: + from deep_translator import GoogleTranslator +except requests.exceptions.JSONDecodeError: + print("Failed to initialize GoogleTranslator due to external API issues.") from django.conf import settings from django.core.files import File from django.db import transaction