-
Notifications
You must be signed in to change notification settings - Fork 17
/
Summary.py
executable file
·106 lines (79 loc) · 4.11 KB
/
Summary.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
#!/usr/bin/env python
#encoding:utf-8
#author:ccjensen/Chris
#project:PlexMediaTagger
#repository:https://github.com/ccjensen/plexmediatagger
#license:Creative Commons GNU GPL v2
# (http://creativecommons.org/licenses/GPL/2.0/)
from datetime import datetime
class Summary:
__shared_state = {}
def __init__(self):
self.__dict__ = self.__shared_state
if not 'time_start' in self.__dict__:
self.time_start = datetime.now()
self.datetimeformat = "%Y-%m-%d_%H:%M:%S"
self.items_processed = 0
self.metadata_removal_success = 0
self.metadata_removal_fail = 0
self.metadata_embedded_success = 0
self.metadata_embedded_fail = 0
self.metadata_optimized_success = 0
self.metadata_optimized_fail = 0
self.added_to_itunes_success = 0
self.added_to_itunes_fail = 0
self.subtitle_export_success = 0
self.subtitle_export_fail = 0
self.artwork_export_success = 0
self.artwork_export_fail = 0
def results(self):
now_time = datetime.now()
results = []
total_items = self.metadata_removal_success+self.metadata_removal_fail
if total_items > 0:
results.append("Metadata cleared: \t\t%d, \tFailed: %d, \tTotal: %d" % ( self.metadata_removal_success, self.metadata_removal_fail, total_items ))
total_items = self.metadata_embedded_success+self.metadata_embedded_fail
if total_items > 0:
results.append("Metadata embedded: \t\t%d, \tFailed: %d, \tTotal: %d" % ( self.metadata_embedded_success, self.metadata_embedded_fail, total_items ))
total_items = self.metadata_optimized_success+self.metadata_optimized_fail
if total_items > 0:
results.append("Metadata optimized: \t\t%d, \tFailed: %d, \tTotal: %d" % ( self.metadata_optimized_success, self.metadata_optimized_fail, total_items ))
total_items = self.added_to_itunes_success+self.added_to_itunes_fail
if total_items > 0:
results.append("Added to iTunes: \t\t%d, \tFailed: %d, \tTotal: %d" % ( self.added_to_itunes_success, self.added_to_itunes_fail, total_items ))
total_items = self.subtitle_export_success+self.subtitle_export_success
if total_items > 0:
results.append("Subtitles exported: \t\t%d, \tFailed: %d, \tTotal: %d" % ( self.subtitle_export_success, self.subtitle_export_success, total_items ))
total_items = self.artwork_export_success+self.artwork_export_fail
if total_items > 0:
results.append("Artwork exported: \t\t%d, \tFailed: %d, \tTotal: %d" % ( self.artwork_export_success, self.artwork_export_fail, total_items ))
results.append("Parts processed: \t\t%d" % ( self.items_processed ))
duration = str(now_time - self.time_start).split('.')[0]
results.append("Execution Duration: \t\t%s" % duration)
return results
def increment_parts_processed(self):
self.items_processed += 1
def metadata_removal_succeeded(self):
self.metadata_removal_success += 1
def metadata_removal_failed(self):
self.metadata_removal_fail += 1
def metadata_embedded_succeeded(self):
self.metadata_embedded_success += 1
def metadata_embedded_failed(self):
self.metadata_embedded_fail += 1
def metadata_optimized_succeeded(self):
self.metadata_optimized_success += 1
def metadata_optimized_failed(self):
self.metadata_optimized_fail += 1
def add_to_tv_succeeded(self):
self.added_to_itunes_success += 1
def add_to_tv_failed(self):
self.added_to_itunes_fail += 1
def subtitle_export_succeeded(self):
self.subtitle_export_success += 1
def subtitle_export_failed(self):
self.subtitle_export_fail += 1
def artwork_export_succeeded(self):
self.artwork_export_success += 1
def artwork_export_failed(self):
self.artwork_export_fail += 1