mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-22 19:23:21 +00:00
Added commercial padding to config / logic. Difficult to test without just running it as is. Fingers crossed. Am converting the config value from seconds to milli's then adding it to the commercial duration - in theory this will work as a padding if value specified is > than 0.
This commit is contained in:
@@ -47,6 +47,8 @@ class PseudoChannel():
|
||||
|
||||
APP_TIME_FORMAT_STR = '%I:%M:%S %p'
|
||||
|
||||
COMMERCIAL_PADDING_IN_SECONDS = config.commercialPadding
|
||||
|
||||
DEBUG = config.debug_mode
|
||||
|
||||
def __init__(self):
|
||||
@@ -573,7 +575,8 @@ class PseudoChannel():
|
||||
|
||||
if self.USING_COMMERCIAL_INJECTION:
|
||||
self.commercials = PseudoChannelCommercial(
|
||||
self.db.get_commercials()
|
||||
self.db.get_commercials(),
|
||||
self.COMMERCIAL_PADDING_IN_SECONDS
|
||||
)
|
||||
|
||||
schedule = self.db.get_schedule()
|
||||
@@ -816,7 +819,7 @@ class PseudoChannel():
|
||||
|
||||
def run_commercial_injection(self):
|
||||
|
||||
print "#### Running commercial injection."
|
||||
"""print "#### Running commercial injection."
|
||||
|
||||
self.commercials = PseudoChannelCommercial(
|
||||
self.db.get_commercials(),
|
||||
@@ -825,7 +828,9 @@ class PseudoChannel():
|
||||
|
||||
commercials_to_inject = self.commercials.get_commercials_to_inject()
|
||||
|
||||
print commercials_to_inject
|
||||
print commercials_to_inject"""
|
||||
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
|
||||
|
||||
@@ -63,6 +63,9 @@ useGoogleCalendar = False
|
||||
|
||||
useCommercialInjection = True
|
||||
|
||||
# How many seconds to pad commercials between each other / other media
|
||||
commercialPadding = 5
|
||||
|
||||
dailyUpdateTime = "12:00 AM"
|
||||
|
||||
debug_mode = False
|
||||
|
||||
@@ -11,12 +11,15 @@ from src import Commercial
|
||||
class PseudoChannelCommercial():
|
||||
|
||||
MIN_DURATION_FOR_COMMERCIAL = 10 #seconds
|
||||
COMMERCIAL_PADDING_IN_SECONDS = 0
|
||||
daily_schedule = []
|
||||
|
||||
def __init__(self, commercials):
|
||||
def __init__(self, commercials, commercialPadding):
|
||||
|
||||
self.commercials = commercials
|
||||
|
||||
self.COMMERCIAL_PADDING_IN_SECONDS = commercialPadding
|
||||
|
||||
def get_commercials_to_inject(self):
|
||||
|
||||
self.go()
|
||||
@@ -86,6 +89,16 @@ class PseudoChannelCommercial():
|
||||
def timedelta_milliseconds(self, td):
|
||||
return td.days*86400000 + td.seconds*1000 + td.microseconds/1000
|
||||
|
||||
def pad_the_commercial_dur(self, commercial):
|
||||
|
||||
commercial_as_list = list(commercial)
|
||||
|
||||
commercial_as_list[4] = int(commercial_as_list[4]) + (self.COMMERCIAL_PADDING_IN_SECONDS * 1000)
|
||||
|
||||
commercial = tuple(commercial_as_list)
|
||||
|
||||
return commercial
|
||||
|
||||
def get_commercials_to_place_between_media(self, last_ep, now_ep):
|
||||
|
||||
#print last_ep.end_time, now_ep.start_time
|
||||
@@ -114,7 +127,12 @@ class PseudoChannelCommercial():
|
||||
|
||||
while curr_item_start_time > new_commercial_start_time and (count) < len(self.commercials)*100:
|
||||
|
||||
random_commercial = self.get_random_commercial()
|
||||
random_commercial_without_pad = self.get_random_commercial()
|
||||
|
||||
"""
|
||||
Padding the duration of commercials as per user specified padding.
|
||||
"""
|
||||
random_commercial = self.pad_the_commercial_dur(random_commercial_without_pad)
|
||||
|
||||
#new_commercial_seconds = (int(random_commercial[4])/1000)%60
|
||||
|
||||
|
||||
Reference in New Issue
Block a user