mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-22 03:03:33 +00:00
fixed commercials over-scheduling bug
added logic to set the end time of the last scheduled item to 1 microsecond before reset time if the original end time is after the reset time
This commit is contained in:
@@ -1418,6 +1418,10 @@ class PseudoChannel():
|
||||
self.translate_time(entry.start_time),
|
||||
entry.duration
|
||||
)
|
||||
if entry.end_time.hour >= 0 and entry.end_time.hour < int(config.dailyUpdateTime[0]):
|
||||
entry.end_time = entry.end_time + datetime.timedelta(days=1)
|
||||
if natural_start_time.hour < int(config.dailyUpdateTime[0]) and entry.end_time.hour >= int(config.dailyUpdateTime[0]):
|
||||
entry.end_time = datetime.datetime.strptime('1900-01-02 0' + str(int(config.dailyUpdateTime[0])-1) + ':59:59.999999', '%y-%m-%d %H:%M:%S.%f')
|
||||
"""Get List of Commercials to inject"""
|
||||
if self.USING_COMMERCIAL_INJECTION:
|
||||
list_of_commercials = self.commercials.get_commercials_to_place_between_media(
|
||||
@@ -1453,6 +1457,10 @@ class PseudoChannel():
|
||||
self.translate_time(natural_start_time.strftime(self.APP_TIME_FORMAT_STR)),
|
||||
entry.duration
|
||||
)
|
||||
if entry.end_time.hour >= 0 and entry.end_time.hour < int(config.dailyUpdateTime[0]):
|
||||
entry.end_time = entry.end_time + datetime.timedelta(days=1)
|
||||
if natural_start_time.hour < int(config.dailyUpdateTime[0]) and entry.end_time.hour >= int(config.dailyUpdateTime[0]):
|
||||
entry.end_time = datetime.datetime.strptime('1900-01-02 0' + str(int(config.dailyUpdateTime[0])-1) + ':59:59.999999', '%y-%m-%d %H:%M:%S.%f')
|
||||
print("INFO: End Time = {}".format(str(entry.end_time)))
|
||||
overlap_max_seconds=int(entry.overlap_max) * 60
|
||||
print(("INFO: Overlap Max is "+str(overlap_max_seconds)))
|
||||
@@ -1492,6 +1500,10 @@ class PseudoChannel():
|
||||
print("INFO: New start time:", new_starttime)
|
||||
entry.start_time = datetime.datetime.strptime(new_starttime, self.APP_TIME_FORMAT_STR).strftime(self.APP_TIME_FORMAT_STR)
|
||||
entry.end_time = self.get_end_time_from_duration(entry.start_time, entry.duration)
|
||||
if entry.end_time.hour >= 0 and entry.end_time.hour < int(config.dailyUpdateTime[0]):
|
||||
entry.end_time = entry.end_time + datetime.timedelta(days=1)
|
||||
if natural_start_time.hour < int(config.dailyUpdateTime[0]) and entry.end_time.hour >= int(config.dailyUpdateTime[0]):
|
||||
entry.end_time = datetime.datetime.strptime('1900-01-02 0' + str(int(config.dailyUpdateTime[0])-1) + ':59:59.999999', '%y-%m-%d %H:%M:%S.%f')
|
||||
"""Get List of Commercials to inject"""
|
||||
if self.USING_COMMERCIAL_INJECTION:
|
||||
list_of_commercials = self.commercials.get_commercials_to_place_between_media(
|
||||
|
||||
@@ -47,6 +47,7 @@ class PseudoChannelCommercial():
|
||||
|
||||
reset_time = datetime.strptime(reset_time,'%H:%M')
|
||||
prev_item_end_time = datetime.strptime(last_ep.end_time.strftime('%Y-%m-%d %H:%M:%S.%f'), '%Y-%m-%d %H:%M:%S.%f')
|
||||
prev_item_start_time = datetime.strptime(last_ep.start_time, '%H:%M:%S')
|
||||
if(now_ep != "reset"):
|
||||
curr_item_start_time = datetime.strptime(now_ep.start_time, '%H:%M:%S')
|
||||
else:
|
||||
@@ -71,6 +72,8 @@ class PseudoChannelCommercial():
|
||||
prev_item_end_time += timedelta(days=1)
|
||||
#else:
|
||||
#prev_item_end_time = prev_item_end_time.replace(day=1)
|
||||
if prev_item_start_time.hour < reset_time.hour and prev_item_end_time.hour >= reset_time.hour:
|
||||
prev_item_end_time = datetime.strptime('1900-01-02 0' + str(int(reset_time.hour)-1) + ':59:59.999999', '%Y-%m-%d %H:%M:%S.%f')
|
||||
time_diff = (curr_item_start_time - prev_item_end_time)
|
||||
|
||||
if prev_item_end_time.replace(microsecond=0) > curr_item_start_time and strict_time == "false":
|
||||
|
||||
Reference in New Issue
Block a user