mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-30 15:03:13 +00:00
Added html background image for series to shows DB for retrieval in the controller.
This commit is contained in:
@@ -29,13 +29,16 @@ def dump(obj):
|
||||
for attr in dir(obj):
|
||||
print "obj.%s = %s" % (attr, getattr(obj, attr))
|
||||
|
||||
def get_media_photo(sectionTitle, seriesTitle):
|
||||
def get_show_photo(seriesTitle):
|
||||
|
||||
last_episode = plex.library.section(sectionTitle).get(seriesTitle)
|
||||
c.execute("SELECT fullImageURL FROM shows WHERE title = ? COLLATE NOCASE", (seriesTitle, ))
|
||||
|
||||
backgroundImgURL = baseurl+last_episode.art+"?X-Plex-Token="+token
|
||||
datalist = list(c.fetchone())
|
||||
|
||||
print(baseurl+last_episode.art+"?X-Plex-Token="+token)
|
||||
backgroundImgURL = ''
|
||||
|
||||
if len(datalist):
|
||||
backgroundImgURL = datalist[0]
|
||||
|
||||
return backgroundImgURL
|
||||
|
||||
@@ -254,7 +257,7 @@ def tv_controller():
|
||||
|
||||
play_media("TV Shows", row[6], row[3])
|
||||
|
||||
write_schedule_to_file(get_html_from_daily_schedule(timeB, get_media_photo('TV Shows', row[6])))
|
||||
write_schedule_to_file(get_html_from_daily_schedule(timeB, get_show_photo(row[6])))
|
||||
|
||||
my_logger.debug('Trying to play: ' + row[3])
|
||||
|
||||
@@ -269,6 +272,8 @@ def tv_controller():
|
||||
|
||||
tv_controller()
|
||||
|
||||
# print(get_show_photo("the office"))
|
||||
|
||||
# get_media_photo()
|
||||
|
||||
#showConnectedClients()
|
||||
|
||||
@@ -17,7 +17,7 @@ c = conn.cursor()
|
||||
|
||||
def create_tables():
|
||||
c.execute('CREATE TABLE IF NOT EXISTS movies(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER)')
|
||||
c.execute('CREATE TABLE IF NOT EXISTS shows(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, lastEpisodeTitle TEXT)')
|
||||
c.execute('CREATE TABLE IF NOT EXISTS shows(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, lastEpisodeTitle TEXT, fullImageURL TEXT)')
|
||||
c.execute('CREATE TABLE IF NOT EXISTS episodes(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, episodeNumber INTEGER, seasonNumber INTEGER, showTitle TEXT)')
|
||||
c.execute('CREATE TABLE IF NOT EXISTS commercials(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER)')
|
||||
c.execute('CREATE TABLE IF NOT EXISTS schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, startTime INTEGER, endTime INTEGER, dayOfWeek TEXT, startTimeUnix INTEGER)')
|
||||
@@ -38,10 +38,10 @@ def add_movies_to_db(mediaID, title, duration):
|
||||
conn.rollback()
|
||||
raise e
|
||||
|
||||
def add_shows_to_db(mediaID, title, duration, lastEpisodeTitle):
|
||||
def add_shows_to_db(mediaID, title, duration, lastEpisodeTitle, fullImageURL):
|
||||
unix = int(time.time())
|
||||
try:
|
||||
c.execute("INSERT OR REPLACE INTO shows (unix, mediaID, title, duration, lastEpisodeTitle) VALUES (?, ?, ?, ?, ?)", (unix, mediaID, title, duration, lastEpisodeTitle))
|
||||
c.execute("INSERT OR REPLACE INTO shows (unix, mediaID, title, duration, lastEpisodeTitle, fullImageURL) VALUES (?, ?, ?, ?, ?, ?)", (unix, mediaID, title, duration, lastEpisodeTitle, fullImageURL))
|
||||
conn.commit()
|
||||
# Catch the exception
|
||||
except Exception as e:
|
||||
@@ -83,29 +83,60 @@ def add_schedule_to_db(mediaID, title, duration, startTime, endTime, dayOfWeek):
|
||||
raise e
|
||||
|
||||
def update_db_with_media():
|
||||
|
||||
sections = plex.library.sections()
|
||||
|
||||
for section in sections:
|
||||
|
||||
if section.title == "Movies":
|
||||
|
||||
sectionMedia = plex.library.section(section.title).all()
|
||||
|
||||
for media in sectionMedia:
|
||||
|
||||
add_movies_to_db(1, media.title, media.duration)
|
||||
|
||||
elif section.title == "TV Shows":
|
||||
|
||||
sectionMedia = plex.library.section(section.title).all()
|
||||
|
||||
for media in sectionMedia:
|
||||
add_shows_to_db(2, media.title, media.duration, '')
|
||||
|
||||
backgroundImagePath = plex.library.section(section.title).get(media.title)
|
||||
|
||||
backgroundImgURL = ''
|
||||
|
||||
if isinstance(backgroundImagePath.art, str):
|
||||
|
||||
backgroundImgURL = baseurl+backgroundImagePath.art+"?X-Plex-Token="+token
|
||||
|
||||
add_shows_to_db(2, media.title, media.duration, '', backgroundImgURL)
|
||||
|
||||
#add all episodes of each tv show to episodes table
|
||||
episodes = plex.library.section(section.title).get(media.title).episodes()
|
||||
|
||||
for episode in episodes:
|
||||
|
||||
duration = episode.duration
|
||||
|
||||
if duration:
|
||||
|
||||
add_episodes_to_db(4, episode.title, duration, episode.index, episode.parentIndex, media.title)
|
||||
|
||||
else:
|
||||
|
||||
add_episodes_to_db(4, episode.title, 0, episode.index, episode.parentIndex, media.title)
|
||||
|
||||
elif section.title == "Commercials":
|
||||
|
||||
sectionMedia = plex.library.section(section.title).all()
|
||||
|
||||
for media in sectionMedia:
|
||||
|
||||
add_commercials_to_db(3, media.title, media.duration)
|
||||
|
||||
c.close()
|
||||
|
||||
conn.close()
|
||||
|
||||
def update_db_with_media_test():
|
||||
|
||||
Reference in New Issue
Block a user