-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_creators.py
47 lines (34 loc) · 1008 Bytes
/
get_creators.py
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
import argparse
import json
import musicbrainzngs as mb
mb.set_useragent('TROMPA', '0.1')
def lookup_artists(artists):
for a in artists:
print(a)
lookup_composer(a)
def lookup_composer(composer):
work = mb.search_artists(artist=composer)
print(work)
def process_file(fname):
artists = set()
with open(fname) as fp:
data = json.load(fp)
for k, work in data.items():
composer = work["Creator"]
if not composer:
print(work)
else:
artists.add(composer)
return artists
def main(inputfiles):
artists = set()
for f in inputfiles:
file_artists = process_file(f)
artists.update(file_artists)
print("processing %s artists" % len(artists))
lookup_artists(list(artists))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('inputfile', nargs='+', help='Json data files to import')
args = parser.parse_args()
main(args.inputfile)