From 7d3401ff9fef3e59a40e5dc6db8b323424a2191c Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sun, 6 Apr 2014 17:38:56 +0200 Subject: [PATCH] Bugfixes --- headphones/helpers.py | 8 ++++---- headphones/searcher.py | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/headphones/helpers.py b/headphones/helpers.py index 3b614a68..b18cda6b 100644 --- a/headphones/helpers.py +++ b/headphones/helpers.py @@ -609,12 +609,12 @@ def request_response(url, method="get", auto_raise=True, whitelist_status_code=N whitelist_status_code = [whitelist_status_code] # Map method to the request.XXX method. This is a simple hack, but it allows - # requests to apply more magic per method. See it's source. - request_method = requests[method.lower()] + # requests to apply more magic per method. See lib/requests/api.py. + request_method = getattr(requests, method) try: # Request the URL - logger.debug("Requesting URL via %s method: %s", method, url) + logger.debug("Requesting URL via %s method: %s", method.upper(), url) response = request_method(url, **kwargs) # If status code != OK, then raise exception, except if the status code @@ -649,7 +649,7 @@ def request_soup(url, **kwargs): response = request_response(url, **kwargs) if response is not None: - return BeautifulSoup(response.content) + return BeautifulSoup(response.content, "html5lib") def request_minidom(url, **kwargs): """ diff --git a/headphones/searcher.py b/headphones/searcher.py index 3346a1c0..ed225dce 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -1133,10 +1133,9 @@ def searchTorrent(album, new=False, losslessOnly=False): timeout=20 ) - # Process feed + # Process content if data: - table = data.find('table') - rows = table.findAll('tr') + rows = data.select('table tr') if not rows or len(rows) == '1': logger.info(u"No results found from %s for %s" % (provider, term))