diff --git a/ox/web/imdb.py b/ox/web/imdb.py index c8e909b..db0a700 100644 --- a/ox/web/imdb.py +++ b/ox/web/imdb.py @@ -64,6 +64,17 @@ def zebra_table(label, more=None, type='string'): conditions['re'] += more return conditions +def parse_aspectratio(value): + r = value + if ':' in value: + r = value.split(':') + n = r[0] + d = r[1].strip().split(' ')[0] + try: + value = str(float(n) / float(d)) + except: + print('failed to parse aspect: %s' % value) + return value ''' 'posterIds': { @@ -94,7 +105,7 @@ class Imdb(SiteParser): 'page': 'reference', 're': [ 'Aspect Ratio.*?ipl-inline-list__item">\s+([\d\.\:\ ]+)', - lambda r: str(float(r.split(':')[0])/float(r.split(':')[1].split(' ')[0])) if ':' in r else r, + parse_aspectratio, ], 'type': 'float', },