mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-22 03:03:33 +00:00
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:
@@ -44,8 +44,32 @@ class PseudoChannelCommercial():
|
|||||||
def get_commercials_to_place_between_media(self, last_ep, now_ep):
|
def get_commercials_to_place_between_media(self, last_ep, now_ep):
|
||||||
|
|
||||||
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_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')
|
curr_item_start_time = datetime.strptime(now_ep.start_time, '%I:%M:%S %p')
|
||||||
time_diff = (curr_item_start_time - prev_item_end_time)
|
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
|
count = 0
|
||||||
commercial_list = []
|
commercial_list = []
|
||||||
commercial_dur_sum = 0
|
commercial_dur_sum = 0
|
||||||
|
|||||||
@@ -164,10 +164,13 @@ class PseudoDailyScheduleController():
|
|||||||
def get_html_from_daily_schedule(self, currentTime, bgImageURL, datalist, nowPlayingTitle):
|
def get_html_from_daily_schedule(self, currentTime, bgImageURL, datalist, nowPlayingTitle):
|
||||||
|
|
||||||
now = datetime.now()
|
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?
|
#mutto233 put this here, because to be honest, isn't the current time always now?
|
||||||
if currentTime != None:
|
if currentTime != None:
|
||||||
currentTime=now
|
currentTime=now
|
||||||
|
|
||||||
|
|
||||||
time = now.strftime("%B %d, %Y")
|
time = now.strftime("%B %d, %Y")
|
||||||
doc, tag, text, line = Doc(
|
doc, tag, text, line = Doc(
|
||||||
|
|
||||||
@@ -272,9 +275,15 @@ class PseudoDailyScheduleController():
|
|||||||
timeBStart = timeBStart.replace(year=1900, month=1, day=1)
|
timeBStart = timeBStart.replace(year=1900, month=1, day=1)
|
||||||
try:
|
try:
|
||||||
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S.%f')
|
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S.%f')
|
||||||
|
timeBEnd = timeBEnd.replace(day=1)
|
||||||
except:
|
except:
|
||||||
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S')
|
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S')
|
||||||
|
timeBEnd = timeBEnd.replace(day=1)
|
||||||
#print timeBStart
|
#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:
|
if currentTime == None:
|
||||||
with tag('tr'):
|
with tag('tr'):
|
||||||
with tag('th', scope='row'):
|
with tag('th', scope='row'):
|
||||||
@@ -287,12 +296,14 @@ class PseudoDailyScheduleController():
|
|||||||
text(row[3])
|
text(row[3])
|
||||||
with tag('td'):
|
with tag('td'):
|
||||||
text(row[8])
|
text(row[8])
|
||||||
elif (currentTime - timeBStart).total_seconds() >= 0 and \
|
elif ((currentTime - timeBStart).total_seconds() >= 0 and \
|
||||||
(timeBEnd - currentTime).total_seconds() >= 0:
|
(timeBEnd - currentTime).total_seconds() >= 0) or \
|
||||||
|
((timeBStart - timeBEnd).total_seconds() >= 0 and \
|
||||||
#if self.DEBUG:
|
(((currentTime-midnight.replace(hour=0,minute=0,second=0)).total_seconds() >= 0 and \
|
||||||
#print "%s, %s, %s" % (currentTime, timeBStart, timeBEnd)
|
(timeBEnd-currentTime).total_seconds() >= 0) or
|
||||||
#print "%s, %s" % ((currentTime - timeBStart).total_seconds(), (timeBEnd - currentTime).total_seconds())
|
((currentTime-timeBStart).total_seconds() >= 0 and \
|
||||||
|
(midnight-currentTime).total_seconds() >= 0))):
|
||||||
|
|
||||||
print "+++++ Currently Playing:", row[3]
|
print "+++++ Currently Playing:", row[3]
|
||||||
|
|
||||||
with tag('tr', klass='bg-info'):
|
with tag('tr', klass='bg-info'):
|
||||||
@@ -599,7 +610,9 @@ class PseudoDailyScheduleController():
|
|||||||
self.check_for_end_time(datalist)
|
self.check_for_end_time(datalist)
|
||||||
|
|
||||||
def manually_get_now_playing_bg_image(self, currentTime, 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
|
increase_var = 0
|
||||||
|
|
||||||
for row in datalist:
|
for row in datalist:
|
||||||
@@ -611,8 +624,10 @@ class PseudoDailyScheduleController():
|
|||||||
timeBStart = timeBStart.replace(year=1900, month=1, day=1)
|
timeBStart = timeBStart.replace(year=1900, month=1, day=1)
|
||||||
try:
|
try:
|
||||||
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S.%f')
|
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S.%f')
|
||||||
|
timeBEnd = timeBEnd.replace(day=1)
|
||||||
except:
|
except:
|
||||||
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S')
|
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S')
|
||||||
|
timeBEnd = timeBEnd.replace(day=1)
|
||||||
|
|
||||||
#print ((currentTime - timeBStart).total_seconds() >= 0 and \
|
#print ((currentTime - timeBStart).total_seconds() >= 0 and \
|
||||||
# (timeBEnd - currentTime).total_seconds() >= 0)
|
# (timeBEnd - currentTime).total_seconds() >= 0)
|
||||||
@@ -620,8 +635,13 @@ class PseudoDailyScheduleController():
|
|||||||
#print currentTime.minute
|
#print currentTime.minute
|
||||||
#print timeBStart.minute
|
#print timeBStart.minute
|
||||||
|
|
||||||
if (currentTime - timeBStart).total_seconds() >= 0 and \
|
if ((currentTime - timeBStart).total_seconds() >= 0 and \
|
||||||
(timeBEnd - currentTime).total_seconds() >= 0:
|
(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])
|
print "+++++ Made the conditional & found item: {}".format(row[6])
|
||||||
|
|
||||||
@@ -642,7 +662,9 @@ class PseudoDailyScheduleController():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def manually_get_now_playing_title(self, currentTime, datalist):
|
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
|
increase_var = 0
|
||||||
|
|
||||||
for row in datalist:
|
for row in datalist:
|
||||||
@@ -654,8 +676,10 @@ class PseudoDailyScheduleController():
|
|||||||
timeBStart = timeBStart.replace(year=1900, month=1, day=1)
|
timeBStart = timeBStart.replace(year=1900, month=1, day=1)
|
||||||
try:
|
try:
|
||||||
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S.%f')
|
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S.%f')
|
||||||
|
timeBEnd = timeBEnd.replace(day=1)
|
||||||
except:
|
except:
|
||||||
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S')
|
timeBEnd = datetime.strptime(row[9], '%Y-%m-%d %H:%M:%S')
|
||||||
|
timeBEnd = timeBEnd.replace(day=1)
|
||||||
|
|
||||||
#print ((currentTime - timeBStart).total_seconds() >= 0 and \
|
#print ((currentTime - timeBStart).total_seconds() >= 0 and \
|
||||||
# (timeBEnd - currentTime).total_seconds() >= 0)
|
# (timeBEnd - currentTime).total_seconds() >= 0)
|
||||||
@@ -663,8 +687,13 @@ class PseudoDailyScheduleController():
|
|||||||
#print currentTime.minute
|
#print currentTime.minute
|
||||||
#print timeBStart.minute
|
#print timeBStart.minute
|
||||||
|
|
||||||
if (currentTime - timeBStart).total_seconds() >= 0 and \
|
if ((currentTime - timeBStart).total_seconds() >= 0 and \
|
||||||
(timeBEnd - currentTime).total_seconds() >= 0 :
|
(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])
|
print "+++++ Made the conditional & found item: {}".format(row[6])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user