summaryrefslogtreecommitdiff
path: root/scrap/main.py
blob: eda213a291f61e95f86d735ccb8ca6df54590d63 (plain)
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
from albums import album_data
import api
import parser
import database


def start():
    print("downloading data...")
    api.download_albums(album_data)

    print("uploading data...")
    database.setup()
    upload_albums(
        get_album_data(),
        get_artist_names()
    )
    database.close()
    print("upload finished!")
    print("remember to move the covers directory once you're done")


def upload_albums(album_data, artist_names):
    database.process_artists(artist_names)
    database.process_albums(album_data)


def get_album_data():
    album_data = []
    artist_id = 0

    for artist in album_data:
        artist_id += 1

        for album in artist[1]:
            album_data.append(parser.process_json_file(album, artist_id))

    return album_data


def get_artist_names():
    artist_data = []
    [artist_data.append(
        artist[0]
    ) for artist in album_data]
    return artist_data


start()