-
Notifications
You must be signed in to change notification settings - Fork 0
/
mklist-fesfilm-xls
executable file
·61 lines (56 loc) · 1.63 KB
/
mklist-fesfilm-xls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Extract information from spread sheet file received from Ron at
Festival Films.
"""
import xlrd
import json
import movielib
def main():
book = xlrd.open_workbook("fesfilm-imdb-list.xls")
sh = book.sheet_by_index(0)
print("%d x %d" % (sh.nrows, sh.ncols))
fields = []
for colx in range(0, sh.ncols):
cval = sh.cell_value(0, colx)
fields.append(cval)
fieldmap = {
'AAA TITLE' : 'title',
'DATE' : 'year',
'IMDB tt #' : 'imdb',
}
l = {}
for rowx in range(1, sh.nrows):
info = {}
for colx in range(0, sh.ncols):
cval = sh.cell_value(rowx, colx)
field = fields[colx]
if field in fieldmap:
field = fieldmap[field]
info[field] = cval
print(info)
if '' != info['year']:
try:
info['year'] = int(info['year'])
except:
try:
info['year'] = int(info['year'].split(',')[0])
except:
pass
else:
del info['year']
if '' != info['imdb']:
ref = 'http://www.imdb.com/title/' + info['imdb'] + '/'
else:
if 'year' in info:
ref = info['title'] + '-' + str(info['year'])
else:
ref = info['title']
info['status'] = 'free'
info['freenessurl'] = 'n/a'
if info['GENRE'] not in ['GENRE', 'AAA', '']:
l[ref] = info
movielib.savelist(l, name='free-movies-fesfilm-xls.json')
if __name__ == "__main__":
main()