Commercial logic improvement; website creation changes

Modifications were made to allow for commercials to be generated for the last show before midnight. This had been an issue in the past, and should be fixed with this update.

Further modifications were also made to the -m flag script, hopefully removing the issues surrounding multiple items being declared running.
This commit is contained in:
mutto233
2018-07-09 01:14:09 -04:00
parent b3d5b99a68
commit fce926936e
2 changed files with 67 additions and 14 deletions

View File

@@ -46,6 +46,30 @@ class PseudoChannelCommercial():
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')
curr_item_start_time = datetime.strptime(now_ep.start_time, '%I:%M:%S %p')
time_diff = (curr_item_start_time - prev_item_end_time)
# mutto233 has added some logic at this point
# - All dates are now changed to 1/1/90 so midnight doesn't cause issues
# - Issues with day skips again being adressed
now = datetime.now()
now = now.replace(year=1900, month=1, day=1)
midnight = now.replace(hour=0,minute=0,second=0)
prev_item_end_time = prev_item_end_time.replace(day=1)
if prev_item_end_time > curr_item_start_time:
# NOTE: This is just for the logic of this function, I have noticed that this
# may cause other issues in other functions, since now the day is off.
print "WE MUST BE SKIPPING A DAY, ADDING A DAY TO THE START TIME"
curr_item_start_time = curr_item_start_time.replace(day=2)
print "##############################################"
print "get_commercials_to_place_between_media DEBUG"
print "NOW: %s" % now
print "prev_item_end_time: %s" % prev_item_end_time
print "curr_item_start_time: %s" % curr_item_start_time
print "time_diff: %s" % time_diff
print "##############################################"
count = 0
commercial_list = []
commercial_dur_sum = 0

View File

@@ -164,10 +164,13 @@ class PseudoDailyScheduleController():
def get_html_from_daily_schedule(self, currentTime, bgImageURL, datalist, nowPlayingTitle):
now = datetime.now()
now = now.replace(year=1900, month=1, day=1)
midnight = now.replace(hour=23, minute=59, second=59)
#mutto233 put this here, because to be honest, isn't the current time always now?
if currentTime != None:
currentTime=now
time = now.strftime("%B %d, %Y")
doc, tag, text, line = Doc(
@@ -272,9 +275,15 @@ class PseudoDailyScheduleController():
timeBStart = timeBStart.replace(year=1900, month=1, day=1)
try:
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S.%f')
timeBEnd = timeBEnd.replace(day=1)
except:
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S')
timeBEnd = timeBEnd.replace(day=1)
#print timeBStart
#print "%s" % row[3]
#print "%s, %s, %s, %s, %s" % (currentTime, timeBStart, timeBEnd, midnight,midnight.replace(hour=0,minute=0,second=0))
#print "%s" % (timeBStart - timeBEnd).total_seconds()
#print "%s, %s, %s, %s" % ((currentTime-timeBStart).total_seconds(),(midnight-currentTime).total_seconds(),(currentTime-midnight.replace(hour=0,minute=0,second=0)).total_seconds(),(timeBEnd-currentTime).total_seconds())
if currentTime == None:
with tag('tr'):
with tag('th', scope='row'):
@@ -287,12 +296,14 @@ class PseudoDailyScheduleController():
text(row[3])
with tag('td'):
text(row[8])
elif (currentTime - timeBStart).total_seconds() >= 0 and \
(timeBEnd - currentTime).total_seconds() >= 0:
elif ((currentTime - timeBStart).total_seconds() >= 0 and \
(timeBEnd - currentTime).total_seconds() >= 0) or \
((timeBStart - timeBEnd).total_seconds() >= 0 and \
(((currentTime-midnight.replace(hour=0,minute=0,second=0)).total_seconds() >= 0 and \
(timeBEnd-currentTime).total_seconds() >= 0) or
((currentTime-timeBStart).total_seconds() >= 0 and \
(midnight-currentTime).total_seconds() >= 0))):
#if self.DEBUG:
#print "%s, %s, %s" % (currentTime, timeBStart, timeBEnd)
#print "%s, %s" % ((currentTime - timeBStart).total_seconds(), (timeBEnd - currentTime).total_seconds())
print "+++++ Currently Playing:", row[3]
with tag('tr', klass='bg-info'):
@@ -599,7 +610,9 @@ class PseudoDailyScheduleController():
self.check_for_end_time(datalist)
def manually_get_now_playing_bg_image(self, currentTime, datalist):
now = datetime.now()
now = now.replace(year=1900, month=1, day=1)
midnight = now.replace(hour=23, minute=59, second=59)
increase_var = 0
for row in datalist:
@@ -611,8 +624,10 @@ class PseudoDailyScheduleController():
timeBStart = timeBStart.replace(year=1900, month=1, day=1)
try:
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S.%f')
timeBEnd = timeBEnd.replace(day=1)
except:
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S')
timeBEnd = timeBEnd.replace(day=1)
#print ((currentTime - timeBStart).total_seconds() >= 0 and \
# (timeBEnd - currentTime).total_seconds() >= 0)
@@ -620,8 +635,13 @@ class PseudoDailyScheduleController():
#print currentTime.minute
#print timeBStart.minute
if (currentTime - timeBStart).total_seconds() >= 0 and \
(timeBEnd - currentTime).total_seconds() >= 0:
if ((currentTime - timeBStart).total_seconds() >= 0 and \
(timeBEnd - currentTime).total_seconds() >= 0) or \
((timeBStart - timeBEnd).total_seconds() >= 0 and \
(((currentTime-midnight.replace(hour=0,minute=0,second=0)).total_seconds() >= 0 and \
(timeBEnd-currentTime).total_seconds() >= 0) or
((currentTime-timeBStart).total_seconds() >= 0 and \
(midnight-currentTime).total_seconds() >= 0))):
print "+++++ Made the conditional & found item: {}".format(row[6])
@@ -642,7 +662,9 @@ class PseudoDailyScheduleController():
return None
def manually_get_now_playing_title(self, currentTime, datalist):
now = datetime.now()
now = now.replace(year=1900, month=1, day=1)
midnight = now.replace(hour=23, minute=59, second=59)
increase_var = 0
for row in datalist:
@@ -654,8 +676,10 @@ class PseudoDailyScheduleController():
timeBStart = timeBStart.replace(year=1900, month=1, day=1)
try:
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S.%f')
timeBEnd = timeBEnd.replace(day=1)
except:
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S')
timeBEnd = timeBEnd.replace(day=1)
#print ((currentTime - timeBStart).total_seconds() >= 0 and \
# (timeBEnd - currentTime).total_seconds() >= 0)
@@ -663,8 +687,13 @@ class PseudoDailyScheduleController():
#print currentTime.minute
#print timeBStart.minute
if (currentTime - timeBStart).total_seconds() >= 0 and \
(timeBEnd - currentTime).total_seconds() >= 0 :
if ((currentTime - timeBStart).total_seconds() >= 0 and \
(timeBEnd - currentTime).total_seconds() >= 0) or \
((timeBStart - timeBEnd).total_seconds() >= 0 and \
(((currentTime-midnight.replace(hour=0,minute=0,second=0)).total_seconds() >= 0 and \
(timeBEnd-currentTime).total_seconds() >= 0) or
((currentTime-timeBStart).total_seconds() >= 0 and \
(midnight-currentTime).total_seconds() >= 0))):
print "+++++ Made the conditional & found item: {}".format(row[6])