-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_lyrics.py
51 lines (40 loc) · 1.26 KB
/
get_lyrics.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
'''
Created on Nov 21, 2019
@author: Nikola
'''
from file_handler import FileHandler
import sys, getopt
def run_program(root_directory, overwrite_lyrics):
print('Program started')
handler = FileHandler(overwrite_lyrics=overwrite_lyrics)
handler.read_files_and_add_lyrics(root_directory)
print('Program finished')
def print_help_message():
print('Usage:')
print('\tget_lyrics.py -d <root_directory> [-o]\n')
print('Options:')
print('\t-d\t--dir\t\tTEXT\t\tPath to root directory, from where the program will start scanning for music files.')
print('\t-o\t--overwrite\tOPTIONAL\tOptional parameter, add if you want the program to overwrite existing lyrics.')
def main(argv):
root_directory = ''
overwrite_lyrics = False
try:
opts, args = getopt.getopt(argv,"hd:o:",["dir=","overwrite="])
if len(opts) > 0:
for opt, arg in opts:
if opt in ('-h', "--help"):
print_help_message()
sys.exit()
elif opt in ("-d", "--dir"):
root_directory = arg
elif opt in ("-o", "--overwrite"):
overwrite_lyrics = True
run_program(root_directory, overwrite_lyrics)
else:
print_help_message()
sys.exit(2)
except getopt.GetoptError:
print_help_message()
sys.exit(2)
if __name__ == "__main__":
main(sys.argv[1:])