refactor aspect ratio parsing
This commit is contained in:
parent
4905a8e48d
commit
5ae5bd3a84
1 changed files with 12 additions and 1 deletions
|
@ -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</td>.*?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',
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue