-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathscriptwrapper.py
165 lines (124 loc) · 5 KB
/
scriptwrapper.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import subprocess
import os
import math
import datetime
current_path = os.path.dirname(os.path.realpath(__file__))
class TwitchVideo():
def __init__(self, scriptwrapper):
self.scriptWrapper = scriptwrapper
self.final_clips = None
class DownloadedTwitchClipWrapper():
def __init__(self, id, author_name, clip_title, mp4name, vid_duration, diggCount, shareCount, playCount, commentCount):
self.id = id
self.author_name = author_name
self.mp4 = mp4name
self.clip_name = clip_title
self.vid_duration = vid_duration
self.upload = False
self.isIntro = False
self.isOutro = False
self.isInterval = False
self.isUsed = False
self.audio = 1
self.diggCount = diggCount
self.shareCount = shareCount
self.playCount = playCount
self.commentCount = commentCount
#Getting duration of video clips to trim a percentage of the beginning off
class ScriptWrapper():
def __init__(self, script):
self.rawScript = script
self.scriptMap = []
self.setupScriptMap()
def addClipAtStart(self, clip):
self.rawScript = [clip] + self.rawScript
self.scriptMap = [True] + self.scriptMap
def addScriptWrapper(self, scriptwrapper):
self.rawScript = self.rawScript + scriptwrapper.rawScript
self.scriptMap = self.scriptMap + scriptwrapper.scriptMap
def moveDown(self, i):
if i > 0:
copy1 = self.scriptMap[i-1]
copy2 = self.rawScript[i-1]
self.scriptMap[i-1] = self.scriptMap[i]
self.rawScript[i-1] = self.rawScript[i]
self.scriptMap[i] = copy1
self.rawScript[i] = copy2
else:
print("already at bottom!")
def moveUp(self, i):
if i < len(self.scriptMap) - 1:
copy1 = self.scriptMap[i+1]
copy2 = self.rawScript[i+1]
self.scriptMap[i+1] = self.scriptMap[i]
self.rawScript[i+1] = self.rawScript[i]
self.scriptMap[i] = copy1
self.rawScript[i] = copy2
else:
print("already at top!")
def setupScriptMap(self):
for mainComment in self.rawScript:
line = False
self.scriptMap.append(line)
def keep(self, mainCommentIndex):
self.scriptMap[mainCommentIndex] = True
def skip(self, mainCommentIndex):
self.scriptMap[mainCommentIndex] = False
def setCommentStart(self, x, start):
self.rawScript[x].start_cut = start
def setCommentEnd(self, x, end):
self.rawScript[x].end_cut = end
def setCommentAudio(self, x, audio):
self.rawScript[x].audio = audio
def getCommentData(self, x, y):
return self.rawScript[x][y]
def getCommentAmount(self):
return len(self.scriptMap)
def getEditedCommentThreadsAmount(self):
return len([commentThread for commentThread in self.scriptMap if commentThread[0] is True])
def getEditedCommentAmount(self):
commentThreads = ([commentThread for commentThread in self.scriptMap])
count = 0
for commentThread in commentThreads:
for comment in commentThread:
if comment is True:
count += 1
return count
def getEditedWordCount(self):
commentThreads = ([commentThread for commentThread in self.scriptMap])
word_count = 0
for x, commentThread in enumerate(commentThreads):
for y, comment in enumerate(commentThread):
if comment is True:
word_count += len(self.rawScript[x][y].text.split(" "))
return word_count
def getEditedCharacterCount(self):
commentThreads = ([commentThread for commentThread in self.scriptMap])
word_count = 0
for x, commentThread in enumerate(commentThreads):
for y, comment in enumerate(commentThread):
if comment is True:
word_count += len(self.rawScript[x][y].text)
return word_count
def getCommentInformation(self, x):
return self.rawScript[x]
def getKeptClips(self):
final_script = []
for i, clip in enumerate(self.scriptMap):
if clip:
final_script.append(self.rawScript[i])
return final_script
def getFinalClips(self):
final_script = []
for i, clip in enumerate(self.scriptMap):
clipwrapper = self.rawScript[i]
clipwrapper.isUsed = clip
final_script.append(self.rawScript[i])
return final_script
def getEstimatedVideoTime(self):
time = 0
for i, comment in enumerate(self.scriptMap):
if comment is True:
time += round(self.rawScript[i].vid_duration, 1)
obj = datetime.timedelta(seconds=math.ceil(time))
return obj