-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyflex
More file actions
executable file
·61 lines (52 loc) · 1.64 KB
/
Copy pathpyflex
File metadata and controls
executable file
·61 lines (52 loc) · 1.64 KB
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
#!/usr/bin/env python
import re
import os
from sys import argv
from optparse import OptionParser
flexlog_file = '/home/chris/.flexget/flexget.log'
downloaded_array = []
color_list = []
parser = OptionParser()
parser.add_option('-d', '--delete',
help='delte flexget.log file',
action="store_true",
dest='delete_log',
default=False)
(opts, args) = parser.parse_args()
if opts.delete_log == True:
try:
os.remove(flexlog_file)
print("\033[33m%s has been removed.\033[0m" % flexlog_file)
except os.error:
print("\033[1;33mNo flexget.log exist.\033[0m")
pass
raise SystemExit
# build color array
for i in range(236, 247):
color_list.append(i)
# grab tv shows from flexlog
try:
for line in open(flexlog_file):
if "downloaded" and not "ERROR" in line:
downloaded_array.append(line)
except IOError as e:
print("\033[1;33mNo flexget.log exist.\033[0m")
raise SystemExit
color_count = 0
show_count = 0
# print formated for console
for download in downloaded_array:
show_match = re.match(r'(\d{4}-\d{2}-\d{2} \d{2}:\d{2}).*Downloading: (\w.*?) - ([sS]\d.[eE]\d.).*', download)
if show_match:
show_count += 1
show_season = "\033[38;5;%sm%s %s" % (color_list[color_count], show_match.group(2), show_match.group(3))
print("%s\033[34m on \033[38;5;%sm%s\033[0m" % (show_season.rjust(60),
color_list[color_count], show_match.group(1)))
if color_count == len(color_list) - 1:
color_count = 0
color_list.reverse()
else:
color_count += 1
if show_count == 0:
print ("\033[1;31mNo new shows\033[0m")
raise SystemExit