mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-06 00:13:38 +00:00
fixed scheduling bugs
This commit is contained in:
@@ -930,13 +930,16 @@ class PseudoChannelDatabase():
|
|||||||
|
|
||||||
def get_random_show_data(self,section,min,max,airDate,genres,actors,similar,rating,studios):
|
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))
|
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 != '':
|
||||||
if str(airDate)[3] == '*':
|
try:
|
||||||
print("INFO: Decade = " + str(airDate)[0:3])
|
if str(airDate)[3] == '*':
|
||||||
datestring=str(airDate)[0:3]
|
print("INFO: Decade = " + str(airDate)[0:3])
|
||||||
else:
|
datestring=str(airDate)[0:3]
|
||||||
print("INFO: Air Date = " + str(airDate))
|
else:
|
||||||
datestring=airDate
|
print("INFO: Air Date = " + str(airDate))
|
||||||
|
datestring=airDate
|
||||||
|
except:
|
||||||
|
datestring = None
|
||||||
else:
|
else:
|
||||||
datestring = None
|
datestring = None
|
||||||
genresList = []
|
genresList = []
|
||||||
@@ -949,37 +952,40 @@ class PseudoChannelDatabase():
|
|||||||
tvRatingsUK = ['U','12A','15','18','R18']
|
tvRatingsUK = ['U','12A','15','18','R18']
|
||||||
print("INFO: "+section)
|
print("INFO: "+section)
|
||||||
if rating != None:
|
if rating != None:
|
||||||
ratingsAllowed = []
|
try:
|
||||||
rating=rating.split(',')
|
ratingsAllowed = []
|
||||||
if rating[0] == 'US':
|
rating=rating.split(',')
|
||||||
ratingsList = tvRatingsUS
|
if rating[0] == 'US':
|
||||||
elif rating[0] == 'AUS':
|
ratingsList = tvRatingsUS
|
||||||
ratingsList = tvRatingsAUS
|
elif rating[0] == 'AUS':
|
||||||
elif rating[0] == 'CA':
|
ratingsList = tvRatingsAUS
|
||||||
ratingsList = tvRatingsCA
|
elif rating[0] == 'CA':
|
||||||
elif rating[0] == 'UK':
|
ratingsList = tvRatingsCA
|
||||||
ratingsList = tvRatingsUK
|
elif rating[0] == 'UK':
|
||||||
else:
|
ratingsList = tvRatingsUK
|
||||||
ratingsList = tvRatingsUS
|
else:
|
||||||
if rating[2] == '=':
|
ratingsList = tvRatingsUS
|
||||||
print("INFO: Rating = " + rating[0] +', ' + rating[1])
|
if rating[2] == '=':
|
||||||
ratingsAllowed.append(rating[1])
|
print("INFO: Rating = " + rating[0] +', ' + rating[1])
|
||||||
elif rating[2] == '<':
|
ratingsAllowed.append(rating[1])
|
||||||
ratingPos = ratingsList.index(rating[1])
|
elif rating[2] == '<':
|
||||||
ratings = ''
|
ratingPos = ratingsList.index(rating[1])
|
||||||
while ratingPos >= 0:
|
ratings = ''
|
||||||
ratings = ratings + ', ' + ratingsList[ratingPos]
|
while ratingPos >= 0:
|
||||||
ratingsAllowed.append(ratingsList[ratingPos])
|
ratings = ratings + ', ' + ratingsList[ratingPos]
|
||||||
ratingPos = ratingPos - 1
|
ratingsAllowed.append(ratingsList[ratingPos])
|
||||||
elif rating[2] == '>':
|
ratingPos = ratingPos - 1
|
||||||
ratingPos = ratingsList.index(rating[1])
|
elif rating[2] == '>':
|
||||||
ratings = ''
|
ratingPos = ratingsList.index(rating[1])
|
||||||
ratingsListLength = len(ratingsList)
|
ratings = ''
|
||||||
print("INFO: Rating = " + rating[0] +', '+rating[1])
|
ratingsListLength = len(ratingsList)
|
||||||
while ratingPos < ratingsListLength:
|
print("INFO: Rating = " + rating[0] +', '+rating[1])
|
||||||
ratings = ratings + ', ' + ratingsList[ratingPos]
|
while ratingPos < ratingsListLength:
|
||||||
ratingsAllowed.append(ratingsList[ratingPos])
|
ratings = ratings + ', ' + ratingsList[ratingPos]
|
||||||
ratingPos = ratingPos + 1
|
ratingsAllowed.append(ratingsList[ratingPos])
|
||||||
|
ratingPos = ratingPos + 1
|
||||||
|
except:
|
||||||
|
ratingsAllowed = []
|
||||||
if genres != None and ',' in genres:
|
if genres != None and ',' in genres:
|
||||||
genres=genres.replace("'",r"''").replace('"',r'""').split(',')
|
genres=genres.replace("'",r"''").replace('"',r'""').split(',')
|
||||||
for genre in genres:
|
for genre in genres:
|
||||||
@@ -1016,9 +1022,12 @@ class PseudoChannelDatabase():
|
|||||||
print("INFO: Studio = " + studio)
|
print("INFO: Studio = " + studio)
|
||||||
studiosList.append(studio)
|
studiosList.append(studio)
|
||||||
elif studios != None:
|
elif studios != None:
|
||||||
studios=studio.replace("'",r"''").replace('"',r'""')
|
try:
|
||||||
print("INFO: Studio = " + studios)
|
studios=studio.replace("'",r"''").replace('"',r'""')
|
||||||
studiosList.append(studios)
|
print("INFO: Studio = " + studios)
|
||||||
|
studiosList.append(studios)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
cursor_execute = "SELECT * FROM shows WHERE (customSectionName LIKE \"TV Shows\")"
|
cursor_execute = "SELECT * FROM shows WHERE (customSectionName LIKE \"TV Shows\")"
|
||||||
leading_and = True
|
leading_and = True
|
||||||
if rating != None:
|
if rating != None:
|
||||||
@@ -1123,9 +1132,12 @@ class PseudoChannelDatabase():
|
|||||||
if episode != None:
|
if episode != None:
|
||||||
cursor_execute = cursor_execute + " and episodeNumber LIKE \""+str(episode)+"\""
|
cursor_execute = cursor_execute + " and episodeNumber LIKE \""+str(episode)+"\""
|
||||||
if date != None:
|
if date != None:
|
||||||
if str(date)[3] == '*':
|
try:
|
||||||
date = str(date)[0:3]
|
if str(date)[3] == '*':
|
||||||
cursor_execute = cursor_execute + " and airDate LIKE \""+str(date)+"%\""
|
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"
|
cursor_execute = cursor_execute + " ORDER BY RANDOM() LIMIT 1"
|
||||||
print("INFO: " + cursor_execute)
|
print("INFO: " + cursor_execute)
|
||||||
self.cursor.execute(cursor_execute)
|
self.cursor.execute(cursor_execute)
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ def get_playing():
|
|||||||
for runningPID in glob.glob(pids):
|
for runningPID in glob.glob(pids):
|
||||||
with open(runningPID) as f:
|
with open(runningPID) as f:
|
||||||
pid = f.readline()
|
pid = f.readline()
|
||||||
playing = { runningPID : pid }
|
try:
|
||||||
|
playing = { runningPID : pid }
|
||||||
|
except:
|
||||||
|
playing = None
|
||||||
return playing
|
return playing
|
||||||
|
|
||||||
def get_last():
|
def get_last():
|
||||||
@@ -208,7 +211,14 @@ parser.add_argument('-u', '--updatedatabase',
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.channel:
|
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)
|
start_channel(args.channel)
|
||||||
if args.stop:
|
if args.stop:
|
||||||
playing = get_playing()
|
playing = get_playing()
|
||||||
|
|||||||
Reference in New Issue
Block a user