mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-21 18:53:42 +00:00
Kevin Bacon mode bug fixes and polish
Fixed bugs in Kevin Bacon Mode Added function to expose actor and previous movie in the showTitle field of Kevin Bacon generated movies
This commit is contained in:
@@ -662,6 +662,9 @@ class PseudoChannel():
|
|||||||
schedule_advance_watcher = 0
|
schedule_advance_watcher = 0
|
||||||
xtraSeason = None
|
xtraSeason = None
|
||||||
xtraEpisode = None
|
xtraEpisode = None
|
||||||
|
actors_list = {}
|
||||||
|
prev_actors = []
|
||||||
|
prev_movies = []
|
||||||
for entry in schedule:
|
for entry in schedule:
|
||||||
schedule_advance_watcher += 1
|
schedule_advance_watcher += 1
|
||||||
section = entry[9]
|
section = entry[9]
|
||||||
@@ -888,6 +891,7 @@ class PseudoChannel():
|
|||||||
#next_episode[8] if len(next_episode) >= 9 else '', # plex id
|
#next_episode[8] if len(next_episode) >= 9 else '', # plex id
|
||||||
next_episode[8], #plex id
|
next_episode[8], #plex id
|
||||||
customSectionName, # custom lib name
|
customSectionName, # custom lib name
|
||||||
|
2, #media_id
|
||||||
show_title, # show_series_title
|
show_title, # show_series_title
|
||||||
next_episode[5], # episode_number
|
next_episode[5], # episode_number
|
||||||
next_episode[6], # season_number
|
next_episode[6], # season_number
|
||||||
@@ -896,13 +900,14 @@ class PseudoChannel():
|
|||||||
else:
|
else:
|
||||||
print("ERROR: Cannot find TV Show Episode, {} in the local db".format(entry[3]))
|
print("ERROR: Cannot find TV Show Episode, {} in the local db".format(entry[3]))
|
||||||
elif section == "Movies":
|
elif section == "Movies":
|
||||||
|
minmax = entry[4].split(",")
|
||||||
|
min = int(minmax[0])
|
||||||
|
min = min * 60000
|
||||||
|
max = int(minmax[1])
|
||||||
|
max = max * 60000
|
||||||
|
movies_list = []
|
||||||
|
movies_list_filtered = []
|
||||||
if str(entry[3]).lower() == "random":
|
if str(entry[3]).lower() == "random":
|
||||||
minmax = entry[4].split(",")
|
|
||||||
min = int(minmax[0])
|
|
||||||
min = min * 60000
|
|
||||||
max = int(minmax[1])
|
|
||||||
max = max * 60000
|
|
||||||
movies_list = []
|
|
||||||
if(entry[13] != ''): # xtra params
|
if(entry[13] != ''): # xtra params
|
||||||
"""
|
"""
|
||||||
Using specified Movies library names
|
Using specified Movies library names
|
||||||
@@ -914,6 +919,7 @@ class PseudoChannel():
|
|||||||
for correct_lib_name, user_lib_name in libs_dict.items():
|
for correct_lib_name, user_lib_name in libs_dict.items():
|
||||||
if theSection.title.lower() in [x.lower() for x in user_lib_name]:
|
if theSection.title.lower() in [x.lower() for x in user_lib_name]:
|
||||||
if correct_lib_name == "Movies" and entry[13] != "":
|
if correct_lib_name == "Movies" and entry[13] != "":
|
||||||
|
print("----------------------------------")
|
||||||
print("INFO: Movie Xtra Arguments: ", entry[13])
|
print("INFO: Movie Xtra Arguments: ", entry[13])
|
||||||
movies = self.PLEX.library.section(theSection.title)
|
movies = self.PLEX.library.section(theSection.title)
|
||||||
xtra = []
|
xtra = []
|
||||||
@@ -938,11 +944,29 @@ class PseudoChannel():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if (len(movies_list) > 0):
|
if (len(movies_list) > 0):
|
||||||
the_movie = self.db.get_movie(random.choice(movies_list).title)
|
movie_get = random.choice(movies_list)
|
||||||
|
movies_list.remove(movie_get)
|
||||||
|
try:
|
||||||
|
print("INFO: Movie Title - " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie_by_id(movie_get.key)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: Key not found")
|
||||||
|
print(e)
|
||||||
|
print("INFO: " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie(movie_get.title)
|
||||||
movie_duration = the_movie[4]
|
movie_duration = the_movie[4]
|
||||||
attempt = 1
|
attempt = 1
|
||||||
while int(movie_duration) < min or movie_duration > max:
|
while int(movie_duration) < min or movie_duration > max:
|
||||||
the_movie = self.db.get_movie(random.choice(movies_list).title)
|
movie_get = random.choice(movies_list)
|
||||||
|
movies_list.remove(movie_get)
|
||||||
|
try:
|
||||||
|
print("INFO: Movie Title - " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie_by_id(movie_get.key)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: Key not found")
|
||||||
|
print(e)
|
||||||
|
print("INFO: " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie(movie_get.title)
|
||||||
attempt = attempt + 1
|
attempt = attempt + 1
|
||||||
if attempt > 500:
|
if attempt > 500:
|
||||||
movie_duration = max
|
movie_duration = max
|
||||||
@@ -953,6 +977,7 @@ class PseudoChannel():
|
|||||||
else:
|
else:
|
||||||
print("ERROR: xtra args not found, getting random movie")
|
print("ERROR: xtra args not found, getting random movie")
|
||||||
the_movie = self.db.get_random_movie_duration(int(min), int(max))
|
the_movie = self.db.get_random_movie_duration(int(min), int(max))
|
||||||
|
print("INFO: Movie Title - " + str(the_movie[3]))
|
||||||
movie_duration = the_movie[4]
|
movie_duration = the_movie[4]
|
||||||
attempt = 1
|
attempt = 1
|
||||||
while int(movie_duration) < min or movie_duration > max:
|
while int(movie_duration) < min or movie_duration > max:
|
||||||
@@ -964,7 +989,7 @@ class PseudoChannel():
|
|||||||
movie_duration = the_movie[4]
|
movie_duration = the_movie[4]
|
||||||
"""Updating movies table in the db with lastPlayedDate entry"""
|
"""Updating movies table in the db with lastPlayedDate entry"""
|
||||||
self.db.update_movies_table_with_last_played_date(the_movie[3])
|
self.db.update_movies_table_with_last_played_date(the_movie[3])
|
||||||
minmax = str(entry[4]).split(",")
|
"""minmax = str(entry[4]).split(",")
|
||||||
min = int(minmax[0])
|
min = int(minmax[0])
|
||||||
min = min * 60000
|
min = min * 60000
|
||||||
max = int(minmax[1])
|
max = int(minmax[1])
|
||||||
@@ -982,11 +1007,301 @@ class PseudoChannel():
|
|||||||
movies_list = []
|
movies_list = []
|
||||||
libs_dict = config.plexLibraries
|
libs_dict = config.plexLibraries
|
||||||
sections = self.PLEX.library.sections()
|
sections = self.PLEX.library.sections()
|
||||||
"""Updating movies table in the db with lastPlayedDate entry"""
|
#Updating movies table in the db with lastPlayedDate entry
|
||||||
self.db.update_movies_table_with_last_played_date(the_movie[3])
|
self.db.update_movies_table_with_last_played_date(the_movie[3])"""
|
||||||
|
elif str(entry[3]).lower() == "kevinbacon":
|
||||||
|
#kevin bacon mode
|
||||||
|
print("----------------------------------")
|
||||||
|
print("NOTICE: Kevin Bacon Mode Initiated")
|
||||||
|
backup_list = []
|
||||||
|
delete_list = []
|
||||||
|
xtra = []
|
||||||
|
for k in actors_list:
|
||||||
|
if actors_list[k] in prev_actors:
|
||||||
|
delete_list.append(k)
|
||||||
|
for dL in delete_list:
|
||||||
|
actors_list.pop(dL)
|
||||||
|
"""
|
||||||
|
Using specified Movies library names
|
||||||
|
"""
|
||||||
|
libs_dict = config.plexLibraries
|
||||||
|
|
||||||
|
sections = self.PLEX.library.sections()
|
||||||
|
for theSection in sections:
|
||||||
|
for correct_lib_name, user_lib_name in libs_dict.items():
|
||||||
|
if theSection.title.lower() in [x.lower() for x in user_lib_name]:
|
||||||
|
if correct_lib_name == "Movies":
|
||||||
|
movies = self.PLEX.library.section(theSection.title)
|
||||||
|
if(entry[13] != '' or len(actors_list) > 0): # xtra params
|
||||||
|
xtra = []
|
||||||
|
try:
|
||||||
|
print("INFO: Movie Xtra Arguments: ", entry[13])
|
||||||
|
except:
|
||||||
|
print("INFO: Xtra Arguments Not Found")
|
||||||
|
d = {}
|
||||||
|
if len(actors_list) > 0:
|
||||||
|
for actorName in actors_list:
|
||||||
|
xtra = []
|
||||||
|
if ";" in entry[13]:
|
||||||
|
xtra = entry[13].split(';')
|
||||||
|
elif entry[13] != '':
|
||||||
|
xtra.append(str(entry[13]))
|
||||||
|
#xtra = xtra.split(';')
|
||||||
|
else:
|
||||||
|
xtra = []
|
||||||
|
actorID = actors_list[actorName]
|
||||||
|
print("----------------------------------")
|
||||||
|
print("INFO: Actor from " + last_movie + " selected - " + actorName)
|
||||||
|
try:
|
||||||
|
#print("NOTICE: Appending " + actorName + " to xtra args")
|
||||||
|
xtra.append("actor:"+str(actorID))
|
||||||
|
except:
|
||||||
|
#print("ERROR: Appending failed, creating new list with actor name")
|
||||||
|
xtra = ["actor:"+str(actorID)]
|
||||||
|
print("INFO: xtra args: " + str(xtra))
|
||||||
|
try:
|
||||||
|
for thestr in xtra:
|
||||||
|
#print ("INFO: "+thestr)
|
||||||
|
regex = re.compile(r"\b(\w+)\s*:\s*([^:]*)(?=\s+\w+\s*:|$)")
|
||||||
|
d.update(regex.findall(thestr))
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: " + str(e))
|
||||||
|
pass
|
||||||
|
#print("NOTICE: turning xtra values into a dict")
|
||||||
|
try:
|
||||||
|
for key, val in d.items():
|
||||||
|
d[key] = val.split(',')
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: " + str(e))
|
||||||
|
pass
|
||||||
|
print("NOTICE: Executing movies search for matches")
|
||||||
|
try:
|
||||||
|
movie_search = movies.search(None, **d)
|
||||||
|
print("INFO: " + str(len(movie_search)) + " results found")
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
for movie in movie_search:
|
||||||
|
if movie not in movies_list and movie.title not in last_movie:
|
||||||
|
print(str(movie.title))
|
||||||
|
movies_list.append(movie)
|
||||||
|
#print("INFO: Match Found - " + str(movie))
|
||||||
|
#for movie in movies.search(None, **d):
|
||||||
|
# movies_list.append(movie)
|
||||||
|
# print("INFO: Match Found - " + str(movie))
|
||||||
|
#except Exception as e:
|
||||||
|
# print("ERROR: " + str(e))
|
||||||
|
# pass
|
||||||
|
#print("INFO: Movies List: " + str(movies_list))
|
||||||
|
else:
|
||||||
|
print("NOTICE: No previous actor data, skipping...")
|
||||||
|
if ";" in entry[13]:
|
||||||
|
xtra = entry[13].split(';')
|
||||||
|
else:
|
||||||
|
if entry[13] != None:
|
||||||
|
xtra = str(entry[13]) + ';'
|
||||||
|
xtra = xtra.split(';')
|
||||||
|
print(xtra)
|
||||||
|
try:
|
||||||
|
for thestr in xtra:
|
||||||
|
print ("INFO: "+thestr)
|
||||||
|
regex = re.compile(r"\b(\w+)\s*:\s*([^:]*)(?=\s+\w+\s*:|$)")
|
||||||
|
d.update(regex.findall(thestr))
|
||||||
|
# turn values into list
|
||||||
|
for key, val in d.items():
|
||||||
|
d[key] = val.split(',')
|
||||||
|
for movie in movies.search(None, **d):
|
||||||
|
movies_list.append(movie)
|
||||||
|
#print("INFO: Match Found - " + movie)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: " + str(e))
|
||||||
|
pass
|
||||||
|
#print(xtra)
|
||||||
|
|
||||||
|
if (len(movies_list) > 0):
|
||||||
|
print("----------------------------------")
|
||||||
|
print("INFO: " + str(len(movies_list)) + " movies in list")
|
||||||
|
movie_get = random.choice(movies_list)
|
||||||
|
movies_list.remove(movie_get)
|
||||||
|
try:
|
||||||
|
print("INFO: Movie Title - " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie_by_id(movie_get.key)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: Key not found")
|
||||||
|
print(e)
|
||||||
|
print("INFO: " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie(movie_get.title)
|
||||||
|
attempt = 1
|
||||||
|
while the_movie[6] in prev_movies and last_movie in the_movie[3] and attempt < 500:
|
||||||
|
movie_get = random.choice(movies_list)
|
||||||
|
try:
|
||||||
|
print("INFO: Movie Title - " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie_by_id(movie_get.key)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: Key not found")
|
||||||
|
print(e)
|
||||||
|
print("INFO: " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie(movie_get.title)
|
||||||
|
attempt = attempt + 1
|
||||||
|
movie_duration = the_movie[4]
|
||||||
|
attempt = 1
|
||||||
|
while int(movie_duration) < min or movie_duration > max:
|
||||||
|
if len(movies_list) > 0:
|
||||||
|
movie_get = random.choice(movies_list)
|
||||||
|
movies_list.remove(movie_get)
|
||||||
|
try:
|
||||||
|
print("INFO: Movie Title - " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie_by_id(movie_get.key)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: Key not found")
|
||||||
|
print(e)
|
||||||
|
print("INFO: " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie(movie_get.title)
|
||||||
|
else:
|
||||||
|
the_movie = self.db.get_random_movie_duration(int(min), int(max))
|
||||||
|
print("ERROR: Falling back to random movie that fits in the duration window")
|
||||||
|
print("INFO: Movie Title - " + str(the_movie[3]))
|
||||||
|
attempt = attempt + 1
|
||||||
|
if attempt > 500:
|
||||||
|
movie_duration = max
|
||||||
|
else:
|
||||||
|
movie_duration = the_movie[4]
|
||||||
|
"""Updating movies table in the db with lastPlayedDate entry"""
|
||||||
|
self.db.update_movies_table_with_last_played_date(the_movie[3])
|
||||||
|
else:
|
||||||
|
print("ERROR: No movies found, re-rolling without xtra args")
|
||||||
|
d = {}
|
||||||
|
if len(actors_list) > 0:
|
||||||
|
for actorName in actors_list:
|
||||||
|
actorID = actors_list[actorName]
|
||||||
|
print("INFO: Actor from " + last_movie + " selected - " + actorName)
|
||||||
|
try:
|
||||||
|
xtra = xtra.append("actor:"+str(actorID))
|
||||||
|
except:
|
||||||
|
xtra = ["actor:"+str(actorID)]
|
||||||
|
try:
|
||||||
|
for thestr in xtra:
|
||||||
|
print ("INFO: "+thestr)
|
||||||
|
regex = re.compile(r"\b(\w+)\s*:\s*([^:]*)(?=\s+\w+\s*:|$)")
|
||||||
|
d.update(regex.findall(thestr))
|
||||||
|
# turn values into list
|
||||||
|
for key, val in d.items():
|
||||||
|
d[key] = val.split(',')
|
||||||
|
movie_search = movies.search(None, **d)
|
||||||
|
for movie in movie_search:
|
||||||
|
print(str(movie.title))
|
||||||
|
if movie not in movies_list and movie.title not in last_movie:
|
||||||
|
print(str(movie.title))
|
||||||
|
movies_list.append(movie)
|
||||||
|
#print("INFO: Match Found - " + movie)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: " + str(e))
|
||||||
|
pass
|
||||||
|
print("INFO: " + str(len(movie_search)) + " results found")
|
||||||
|
|
||||||
|
if (len(movies_list) > 0):
|
||||||
|
print("----------------------------------")
|
||||||
|
print("INFO: " + str(len(movies_list)) + " movies in list")
|
||||||
|
movie_get = random.choice(movies_list)
|
||||||
|
movies_list.remove(movie_get)
|
||||||
|
try:
|
||||||
|
print("INFO: Movie Title - " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie_by_id(movie_get.key)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: Key not found")
|
||||||
|
print(e)
|
||||||
|
print("INFO: " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie(movie_get.title)
|
||||||
|
attempt = 1
|
||||||
|
while the_movie[6] in prev_movies and last_movie in the_movie[3]and attempt < 500:
|
||||||
|
movie_get = random.choice(movies_list)
|
||||||
|
movies_list.remove(movie_get)
|
||||||
|
try:
|
||||||
|
print("INFO: Movie Title - " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie_by_id(movie_get.key)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: Key not found")
|
||||||
|
print(e)
|
||||||
|
print("INFO: " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie(movie_get.title)
|
||||||
|
attempt = attempt + 1
|
||||||
|
attempt = 1
|
||||||
|
movie_duration = the_movie[4]
|
||||||
|
while int(movie_duration) < min or movie_duration > max:
|
||||||
|
if len(movies_list) > 0:
|
||||||
|
try:
|
||||||
|
movies_list.remove(the_movie)
|
||||||
|
except Exception as e:
|
||||||
|
print(the_movie)
|
||||||
|
print(e)
|
||||||
|
movie_get = random.choice(movies_list)
|
||||||
|
try:
|
||||||
|
print("INFO: Movie Title - " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie_by_id(movie_get.key)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: Key not found")
|
||||||
|
print(e)
|
||||||
|
print("INFO: " + movie_get.title)
|
||||||
|
the_movie = self.db.get_movie(movie_get.title)
|
||||||
|
else:
|
||||||
|
the_movie = self.db.get_random_movie_duration(int(min), int(max))
|
||||||
|
print("ERROR: Falling back to random movie that fits in the duration window")
|
||||||
|
print("INFO: Movie Title - " + str(the_movie[3]))
|
||||||
|
attempt = attempt + 1
|
||||||
|
if attempt > 500:
|
||||||
|
movie_duration = max
|
||||||
|
else:
|
||||||
|
movie_duration = the_movie[4]
|
||||||
|
else:
|
||||||
|
print("ERROR: Kevin Bacon Mode failed to find a match, selecting random movie")
|
||||||
|
the_movie = self.db.get_random_movie_duration(int(min), int(max))
|
||||||
|
print("INFO: Movie Title - " + str(the_movie[3]))
|
||||||
|
movie_duration = the_movie[4]
|
||||||
|
attempt = 1
|
||||||
|
while int(movie_duration) < min or movie_duration > max:
|
||||||
|
the_movie = self.db.get_random_movie_duration(int(min), int(max))
|
||||||
|
attempt = attempt + 1
|
||||||
|
if attempt > 500:
|
||||||
|
movie_duration = max
|
||||||
|
else:
|
||||||
|
movie_duration = the_movie[4]
|
||||||
|
"""Updating movies table in the db with lastPlayedDate entry"""
|
||||||
|
self.db.update_movies_table_with_last_played_date(the_movie[3])
|
||||||
|
try:
|
||||||
|
prev_actors.append(actorID)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
prev_movies.append(the_movie[6])
|
||||||
|
#last_movie = the_movie[3]
|
||||||
|
"""Updating movies table in the db with lastPlayedDate entry"""
|
||||||
|
self.db.update_movies_table_with_last_played_date(the_movie[3])
|
||||||
else:
|
else:
|
||||||
the_movie = self.db.get_movie(entry[3])
|
the_movie = self.db.get_movie(entry[3])
|
||||||
|
if str(entry[3]).lower() == "kevinbacon":
|
||||||
|
media_id = 112
|
||||||
|
else:
|
||||||
|
media_id = 1
|
||||||
if the_movie != None:
|
if the_movie != None:
|
||||||
|
print("----------------------------------")
|
||||||
|
print("NOTICE: Movie Selected - " + the_movie[3])
|
||||||
|
#get plex metadata
|
||||||
|
plex_movie = self.PLEX.fetchItem(the_movie[6])
|
||||||
|
if str(entry[3]).lower() == "kevinbacon":
|
||||||
|
actors_list_old = actors_list
|
||||||
|
actors_list = {}
|
||||||
|
actor_match = ""
|
||||||
|
print("NOTICE: Replacing Actors List with list from " + the_movie[3])
|
||||||
|
for actor in plex_movie.actors:
|
||||||
|
actors_list[actor.tag] = actor.id
|
||||||
|
if actor.tag in actors_list_old.keys():
|
||||||
|
print("INFO: Match between movies - " + actor.tag)
|
||||||
|
prev_actors.append(actor.id)
|
||||||
|
if actor_match == "":
|
||||||
|
actor_match = actor.tag
|
||||||
|
if actor_match != "":
|
||||||
|
last_data = actor_match + "," + last_movie
|
||||||
|
else:
|
||||||
|
last_data = ""
|
||||||
|
last_movie = the_movie[3]
|
||||||
movie = Movie(
|
movie = Movie(
|
||||||
section, # section_type
|
section, # section_type
|
||||||
the_movie[3], # title
|
the_movie[3], # title
|
||||||
@@ -998,7 +1313,9 @@ class PseudoChannel():
|
|||||||
entry[11], # time_shift
|
entry[11], # time_shift
|
||||||
entry[12], # overlap_max
|
entry[12], # overlap_max
|
||||||
the_movie[6], # plex id
|
the_movie[6], # plex id
|
||||||
the_movie[7] # custom lib name
|
the_movie[7], # custom lib name
|
||||||
|
media_id, # media_id
|
||||||
|
last_data # show_series_title (for storing kevin bacon data)
|
||||||
)
|
)
|
||||||
self.MEDIA.append(movie)
|
self.MEDIA.append(movie)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ class Commercial(Media):
|
|||||||
time_shift,
|
time_shift,
|
||||||
overlap_max,
|
overlap_max,
|
||||||
plex_media_id,
|
plex_media_id,
|
||||||
custom_section_name
|
custom_section_name,
|
||||||
|
media_id
|
||||||
):
|
):
|
||||||
|
|
||||||
super(Commercial, self).__init__(
|
super(Commercial, self).__init__(
|
||||||
@@ -42,5 +43,6 @@ class Commercial(Media):
|
|||||||
time_shift,
|
time_shift,
|
||||||
overlap_max,
|
overlap_max,
|
||||||
plex_media_id,
|
plex_media_id,
|
||||||
custom_section_name
|
custom_section_name,
|
||||||
|
media_id
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class Episode(Media):
|
|||||||
overlap_max,
|
overlap_max,
|
||||||
plex_media_id,
|
plex_media_id,
|
||||||
custom_section_name,
|
custom_section_name,
|
||||||
|
media_id,
|
||||||
show_series_title,
|
show_series_title,
|
||||||
episode_number,
|
episode_number,
|
||||||
season_number,
|
season_number,
|
||||||
@@ -49,6 +50,7 @@ class Episode(Media):
|
|||||||
overlap_max,
|
overlap_max,
|
||||||
plex_media_id,
|
plex_media_id,
|
||||||
custom_section_name,
|
custom_section_name,
|
||||||
|
media_id
|
||||||
)
|
)
|
||||||
|
|
||||||
self.show_series_title = show_series_title
|
self.show_series_title = show_series_title
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ class Media(object):
|
|||||||
time_shift,
|
time_shift,
|
||||||
overlap_max,
|
overlap_max,
|
||||||
plex_media_id,
|
plex_media_id,
|
||||||
custom_section_name
|
custom_section_name,
|
||||||
|
media_id
|
||||||
):
|
):
|
||||||
|
|
||||||
self.section_type = section_type
|
self.section_type = section_type
|
||||||
@@ -47,6 +48,7 @@ class Media(object):
|
|||||||
self.overlap_max = overlap_max
|
self.overlap_max = overlap_max
|
||||||
self.plex_media_id = plex_media_id
|
self.plex_media_id = plex_media_id
|
||||||
self.custom_section_name = custom_section_name
|
self.custom_section_name = custom_section_name
|
||||||
|
self.media_id = media_id
|
||||||
|
|
||||||
self.start_time = natural_start_time
|
self.start_time = natural_start_time
|
||||||
self.end_time = natural_end_time
|
self.end_time = natural_end_time
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ class Movie(Media):
|
|||||||
time_shift,
|
time_shift,
|
||||||
overlap_max,
|
overlap_max,
|
||||||
plex_media_id,
|
plex_media_id,
|
||||||
custom_section_name
|
custom_section_name,
|
||||||
|
media_id,
|
||||||
|
show_series_title
|
||||||
):
|
):
|
||||||
|
|
||||||
super(Movie, self).__init__(
|
super(Movie, self).__init__(
|
||||||
@@ -42,5 +44,8 @@ class Movie(Media):
|
|||||||
time_shift,
|
time_shift,
|
||||||
overlap_max,
|
overlap_max,
|
||||||
plex_media_id,
|
plex_media_id,
|
||||||
custom_section_name
|
custom_section_name,
|
||||||
|
media_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.show_series_title = show_series_title
|
||||||
@@ -121,6 +121,7 @@ class PseudoChannelCommercial():
|
|||||||
"0", # overlap_max
|
"0", # overlap_max
|
||||||
random_commercial[5], # plex_media_id
|
random_commercial[5], # plex_media_id
|
||||||
random_commercial[6], # custom lib name
|
random_commercial[6], # custom lib name
|
||||||
|
"3" #media_id
|
||||||
)
|
)
|
||||||
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:
|
||||||
@@ -165,6 +166,7 @@ class PseudoChannelCommercial():
|
|||||||
"0", # overlap_max
|
"0", # overlap_max
|
||||||
random_final_comm[5], # plex_media_id
|
random_final_comm[5], # plex_media_id
|
||||||
random_final_comm[6], # custom lib name
|
random_final_comm[6], # custom lib name
|
||||||
|
"3" #media_id
|
||||||
)
|
)
|
||||||
commercial_list.append(final_commercial)
|
commercial_list.append(final_commercial)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -330,13 +330,18 @@ class PseudoChannelDatabase():
|
|||||||
#print(str("{}: {} - {}".format(media.start_time, media.title, media.custom_section_name)).encode('UTF-8'))
|
#print(str("{}: {} - {}".format(media.start_time, media.title, media.custom_section_name)).encode('UTF-8'))
|
||||||
except:
|
except:
|
||||||
print("ERROR: Not outputting media info due to ascii code issues.")
|
print("ERROR: Not outputting media info due to ascii code issues.")
|
||||||
|
if media.__class__.__name__ == "Episode":
|
||||||
|
seriesTitle = media.show_series_title
|
||||||
|
elif media.media_id == 112:
|
||||||
|
seriesTitle = media.show_series_title
|
||||||
|
else:
|
||||||
|
seriesTitle = ''
|
||||||
self.add_daily_schedule_to_db(
|
self.add_daily_schedule_to_db(
|
||||||
0,
|
media.media_id if media.__class__.__name__ == "Movie" else 0,
|
||||||
media.title,
|
media.title,
|
||||||
media.episode_number if media.__class__.__name__ == "Episode" else 0,
|
media.episode_number if media.__class__.__name__ == "Episode" else 0,
|
||||||
media.season_number if media.__class__.__name__ == "Episode" else 0,
|
media.season_number if media.__class__.__name__ == "Episode" else 0,
|
||||||
media.show_series_title if media.__class__.__name__ == "Episode" else '',
|
seriesTitle,
|
||||||
media.duration,
|
media.duration,
|
||||||
media.start_time,
|
media.start_time,
|
||||||
media.end_time,
|
media.end_time,
|
||||||
@@ -470,6 +475,17 @@ class PseudoChannelDatabase():
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_media_by_id(self, plex_media_id, mediaType):
|
||||||
|
print("INFO: plex_media_id:", plex_media_id)
|
||||||
|
if(plex_media_id is not None):
|
||||||
|
media = mediaType
|
||||||
|
sql = "SELECT * FROM "+media+" WHERE (plexMediaID LIKE ?) COLLATE NOCASE"
|
||||||
|
self.cursor.execute(sql, (plex_media_id, ))
|
||||||
|
media_item = self.cursor.fetchone()
|
||||||
|
return media_item
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
def get_schedule(self):
|
def get_schedule(self):
|
||||||
|
|
||||||
self.cursor.execute("SELECT * FROM schedule ORDER BY datetime(startTime) ASC")
|
self.cursor.execute("SELECT * FROM schedule ORDER BY datetime(startTime) ASC")
|
||||||
@@ -500,6 +516,11 @@ class PseudoChannelDatabase():
|
|||||||
media = "movies"
|
media = "movies"
|
||||||
return self.get_media(title, media)
|
return self.get_media(title, media)
|
||||||
|
|
||||||
|
def get_movie_by_id(self, plex_media_id):
|
||||||
|
|
||||||
|
media = "movies"
|
||||||
|
return self.get_media_by_id(plex_media_id, media)
|
||||||
|
|
||||||
def get_shows(self, title):
|
def get_shows(self, title):
|
||||||
|
|
||||||
media = "shows"
|
media = "shows"
|
||||||
|
|||||||
Reference in New Issue
Block a user