-
Notifications
You must be signed in to change notification settings - Fork 2
/
mb_import.py
46 lines (30 loc) · 1.12 KB
/
mb_import.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
import argparse
import musicbrainzngs as mb
from cequery.connection import submit_query
from cequery import person
mb.set_useragent('TROMPA', '0.1')
def transform_mb_artist_to_gql(artist):
pass
def transform_mb_work_to_gql(work):
pass
def import_artist(artist_mbid):
artist = mb.get_artist_by_id(artist_mbid, includes=["url-rels"])["artist"]
query = artist.transform_musicbrainz_artist(artist)
submit_query(query)
def import_work(work_mbid):
work = mb.get_artist_by_id(work_mbid, includes=["url-rels"])["work"]
query = person.transform_work(work)
print(work)
submit_query(query)
def main(artist_mbid=None, work_mbid=None):
if artist_mbid:
import_artist(artist_mbid)
elif work_mbid:
import_work(work_mbid)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--artist', '-a', required=False, help='Artist MBID to import')
group.add_argument('--work', '-w', required=False, help='Work MBID to import')
args = parser.parse_args()
main(args.artist, args.work)