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