From 6498bf9c484867833706d6c3f87aa444441d8921 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Date: Mon, 8 Jun 2020 01:48:02 -0400 Subject: [PATCH] Chequeo user agents en _do_request --- fetcher/musicbrainz.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fetcher/musicbrainz.py b/fetcher/musicbrainz.py index f0adf96..cd6e95c 100644 --- a/fetcher/musicbrainz.py +++ b/fetcher/musicbrainz.py @@ -28,6 +28,8 @@ def _do_request(url): """ if not url: raise ValueError('URL cant be empty') + if not HEADERS['user-agent']: + raise ValueError('User Agent isn\'t set') _log.info('Doing request to "%s" with headers %s', url, HEADERS) response = requests.get(url, headers=HEADERS) @@ -52,9 +54,6 @@ def _do_request_mb(url): :return: The dictionary with the response or the status and his an error message """ - if not HEADERS['user-agent']: - raise ValueError('User Agent isn\'t set') - response = _do_request(url) if response.status_code == 200: @@ -79,8 +78,6 @@ def _do_request_ca(url): :raises ValueError when user-agent isn't set :return: The dictionary with the response or the status and his an error message """ - if not HEADERS['user-agent']: - raise ValueError('User Agent isn\'t set') response = _do_request(url)