diff --git a/sok/management/commands/dblptex.py b/sok/management/commands/dblptex.py index ed7c7b8..85890b8 100644 --- a/sok/management/commands/dblptex.py +++ b/sok/management/commands/dblptex.py @@ -1,6 +1,6 @@ import requests -from django.core.management.base import BaseCommand, CommandParser +from django.core.management.base import BaseCommand, CommandError, CommandParser import sok.management.commands.dblpimport as dblp @@ -17,4 +17,10 @@ class Command(BaseCommand): url = f'https://dblp.uni-trier.de/rec/{key}.bib?param=0' response = requests.get(url) response.raise_for_status + + # The status does not necessarily indicate success, but returns an error + # page instead. + if 'application/x-bibtex' not in response.headers['Content-Type']: + raise CommandError(url) + self.stdout.write(response.content.decode())