Added 'useDirtyGapFix' option to pseudo_config in order to fill up empty gaps with commercials and allow the app to cutoff the last commercial.

This commit is contained in:
Justin Emter
2017-11-11 11:54:04 -08:00
parent 7605dd4981
commit 3d521c0c0b
4 changed files with 16 additions and 6 deletions

View File

@@ -48,6 +48,7 @@ class PseudoChannel():
USE_OVERRIDE_CACHE = config.useDailyOverlapCache USE_OVERRIDE_CACHE = config.useDailyOverlapCache
DEBUG = config.debug_mode DEBUG = config.debug_mode
ROTATE_LOG = config.rotateLog ROTATE_LOG = config.rotateLog
USE_DIRTY_GAP_FIX = config.useDirtyGapFix
def __init__(self): def __init__(self):
@@ -356,7 +357,8 @@ class PseudoChannel():
if self.USING_COMMERCIAL_INJECTION: if self.USING_COMMERCIAL_INJECTION:
self.commercials = PseudoChannelCommercial( self.commercials = PseudoChannelCommercial(
self.db.get_commercials(), self.db.get_commercials(),
self.COMMERCIAL_PADDING_IN_SECONDS self.COMMERCIAL_PADDING_IN_SECONDS,
self.USE_DIRTY_GAP_FIX
) )
schedule = self.db.get_schedule() schedule = self.db.get_schedule()
weekday_dict = { weekday_dict = {

View File

@@ -76,6 +76,11 @@ rotateLog = "friday"
"""Debug mode will give you more output in your terminal to help problem solve issues.""" """Debug mode will give you more output in your terminal to help problem solve issues."""
debug_mode = True debug_mode = True
"""This squeezes in one last commercial to fill up the empty gaps even if the last commercial gets cutoff
Set this to false if you don't want your commercials to get cutoff/don't mind the gap.
"""
useDirtyGapFix = True
""" """
##### Do not edit below this line--------------------------------------------------------------- ##### Do not edit below this line---------------------------------------------------------------

View File

@@ -13,10 +13,11 @@ class PseudoChannelCommercial():
COMMERCIAL_PADDING_IN_SECONDS = 0 COMMERCIAL_PADDING_IN_SECONDS = 0
daily_schedule = [] daily_schedule = []
def __init__(self, commercials, commercialPadding): def __init__(self, commercials, commercialPadding, useDirtyGapFix):
self.commercials = commercials self.commercials = commercials
self.COMMERCIAL_PADDING_IN_SECONDS = commercialPadding self.COMMERCIAL_PADDING_IN_SECONDS = commercialPadding
self.USE_DIRTY_GAP_FIX = useDirtyGapFix
def get_random_commercial(self): def get_random_commercial(self):
@@ -81,6 +82,8 @@ class PseudoChannelCommercial():
) )
last_commercial = new_commercial last_commercial = new_commercial
if new_commercial_end_time > curr_item_start_time: if new_commercial_end_time > curr_item_start_time:
if self.USE_DIRTY_GAP_FIX:
commercial_list.append(new_commercial)
break break
commercial_list.append(new_commercial) commercial_list.append(new_commercial)
return commercial_list return commercial_list

View File

@@ -40,13 +40,13 @@ class PseudoChannelDatabase():
'mediaID INTEGER, title TEXT, duration INTEGER, plexMediaID TEXT)') 'mediaID INTEGER, title TEXT, duration INTEGER, plexMediaID TEXT)')
self.cursor.execute('CREATE TABLE IF NOT EXISTS ' self.cursor.execute('CREATE TABLE IF NOT EXISTS '
'schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, ' 'schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, '
'mediaID INTEGER, title TEXT, duration INTEGER, startTime INTEGER, ' 'mediaID INTEGER, title TEXT, duration INTEGER, startTime TEXT, '
'endTime INTEGER, dayOfWeek TEXT, startTimeUnix INTEGER, section TEXT, ' 'endTime TEXT, dayOfWeek TEXT, startTimeUnix INTEGER, section TEXT, '
'strictTime TEXT, timeShift TEXT, overlapMax TEXT, xtra TEXT)') 'strictTime TEXT, timeShift TEXT, overlapMax TEXT, xtra TEXT)')
self.cursor.execute('CREATE TABLE IF NOT EXISTS ' self.cursor.execute('CREATE TABLE IF NOT EXISTS '
'daily_schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, ' 'daily_schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, '
'mediaID INTEGER, title TEXT, episodeNumber INTEGER, seasonNumber INTEGER, ' 'mediaID INTEGER, title TEXT, episodeNumber INTEGER, seasonNumber INTEGER, '
'showTitle TEXT, duration INTEGER, startTime INTEGER, endTime INTEGER, ' 'showTitle TEXT, duration INTEGER, startTime TEXT, endTime TEXT, '
'dayOfWeek TEXT, sectionType TEXT, plexMediaID TEXT)') 'dayOfWeek TEXT, sectionType TEXT, plexMediaID TEXT)')
self.cursor.execute('CREATE TABLE IF NOT EXISTS ' self.cursor.execute('CREATE TABLE IF NOT EXISTS '
'app_settings(id INTEGER PRIMARY KEY AUTOINCREMENT, version TEXT)') 'app_settings(id INTEGER PRIMARY KEY AUTOINCREMENT, version TEXT)')
@@ -90,7 +90,7 @@ class PseudoChannelDatabase():
self.cursor.execute('CREATE TABLE IF NOT EXISTS ' self.cursor.execute('CREATE TABLE IF NOT EXISTS '
'daily_schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, ' 'daily_schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, '
'mediaID INTEGER, title TEXT, episodeNumber INTEGER, seasonNumber INTEGER, ' 'mediaID INTEGER, title TEXT, episodeNumber INTEGER, seasonNumber INTEGER, '
'showTitle TEXT, duration INTEGER, startTime INTEGER, endTime INTEGER, ' 'showTitle TEXT, duration INTEGER, startTime TEXT, endTime TEXT, '
'dayOfWeek TEXT, sectionType TEXT, plexMediaID TEXT)') 'dayOfWeek TEXT, sectionType TEXT, plexMediaID TEXT)')
self.conn.commit() self.conn.commit()