mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2026-01-05 17:53:14 +00:00
bug fixes
Fixed bug causing infinite loop in daily schedule generation
This commit is contained in:
@@ -757,7 +757,10 @@ class PseudoChannel():
|
||||
max = int(minmax)
|
||||
max = max * 60000
|
||||
if str(entry[3]).lower() == "random":
|
||||
media_id = 999
|
||||
if entry[14] == 0:
|
||||
media_id = 998
|
||||
else:
|
||||
media_id = 999
|
||||
advance_episode = "no"
|
||||
sections = self.PLEX.library.sections()
|
||||
shows_list = []
|
||||
@@ -771,6 +774,7 @@ class PseudoChannel():
|
||||
shows = self.PLEX.library.section(theSection.title)
|
||||
print("NOTICE: Getting Show That Matches Data Filters")
|
||||
the_show = self.db.get_random_show_data("TV Shows",int(min),int(max),entry[15],entry[16],entry[17],entry[18],entry[19],entry[20])
|
||||
print("INFO: " + the_show[3])
|
||||
if (the_show == None):
|
||||
print("NOTICE: Failed to get shows with data filters, trying with less")
|
||||
the_show = self.db.get_random_show_data("TV Shows",int(min),int(max),entry[15],None,None,None,entry[19],None)
|
||||
@@ -796,14 +800,16 @@ class PseudoChannel():
|
||||
episode_duration = int(next_episode[4])
|
||||
print("INFO: Random Selection: "+next_episode[7]+" - S"+str(next_episode[6])+"E"+str(next_episode[5])+" - "+next_episode[3])
|
||||
else:
|
||||
if entry[2] == 999:
|
||||
print("INFO: entry[2] = " + str(entry[2]))
|
||||
print("INFO: media_id = " + str(media_id))
|
||||
if entry[2] == 999 or media_id == 999:
|
||||
media_id = 999
|
||||
print("ACTION: Choosing random episode of "+the_show[3].upper())
|
||||
try:
|
||||
next_episode = self.db.get_random_episode_of_show_by_data(the_show[2],int(min),int(max),entry[15],entry[21].split(',')[0],entry[21].split(',')[1])
|
||||
except:
|
||||
next_episode = self.db.get_random_episode_of_show_by_data(the_show[2],int(min),int(max),entry[15])
|
||||
elif entry[2] == 998:
|
||||
elif entry[2] == 998 or media_id == 998:
|
||||
media_id = 998
|
||||
if entry[14] == 1:
|
||||
print("ACTION: Choosing last episode of " +the_show[3].upper())
|
||||
|
||||
@@ -9,7 +9,7 @@ class PseudoChannelDatabase():
|
||||
|
||||
def __init__(self, db):
|
||||
|
||||
self.db = db
|
||||
self = db
|
||||
self.conn = sqlite3.connect(self.db, check_same_thread=False)
|
||||
self.cursor = self.conn.cursor()
|
||||
|
||||
@@ -457,6 +457,7 @@ class PseudoChannelDatabase():
|
||||
"""Database functions.
|
||||
Updaters, etc.
|
||||
"""
|
||||
|
||||
def update_shows_table_with_last_episode(self, showTitle, lastEpisodeTitle):
|
||||
sql1 = "UPDATE shows SET lastEpisodeTitle = ? WHERE title LIKE ? COLLATE NOCASE"
|
||||
self.cursor.execute(sql1, (lastEpisodeTitle, showTitle, ))
|
||||
@@ -817,18 +818,18 @@ class PseudoChannelDatabase():
|
||||
return media_item
|
||||
|
||||
def get_first_episode(self, tvshow):
|
||||
sql = ("SELECT * FROM episodes WHERE ( showTitle LIKE ? AND "
|
||||
"episodeNumber LIKE (SELECT MIN(episodeNumber) FROM episodes WHERE (showTitle LIKE ?)) AND "
|
||||
"seasonNumber LIKE (SELECT MIN(seasonNumber) FROM episodes WHERE (showTitle LIKE ?))) COLLATE NOCASE")
|
||||
self.cursor.execute(sql, (tvshow, tvshow, tvshow, ))
|
||||
|
||||
sql = ("SELECT id, unix, mediaID, title, duration, MIN(episodeNumber), MIN(seasonNumber), "
|
||||
"showTitle, plexMediaID, customSectionName FROM episodes WHERE ( showTitle LIKE ?) COLLATE NOCASE")
|
||||
self.cursor.execute(sql, (tvshow, ))
|
||||
first_episode = self.cursor.fetchone()
|
||||
return first_episode
|
||||
|
||||
def get_first_episode_by_id(self, tvshow):
|
||||
sql = ("SELECT * FROM episodes WHERE ( mediaID LIKE ? AND "
|
||||
"episodeNumber LIKE (SELECT MIN(episodeNumber) FROM episodes WHERE (mediaID LIKE ?)) AND "
|
||||
"seasonNumber LIKE (SELECT MIN(seasonNumber) FROM episodes WHERE (mediaID LIKE ?))) COLLATE NOCASE")
|
||||
self.cursor.execute(sql, (tvshow, tvshow, tvshow, ))
|
||||
|
||||
sql = ("SELECT id, unix, mediaID, title, duration, MIN(episodeNumber), MIN(seasonNumber), "
|
||||
"showTitle, plexMediaID, customSectionName FROM episodes WHERE ( mediaID LIKE ?) COLLATE NOCASE")
|
||||
self.cursor.execute(sql, (tvshow, ))
|
||||
first_episode = self.cursor.fetchone()
|
||||
return first_episode
|
||||
|
||||
|
||||
@@ -20,6 +20,6 @@ os.chdir(os.path.abspath(os.path.dirname(__file__)))
|
||||
for channel in channelsList:
|
||||
os.chdir(os.path.abspath(os.path.dirname(__file__))+'/pseudo-channel_'+channel)
|
||||
print("GENERATING SCHEDULE FOR CHANNEL "+channel)
|
||||
process = subprocess.call(["python", "-u", "PseudoChannel.py", "-g"], stdout=None, stderr=None, stdin=None)
|
||||
process = subprocess.call(["python3", "-u", "PseudoChannel.py", "-g"], stdout=None, stderr=None, stdin=None)
|
||||
os.chdir('../')
|
||||
print("ALERT: ALL DAILY SCHEDULE GENERATION COMPLETE")
|
||||
Reference in New Issue
Block a user