-
Notifications
You must be signed in to change notification settings - Fork 0
/
rym-parser.py
148 lines (124 loc) · 4.75 KB
/
rym-parser.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import io
import os
#lib for table rendering
from tabulate import tabulate
#lib for .ini file
import configparser
#import all from base_func and stat_func files
from base_functions import *
from stat_functions import *
clear = lambda: os.system('cls')
config = configparser.ConfigParser()
config.read("conf.ini")
#main function
#it contains all commands a user can use in this programm
def main_func():
print("Rate Your Music Parser v {}".format(config['BASIC']['dev_version']))
print("Enter the commands below")
command = ""
global global_album_list
global global_filename
while command != "exit":
print("cmd: ")
command = input()
#basic stats
if command == "basic-stats":
if(global_album_list != 0):
clear()
basic_stats(global_album_list)
#albums spreadsheet
elif command == "album-spreadsheet":
if(global_album_list != 0):
clear()
show_album_spreadsheet(global_album_list, "default")
#albums spreadsheet (best to worst)
elif command == "album-spreadsheet-top":
if(global_album_list != 0):
clear()
show_album_spreadsheet(global_album_list, "top")
#albums spreadsheet (worst to best)
elif command == "album-spreadsheet-bottom":
if(global_album_list != 0):
clear()
show_album_spreadsheet(global_album_list, "bottom")
#albums spreadsheet for a certain year
elif command == "album-spreadsheet-year":
year = input("Input year: ")
if(global_album_list != 0):
clear()
show_album_spreadsheet_by_year(global_album_list, year, "default")
#albums spreadsheet for a certain year (best to worst)
elif command == "album-spreadsheet-year-top":
year = input("Input year: ")
if(global_album_list != 0):
clear()
show_album_spreadsheet_by_year(global_album_list, year, "top")
#artist stats
elif command == "artist-stats":
artist_name = input("Input artist name: ")
clear()
artist_basic_stat(global_album_list, artist_name, "default")
#artist stats with albums best to worst
elif command == "artist-stats-top":
artist_name = input("Input artist name: ")
clear()
artist_basic_stat(global_album_list, artist_name, "top")
#top artists by avg. rating
elif command == "top-artists":
clear()
top_artists(global_album_list)
#top artists by number of ratings
elif command == "top-artists-count":
clear()
top_artists_by_count(global_album_list)
#top years by avg. rating
elif command == "top-years":
clear()
top_years(global_album_list)
#top decades by avg. rating
elif command == "top-decades":
clear()
top_decades(global_album_list)
#change filename with RYM data
elif command == "change-filename":
clear()
print("New file name (with extension): ")
filename = input()
if(change_filename(filename) != 0):
global_filename = change_filename(filename)
global_album_list = load_file(global_filename)
print ("File has been changed! ({})".format(filename))
#change amount of albums for top-art
elif command == "set-top-art":
amount = input("New amount of albums to check: ")
set_amount_for_top_art(amount)
#change amount of albums for top-art
elif command == "set-top-years":
amount = input("New amount of albums to check: ")
set_amount_for_top_years(amount)
#change amount of albums for top-art
elif command == "set-top-decades":
amount = input("New amount of albums to check: ")
set_amount_for_top_decades(amount)
#add new artist name replacement
elif command == "add-art-replace":
old_name = input("Enter the name that should be replaced: ")
new_name = input("Enter the new name: ")
add_artist_for_replace(old_name, new_name)
global_album_list = load_file(global_filename)
#help
elif command == "help":
clear()
help()
#exit the program
elif command == "exit":
break
else:
print("No such command")
global_filename = config['BASIC']['file']
global_album_list = load_file(global_filename)
clear()
#start the main function
main_func()