fixed scheduling bugs

This commit is contained in:
Moe Fwacky
2021-08-08 11:12:19 -07:00
committed by GitHub
parent cf391272c3
commit acba2712ba
2 changed files with 68 additions and 46 deletions

View File

@@ -930,13 +930,16 @@ class PseudoChannelDatabase():
def get_random_show_data(self,section,min,max,airDate,genres,actors,similar,rating,studios):
print("INFO: " + str(min) + ', ' + str(max) + ', ' + str(airDate) + ', ' + str(genres) + ', ' + str(actors) + ', ' + str(similar) + ', ' + str(rating) + ', ' + str(studios))
if airDate != None:
if airDate != None or airDate != '':
try:
if str(airDate)[3] == '*':
print("INFO: Decade = " + str(airDate)[0:3])
datestring=str(airDate)[0:3]
else:
print("INFO: Air Date = " + str(airDate))
datestring=airDate
except:
datestring = None
else:
datestring = None
genresList = []
@@ -949,6 +952,7 @@ class PseudoChannelDatabase():
tvRatingsUK = ['U','12A','15','18','R18']
print("INFO: "+section)
if rating != None:
try:
ratingsAllowed = []
rating=rating.split(',')
if rating[0] == 'US':
@@ -980,6 +984,8 @@ class PseudoChannelDatabase():
ratings = ratings + ', ' + ratingsList[ratingPos]
ratingsAllowed.append(ratingsList[ratingPos])
ratingPos = ratingPos + 1
except:
ratingsAllowed = []
if genres != None and ',' in genres:
genres=genres.replace("'",r"''").replace('"',r'""').split(',')
for genre in genres:
@@ -1016,9 +1022,12 @@ class PseudoChannelDatabase():
print("INFO: Studio = " + studio)
studiosList.append(studio)
elif studios != None:
try:
studios=studio.replace("'",r"''").replace('"',r'""')
print("INFO: Studio = " + studios)
studiosList.append(studios)
except:
pass
cursor_execute = "SELECT * FROM shows WHERE (customSectionName LIKE \"TV Shows\")"
leading_and = True
if rating != None:
@@ -1123,9 +1132,12 @@ class PseudoChannelDatabase():
if episode != None:
cursor_execute = cursor_execute + " and episodeNumber LIKE \""+str(episode)+"\""
if date != None:
try:
if str(date)[3] == '*':
date = str(date)[0:3]
cursor_execute = cursor_execute + " and airDate LIKE \""+str(date)+"%\""
except:
pass
cursor_execute = cursor_execute + " ORDER BY RANDOM() LIMIT 1"
print("INFO: " + cursor_execute)
self.cursor.execute(cursor_execute)

View File

@@ -41,7 +41,10 @@ def get_playing():
for runningPID in glob.glob(pids):
with open(runningPID) as f:
pid = f.readline()
try:
playing = { runningPID : pid }
except:
playing = None
return playing
def get_last():
@@ -208,7 +211,14 @@ parser.add_argument('-u', '--updatedatabase',
args = parser.parse_args()
if args.channel:
print("STARTING CHANNEL "+args.channel)
print("CHECKING IF PSEUDO CHANNEL IS ALREADY RUNNING")
playing = get_playing()
try:
for channel, pid in playing.items():
print("STOPPING CHANNEL "+channel.replace('/running.pid','').split('_')[1])
stop_channel(channel, pid)
except:
print("NOTICE: Pseudo Channel Not Already Running, STARTING CHANNEL "+args.channel)
start_channel(args.channel)
if args.stop:
playing = get_playing()