From fc7769c4cb88cd436c0a7866badce78daa8cf366 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 2 May 2018 11:00:55 +0200 Subject: [PATCH] more aspectratio issues, wrap delete_url --- ox/web/imdb.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ox/web/imdb.py b/ox/web/imdb.py index db0a700..b28bf2b 100644 --- a/ox/web/imdb.py +++ b/ox/web/imdb.py @@ -18,12 +18,21 @@ from . import duckduckgo from ..utils import datetime from ..geo import normalize_country_name -def read_url(url, data=None, headers=cache.DEFAULT_HEADERS, timeout=cache.cache_timeout, valid=None, unicode=False): + +def prepare_url(url, data=None, headers=cache.DEFAULT_HEADERS, timeout=cache.cache_timeout, valid=None, unicode=False): headers = headers.copy() # https://webapps.stackexchange.com/questions/11003/how-can-i-disable-reconfigure-imdbs-automatic-geo-location-so-it-does-not-defau headers['X-Forwarded-For'] = '72.21.206.80' + return url, data, headers, timeout, unicode + +def read_url(url, data=None, headers=cache.DEFAULT_HEADERS, timeout=cache.cache_timeout, valid=None, unicode=False): + url, data, headers, timeout, unicode = prepare_url(url, data, headers, timeout, valid, unicode) return cache.read_url(url, data, headers, timeout, unicode=unicode) +def delete_url(url, data=None, headers=cache.DEFAULT_HEADERS): + url, data, headers, timeout, unicode = prepare_url(url, data, headers) + cache.store.delete(url, data, headers) + def get_url(id): return "http://www.imdb.com/title/tt%s/" % id @@ -74,6 +83,8 @@ def parse_aspectratio(value): value = str(float(n) / float(d)) except: print('failed to parse aspect: %s' % value) + else: + value = '.'.join(value.strip().split('.')[:2]) return value '''