more aspectratio issues, wrap delete_url

This commit is contained in:
j 2018-05-02 11:00:55 +02:00
parent 5ae5bd3a84
commit fc7769c4cb

View file

@ -18,12 +18,21 @@ from . import duckduckgo
from ..utils import datetime from ..utils import datetime
from ..geo import normalize_country_name 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() headers = headers.copy()
# https://webapps.stackexchange.com/questions/11003/how-can-i-disable-reconfigure-imdbs-automatic-geo-location-so-it-does-not-defau # 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' 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) 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): def get_url(id):
return "http://www.imdb.com/title/tt%s/" % id return "http://www.imdb.com/title/tt%s/" % id
@ -74,6 +83,8 @@ def parse_aspectratio(value):
value = str(float(n) / float(d)) value = str(float(n) / float(d))
except: except:
print('failed to parse aspect: %s' % value) print('failed to parse aspect: %s' % value)
else:
value = '.'.join(value.strip().split('.')[:2])
return value return value
''' '''