get rid of u string literal
This commit is contained in:
parent
d03a6b120d
commit
99e221095b
7 changed files with 98 additions and 98 deletions
|
|
@ -13,13 +13,13 @@ def get_id(url):
|
|||
def get_data(id):
|
||||
'''
|
||||
>>> get_data('129689')['cast'][1][1]
|
||||
u'Marianne'
|
||||
'Marianne'
|
||||
>>> get_data('129689')['credits'][0][0]
|
||||
u'Jean-Luc Godard'
|
||||
'Jean-Luc Godard'
|
||||
>>> get_data('129689')['posters'][0]
|
||||
u'http://image.allmusic.com/00/adg/cov200/dru800/u812/u81260bbffr.jpg'
|
||||
'http://image.allmusic.com/00/adg/cov200/dru800/u812/u81260bbffr.jpg'
|
||||
>>> get_data('129689')['rating']
|
||||
u'4.5'
|
||||
'4.5'
|
||||
'''
|
||||
if id.startswith('http'):
|
||||
id = get_id(id)
|
||||
|
|
|
|||
|
|
@ -19,18 +19,18 @@ def get_data(id, language='en'):
|
|||
if 'Willkommen in der Datenbank des Arsenal' in html:
|
||||
return None
|
||||
data = {}
|
||||
data[u'id'] = id
|
||||
data[u'url'] = url
|
||||
data['id'] = id
|
||||
data['url'] = url
|
||||
m = re.compile('<h1>(.*?)</h1>').findall(html)
|
||||
if m:
|
||||
data[u'title'] = m[0]
|
||||
data['title'] = m[0]
|
||||
m = re.compile("<b>Director: </b><a href='.*?'>(.*?)</a>").findall(html)
|
||||
if m:
|
||||
data[u'director'] = m[0]
|
||||
data['director'] = m[0]
|
||||
|
||||
m = re.compile("caUI.initImageScroller\(\[\{url:'(.*?)'").findall(html)
|
||||
if m:
|
||||
data[u'image'] = m[0]
|
||||
data['image'] = m[0]
|
||||
|
||||
units = re.compile("<div class='unit'>(.*?)</div>", re.DOTALL).findall(html)
|
||||
for x in map(re.compile('<b>(.*?)</b>: (.*)', re.DOTALL).findall, units):
|
||||
|
|
@ -43,7 +43,7 @@ def get_data(id, language='en'):
|
|||
else:
|
||||
data[key] = strip_tags(data[key])
|
||||
if "running time (minutes)" in data:
|
||||
data[u'runtime'] = float(data.pop("running time (minutes)").replace(',', '.')) * 60
|
||||
data['runtime'] = float(data.pop("running time (minutes)").replace(',', '.')) * 60
|
||||
for key in ('year', 'length in metres', 'forum participation year', 'number of reels'):
|
||||
if key in data and data[key].isdigit():
|
||||
data[key] = int(data[key])
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ def get_url(id):
|
|||
def get_data(id, timeout=ox.cache.cache_timeout, get_imdb=False):
|
||||
'''
|
||||
>>> get_data('1333').get('imdbId')
|
||||
u'0060304'
|
||||
'0060304'
|
||||
|
||||
>>> get_data('236')['posters'][0]
|
||||
u'http://s3.amazonaws.com/criterion-production/release_images/1586/ThirdManReplace.jpg'
|
||||
'http://s3.amazonaws.com/criterion-production/release_images/1586/ThirdManReplace.jpg'
|
||||
|
||||
>>> get_data('786')['posters'][0]
|
||||
u'http://s3.amazonaws.com/criterion-production/product_images/185/343_box_348x490.jpg'
|
||||
'http://s3.amazonaws.com/criterion-production/product_images/185/343_box_348x490.jpg'
|
||||
'''
|
||||
data = {
|
||||
"id": id,
|
||||
|
|
@ -39,7 +39,7 @@ def get_data(id, timeout=ox.cache.cache_timeout, get_imdb=False):
|
|||
data["number"] = find_re(html, "<b>Spine #(\d+)")
|
||||
|
||||
data["title"] = decode_html(find_re(html, "<h1 class=\"header__primarytitle\".*?>(.*?)</h1>"))
|
||||
data["title"] = data["title"].split(u' \u2014 The Television Version')[0].strip()
|
||||
data["title"] = data["title"].split(' \u2014 The Television Version')[0].strip()
|
||||
results = find_re(html, '<ul class="film-meta-list">(.*?)</ul>')
|
||||
info = re.compile('<li itemprop="(.*?)".*?>(.*?)</li>', re.DOTALL).findall(results)
|
||||
info = {k: strip_tags(v).strip() for k, v in info}
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ def get_data(id, timeout=-1):
|
|||
def get_id(url=None, imdb=None):
|
||||
'''
|
||||
>>> get_id(imdb='0133093')
|
||||
u'the-matrix'
|
||||
'the-matrix'
|
||||
|
||||
#>>> get_id(imdb='0060304')
|
||||
#u'2-or-3-things-i-know-about-her'
|
||||
#'2-or-3-things-i-know-about-her'
|
||||
'''
|
||||
if imdb:
|
||||
i = ImdbCombined(imdb)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue