remove get_category, check for last and next node, less param for filter
This commit is contained in:
parent
7ec0a1de96
commit
01d7d84ae2
@ -59,6 +59,8 @@ class GetSourceFromPlaylist:
|
||||
self.list_date = get_date(True)
|
||||
|
||||
self.node = None
|
||||
self.node_last = None
|
||||
self.node_next = None
|
||||
self.src = None
|
||||
self.begin = 0
|
||||
self.seek = 0
|
||||
@ -109,18 +111,18 @@ class GetSourceFromPlaylist:
|
||||
self.clip_nodes = None
|
||||
|
||||
def get_clip_in_out(self, node):
|
||||
if is_float(node["in"]):
|
||||
self.seek = node["in"]
|
||||
if is_float(node['in']):
|
||||
self.seek = node['in']
|
||||
else:
|
||||
self.seek = 0
|
||||
|
||||
if is_float(node["duration"]):
|
||||
self.duration = node["duration"]
|
||||
if is_float(node['duration']):
|
||||
self.duration = node['duration']
|
||||
else:
|
||||
self.duration = 20
|
||||
|
||||
if is_float(node["out"]):
|
||||
self.out = node["out"]
|
||||
if is_float(node['out']):
|
||||
self.out = node['out']
|
||||
else:
|
||||
self.out = self.duration
|
||||
|
||||
@ -130,39 +132,20 @@ class GetSourceFromPlaylist:
|
||||
self.seek, self.out, self.first, self.last
|
||||
)
|
||||
|
||||
def get_category(self, index, node):
|
||||
if 'category' in node:
|
||||
def last_and_next_node(self, index):
|
||||
if index - 1 >= 0:
|
||||
last_category = self.clip_nodes[
|
||||
"program"][index - 1]["category"]
|
||||
self.node_last = self.clip_nodes['program'][index - 1]
|
||||
else:
|
||||
last_category = 'noad'
|
||||
self.node_last = None
|
||||
|
||||
if index + 2 <= len(self.clip_nodes["program"]):
|
||||
next_category = self.clip_nodes[
|
||||
"program"][index + 1]["category"]
|
||||
if index + 2 <= len(self.clip_nodes['program']):
|
||||
self.node_next = self.clip_nodes['program'][index + 1]
|
||||
else:
|
||||
next_category = 'noad'
|
||||
|
||||
if node["category"] == 'advertisement':
|
||||
self.ad = True
|
||||
else:
|
||||
self.ad = False
|
||||
|
||||
if last_category == 'advertisement':
|
||||
self.ad_last = True
|
||||
else:
|
||||
self.ad_last = False
|
||||
|
||||
if next_category == 'advertisement':
|
||||
self.ad_next = True
|
||||
else:
|
||||
self.ad_next = False
|
||||
self.node_next = None
|
||||
|
||||
def set_filtergraph(self):
|
||||
self.filtergraph = build_filtergraph(
|
||||
self.node, self.duration, self.seek, self.out,
|
||||
self.ad, self.ad_last, self.ad_next, self.probe, messenger)
|
||||
self.node, self.node_last, self.node_next, self.seek, self.probe)
|
||||
|
||||
def check_for_next_playlist(self):
|
||||
if not self.next_playlist:
|
||||
@ -208,13 +191,13 @@ class GetSourceFromPlaylist:
|
||||
|
||||
self.last = False
|
||||
|
||||
def peperation_task(self, index, node):
|
||||
def peperation_task(self, index):
|
||||
# call functions in order to prepare source and filter
|
||||
self.src = node["source"]
|
||||
self.src = self.node['source']
|
||||
self.probe.load(self.src)
|
||||
|
||||
self.get_input()
|
||||
self.get_category(index, node)
|
||||
self.last_and_next_node(index)
|
||||
self.set_filtergraph()
|
||||
self.check_for_next_playlist()
|
||||
|
||||
@ -231,23 +214,23 @@ class GetSourceFromPlaylist:
|
||||
self.begin = self.init_time
|
||||
|
||||
# loop through all clips in playlist and get correct clip in time
|
||||
for index, self.node in enumerate(self.clip_nodes["program"]):
|
||||
for index, self.node in enumerate(self.clip_nodes['program']):
|
||||
self.get_clip_in_out(self.node)
|
||||
|
||||
# first time we end up here
|
||||
if self.first and \
|
||||
self.last_time < self.begin + self.out - self.seek:
|
||||
|
||||
self.peperation_task(index, self.node)
|
||||
self.peperation_task(index)
|
||||
self.first = False
|
||||
break
|
||||
elif self.last_time < self.begin:
|
||||
if index + 1 == len(self.clip_nodes["program"]):
|
||||
if index + 1 == len(self.clip_nodes['program']):
|
||||
self.last = True
|
||||
else:
|
||||
self.last = False
|
||||
|
||||
self.peperation_task(index, self.node)
|
||||
self.peperation_task(index)
|
||||
break
|
||||
|
||||
self.begin += self.out - self.seek
|
||||
|
Loading…
x
Reference in New Issue
Block a user