-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmanage.py
More file actions
31 lines (28 loc) · 760 Bytes
/
manage.py
File metadata and controls
31 lines (28 loc) · 760 Bytes
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
import getTitles
import sys
from MediaClass import Media
def print_usage():
print("There is only one option right now:")
print("extract file(optional)")
if __name__ == "__main__":
for i in range(1,len(sys.argv)):
arg = sys.argv[i]
if arg.lower() == "extract":
the_file = None
if i < (len(sys.argv)-1):
the_file = sys.argv[i+1]
i += 2
else:
i += 1
if the_file:
raw_titles = getTitles.get_titles_from_file(the_file)
else:
raw_titles = getTitles.get_titles_from_file()
parsed_titles = getTitles.parse_titles(raw_titles)
for item in parsed_titles:
m = Media()
m.title = item[0]
m.year = item[1]
m.save()
else:
print_usage()