mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-19 17:53:20 +00:00
Added in XML output alongside HTML. Also should be generating XML/HTML upon the daily generation of the schedule.
This commit is contained in:
@@ -100,7 +100,7 @@ class PseudoChannel():
|
|||||||
|
|
||||||
for i, media in enumerate(sectionMedia):
|
for i, media in enumerate(sectionMedia):
|
||||||
|
|
||||||
self.db.add_movies_to_db(1, media.title, media.duration)
|
self.db.add_movies_to_db(1, media.title, media.duration, media.key)
|
||||||
|
|
||||||
self.print_progress(
|
self.print_progress(
|
||||||
i + 1,
|
i + 1,
|
||||||
@@ -125,7 +125,7 @@ class PseudoChannel():
|
|||||||
|
|
||||||
backgroundImgURL = config.baseurl+backgroundImagePath.art+"?X-Plex-Token="+config.token
|
backgroundImgURL = config.baseurl+backgroundImagePath.art+"?X-Plex-Token="+config.token
|
||||||
|
|
||||||
self.db.add_shows_to_db(2, media.title, media.duration, '', backgroundImgURL)
|
self.db.add_shows_to_db(2, media.title, media.duration, '', backgroundImgURL, media.key)
|
||||||
|
|
||||||
self.print_progress(
|
self.print_progress(
|
||||||
i + 1,
|
i + 1,
|
||||||
@@ -150,7 +150,8 @@ class PseudoChannel():
|
|||||||
duration,
|
duration,
|
||||||
episode.index,
|
episode.index,
|
||||||
episode.parentIndex,
|
episode.parentIndex,
|
||||||
media.title
|
media.title,
|
||||||
|
episode.key
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -161,7 +162,8 @@ class PseudoChannel():
|
|||||||
0,
|
0,
|
||||||
episode.index,
|
episode.index,
|
||||||
episode.parentIndex,
|
episode.parentIndex,
|
||||||
media.title
|
media.title,
|
||||||
|
episode.key
|
||||||
)
|
)
|
||||||
|
|
||||||
elif correct_lib_name == "Commercials":
|
elif correct_lib_name == "Commercials":
|
||||||
@@ -172,7 +174,7 @@ class PseudoChannel():
|
|||||||
|
|
||||||
for i, media in enumerate(sectionMedia):
|
for i, media in enumerate(sectionMedia):
|
||||||
|
|
||||||
self.db.add_commercials_to_db(3, media.title, media.duration)
|
self.db.add_commercials_to_db(3, media.title, media.duration, media.key)
|
||||||
|
|
||||||
self.print_progress(
|
self.print_progress(
|
||||||
i + 1,
|
i + 1,
|
||||||
@@ -589,6 +591,7 @@ class PseudoChannel():
|
|||||||
entry[10], # is_strict_time
|
entry[10], # is_strict_time
|
||||||
entry[11], # time_shift
|
entry[11], # time_shift
|
||||||
entry[12], # overlap_max
|
entry[12], # overlap_max
|
||||||
|
next_episode[8], # plex id
|
||||||
entry[3], # show_series_title
|
entry[3], # show_series_title
|
||||||
next_episode[5], # episode_number
|
next_episode[5], # episode_number
|
||||||
next_episode[6] # season_number
|
next_episode[6] # season_number
|
||||||
@@ -623,7 +626,8 @@ class PseudoChannel():
|
|||||||
entry[7], # day_of_week
|
entry[7], # day_of_week
|
||||||
entry[10], # is_strict_time
|
entry[10], # is_strict_time
|
||||||
entry[11], # time_shift
|
entry[11], # time_shift
|
||||||
entry[12] # overlap_max
|
entry[12], # overlap_max
|
||||||
|
the_movie[6] # plex id
|
||||||
)
|
)
|
||||||
|
|
||||||
#print(movie.natural_end_time)
|
#print(movie.natural_end_time)
|
||||||
@@ -649,7 +653,8 @@ class PseudoChannel():
|
|||||||
entry[7], # day_of_week
|
entry[7], # day_of_week
|
||||||
entry[10], # is_strict_time
|
entry[10], # is_strict_time
|
||||||
entry[11], # time_shift
|
entry[11], # time_shift
|
||||||
entry[12] # overlap_max
|
entry[12], # overlap_max
|
||||||
|
the_music[6], # plex id
|
||||||
)
|
)
|
||||||
|
|
||||||
#print(music.natural_end_time)
|
#print(music.natural_end_time)
|
||||||
@@ -675,7 +680,8 @@ class PseudoChannel():
|
|||||||
entry[7], # day_of_week
|
entry[7], # day_of_week
|
||||||
entry[10], # is_strict_time
|
entry[10], # is_strict_time
|
||||||
entry[11], # time_shift
|
entry[11], # time_shift
|
||||||
entry[12] # overlap_max
|
entry[12], # overlap_max
|
||||||
|
the_video[6] # plex id
|
||||||
)
|
)
|
||||||
|
|
||||||
#print(music.natural_end_time)
|
#print(music.natural_end_time)
|
||||||
@@ -751,6 +757,10 @@ class PseudoChannel():
|
|||||||
|
|
||||||
previous_episode = entry
|
previous_episode = entry
|
||||||
|
|
||||||
|
def make_xml_schedule(self):
|
||||||
|
|
||||||
|
self.controller.make_xml_schedule(self.db.get_daily_schedule())
|
||||||
|
|
||||||
def get_daily_schedule_as_media_object_list(self):
|
def get_daily_schedule_as_media_object_list(self):
|
||||||
|
|
||||||
for i, item in enumerate(self.db.get_daily_schedule(), start=0):
|
for i, item in enumerate(self.db.get_daily_schedule(), start=0):
|
||||||
@@ -887,6 +897,15 @@ if __name__ == '__main__':
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help='Updates the schedule based on entries in the google calendar.')
|
help='Updates the schedule based on entries in the google calendar.')
|
||||||
|
|
||||||
|
'''
|
||||||
|
*
|
||||||
|
* Make XML / HTML Schedule: "python PseudoChannel.py -m"
|
||||||
|
*
|
||||||
|
'''
|
||||||
|
parser.add_argument('-m',
|
||||||
|
action='store_true',
|
||||||
|
help='Makes the XML / HTML schedule based on the daily_schedule table.')
|
||||||
|
|
||||||
globals().update(vars(parser.parse_args()))
|
globals().update(vars(parser.parse_args()))
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@@ -917,6 +936,10 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
pseudo_channel.show_schedule()
|
pseudo_channel.show_schedule()
|
||||||
|
|
||||||
|
if args.m:
|
||||||
|
|
||||||
|
pseudo_channel.make_xml_schedule()
|
||||||
|
|
||||||
if args.r:
|
if args.r:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -948,6 +971,8 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
pseudo_channel.generate_daily_schedule()
|
pseudo_channel.generate_daily_schedule()
|
||||||
|
|
||||||
|
pseudo_channel.make_xml_schedule()
|
||||||
|
|
||||||
pseudo_channel.controller.tv_controller(pseudo_channel.db.get_daily_schedule())
|
pseudo_channel.controller.tv_controller(pseudo_channel.db.get_daily_schedule())
|
||||||
|
|
||||||
t = datetime.datetime.utcnow()
|
t = datetime.datetime.utcnow()
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ class Commercial(Media):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
):
|
):
|
||||||
|
|
||||||
super(Commercial, self).__init__(
|
super(Commercial, self).__init__(
|
||||||
@@ -38,5 +39,6 @@ class Commercial(Media):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -30,9 +30,10 @@ class Episode(Media):
|
|||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max,
|
overlap_max,
|
||||||
|
plex_media_id,
|
||||||
show_series_title,
|
show_series_title,
|
||||||
episode_number,
|
episode_number,
|
||||||
season_number
|
season_number,
|
||||||
):
|
):
|
||||||
|
|
||||||
super(Episode, self).__init__(
|
super(Episode, self).__init__(
|
||||||
@@ -44,7 +45,8 @@ class Episode(Media):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
)
|
)
|
||||||
|
|
||||||
self.show_series_title = show_series_title
|
self.show_series_title = show_series_title
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ class Media(object):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
):
|
):
|
||||||
|
|
||||||
self.section_type = section_type
|
self.section_type = section_type
|
||||||
@@ -43,6 +44,7 @@ class Media(object):
|
|||||||
self.is_strict_time = is_strict_time
|
self.is_strict_time = is_strict_time
|
||||||
self.time_shift = time_shift
|
self.time_shift = time_shift
|
||||||
self.overlap_max = overlap_max
|
self.overlap_max = overlap_max
|
||||||
|
self.plex_media_id = plex_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
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ class Movie(Media):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
):
|
):
|
||||||
|
|
||||||
super(Movie, self).__init__(
|
super(Movie, self).__init__(
|
||||||
@@ -38,5 +39,6 @@ class Movie(Media):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ class Music(Media):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
):
|
):
|
||||||
|
|
||||||
super(Music, self).__init__(
|
super(Music, self).__init__(
|
||||||
@@ -38,5 +39,6 @@ class Music(Media):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,29 +23,30 @@ class PseudoChannelDatabase():
|
|||||||
|
|
||||||
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
||||||
'movies(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
'movies(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
||||||
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, lastPlayedDate TEXT)')
|
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, '
|
||||||
|
'lastPlayedDate TEXT, plexMediaID TEXT)')
|
||||||
|
|
||||||
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
||||||
'videos(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
'videos(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
||||||
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER)')
|
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, plexMediaID TEXT)')
|
||||||
|
|
||||||
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
||||||
'music(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
'music(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
||||||
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER)')
|
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, plexMediaID TEXT)')
|
||||||
|
|
||||||
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
||||||
'shows(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
'shows(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
||||||
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, '
|
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, '
|
||||||
'lastEpisodeTitle TEXT, fullImageURL TEXT)')
|
'lastEpisodeTitle TEXT, fullImageURL TEXT, plexMediaID TEXT)')
|
||||||
|
|
||||||
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
||||||
'episodes(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
'episodes(id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
||||||
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, '
|
'unix INTEGER, mediaID INTEGER, title TEXT, duration INTEGER, '
|
||||||
'episodeNumber INTEGER, seasonNumber INTEGER, showTitle TEXT)')
|
'episodeNumber INTEGER, seasonNumber INTEGER, showTitle TEXT, plexMediaID TEXT)')
|
||||||
|
|
||||||
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
||||||
'commercials(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, '
|
'commercials(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, '
|
||||||
'mediaID INTEGER, title TEXT, duration INTEGER)')
|
'mediaID INTEGER, title TEXT, duration INTEGER, plexMediaID TEXT)')
|
||||||
|
|
||||||
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
||||||
'schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, '
|
'schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, '
|
||||||
@@ -57,7 +58,7 @@ class PseudoChannelDatabase():
|
|||||||
'daily_schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, '
|
'daily_schedule(id INTEGER PRIMARY KEY AUTOINCREMENT, unix INTEGER, '
|
||||||
'mediaID INTEGER, title TEXT, episodeNumber INTEGER, seasonNumber INTEGER, '
|
'mediaID INTEGER, title TEXT, episodeNumber INTEGER, seasonNumber INTEGER, '
|
||||||
'showTitle TEXT, duration INTEGER, startTime INTEGER, endTime INTEGER, '
|
'showTitle TEXT, duration INTEGER, startTime INTEGER, endTime INTEGER, '
|
||||||
'dayOfWeek TEXT, sectionType TEXT)')
|
'dayOfWeek TEXT, sectionType TEXT, plexMediaID TEXT)')
|
||||||
|
|
||||||
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
self.cursor.execute('CREATE TABLE IF NOT EXISTS '
|
||||||
'app_settings(id INTEGER PRIMARY KEY AUTOINCREMENT, version TEXT)')
|
'app_settings(id INTEGER PRIMARY KEY AUTOINCREMENT, version TEXT)')
|
||||||
@@ -119,12 +120,12 @@ class PseudoChannelDatabase():
|
|||||||
Setters, etc.
|
Setters, etc.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def add_movies_to_db(self, mediaID, title, duration):
|
def add_movies_to_db(self, mediaID, title, duration, plexMediaID):
|
||||||
unix = int(time.time())
|
unix = int(time.time())
|
||||||
try:
|
try:
|
||||||
self.cursor.execute("INSERT OR REPLACE INTO movies "
|
self.cursor.execute("INSERT OR REPLACE INTO movies "
|
||||||
"(unix, mediaID, title, duration) VALUES (?, ?, ?, ?)",
|
"(unix, mediaID, title, duration, plexMediaID) VALUES (?, ?, ?, ?, ?)",
|
||||||
(unix, mediaID, title, duration))
|
(unix, mediaID, title, duration, plexMediaID))
|
||||||
|
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
# Catch the exception
|
# Catch the exception
|
||||||
@@ -133,12 +134,12 @@ class PseudoChannelDatabase():
|
|||||||
self.conn.rollback()
|
self.conn.rollback()
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def add_videos_to_db(self, mediaID, title, duration):
|
def add_videos_to_db(self, mediaID, title, duration, plexMediaID):
|
||||||
unix = int(time.time())
|
unix = int(time.time())
|
||||||
try:
|
try:
|
||||||
self.cursor.execute("INSERT OR REPLACE INTO videos "
|
self.cursor.execute("INSERT OR REPLACE INTO videos "
|
||||||
"(unix, mediaID, title, duration) VALUES (?, ?, ?, ?)",
|
"(unix, mediaID, title, duration, plexMediaID) VALUES (?, ?, ?, ?, ?)",
|
||||||
(unix, mediaID, title, duration))
|
(unix, mediaID, title, duration, plexMediaID))
|
||||||
|
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
# Catch the exception
|
# Catch the exception
|
||||||
@@ -147,12 +148,12 @@ class PseudoChannelDatabase():
|
|||||||
self.conn.rollback()
|
self.conn.rollback()
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def add_shows_to_db(self, mediaID, title, duration, lastEpisodeTitle, fullImageURL):
|
def add_shows_to_db(self, mediaID, title, duration, lastEpisodeTitle, fullImageURL, plexMediaID):
|
||||||
unix = int(time.time())
|
unix = int(time.time())
|
||||||
try:
|
try:
|
||||||
self.cursor.execute("INSERT OR REPLACE INTO shows "
|
self.cursor.execute("INSERT OR REPLACE INTO shows "
|
||||||
"(unix, mediaID, title, duration, lastEpisodeTitle, fullImageURL) VALUES (?, ?, ?, ?, ?, ?)",
|
"(unix, mediaID, title, duration, lastEpisodeTitle, fullImageURL, plexMediaID) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||||
(unix, mediaID, title, duration, lastEpisodeTitle, fullImageURL))
|
(unix, mediaID, title, duration, lastEpisodeTitle, fullImageURL, plexMediaID))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
# Catch the exception
|
# Catch the exception
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -160,12 +161,12 @@ class PseudoChannelDatabase():
|
|||||||
self.conn.rollback()
|
self.conn.rollback()
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def add_episodes_to_db(self, mediaID, title, duration, episodeNumber, seasonNumber, showTitle):
|
def add_episodes_to_db(self, mediaID, title, duration, episodeNumber, seasonNumber, showTitle, plexMediaID):
|
||||||
unix = int(time.time())
|
unix = int(time.time())
|
||||||
try:
|
try:
|
||||||
self.cursor.execute("INSERT OR REPLACE INTO episodes "
|
self.cursor.execute("INSERT OR REPLACE INTO episodes "
|
||||||
"(unix, mediaID, title, duration, episodeNumber, seasonNumber, showTitle) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
"(unix, mediaID, title, duration, episodeNumber, seasonNumber, showTitle, plexMediaID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
(unix, mediaID, title, duration, episodeNumber, seasonNumber, showTitle))
|
(unix, mediaID, title, duration, episodeNumber, seasonNumber, showTitle, plexMediaID))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
# Catch the exception
|
# Catch the exception
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -173,15 +174,16 @@ class PseudoChannelDatabase():
|
|||||||
self.conn.rollback()
|
self.conn.rollback()
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def add_commercials_to_db(self, mediaID, title, duration):
|
def add_commercials_to_db(self, mediaID, title, duration, plexMediaID):
|
||||||
unix = int(time.time())
|
unix = int(time.time())
|
||||||
try:
|
try:
|
||||||
self.cursor.execute("INSERT OR REPLACE INTO commercials "
|
self.cursor.execute("INSERT OR REPLACE INTO commercials "
|
||||||
"(unix, mediaID, title, duration) VALUES (?, ?, ?, ?)",
|
"(unix, mediaID, title, duration, plexMediaID) VALUES (?, ?, ?, ?, ?)",
|
||||||
(unix, mediaID, title, duration))
|
(unix, mediaID, title, duration, plexMediaID))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
# Catch the exception
|
# Catch the exception
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print plexMediaID
|
||||||
# Roll back any change if something goes wrong
|
# Roll back any change if something goes wrong
|
||||||
self.conn.rollback()
|
self.conn.rollback()
|
||||||
raise e
|
raise e
|
||||||
@@ -211,7 +213,8 @@ class PseudoChannelDatabase():
|
|||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
dayOfWeek,
|
dayOfWeek,
|
||||||
sectionType
|
sectionType,
|
||||||
|
plexMediaID
|
||||||
):
|
):
|
||||||
|
|
||||||
unix = int(time.time())
|
unix = int(time.time())
|
||||||
@@ -220,8 +223,8 @@ class PseudoChannelDatabase():
|
|||||||
|
|
||||||
self.cursor.execute("INSERT OR REPLACE INTO daily_schedule "
|
self.cursor.execute("INSERT OR REPLACE INTO daily_schedule "
|
||||||
"(unix, mediaID, title, episodeNumber, seasonNumber, "
|
"(unix, mediaID, title, episodeNumber, seasonNumber, "
|
||||||
"showTitle, duration, startTime, endTime, dayOfWeek, sectionType) "
|
"showTitle, duration, startTime, endTime, dayOfWeek, sectionType, plexMediaID) "
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
(
|
(
|
||||||
unix,
|
unix,
|
||||||
mediaID,
|
mediaID,
|
||||||
@@ -233,7 +236,8 @@ class PseudoChannelDatabase():
|
|||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
dayOfWeek,
|
dayOfWeek,
|
||||||
sectionType
|
sectionType,
|
||||||
|
plexMediaID
|
||||||
))
|
))
|
||||||
|
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
@@ -261,7 +265,8 @@ class PseudoChannelDatabase():
|
|||||||
media.start_time,
|
media.start_time,
|
||||||
media.end_time,
|
media.end_time,
|
||||||
media.day_of_week,
|
media.day_of_week,
|
||||||
media.section_type
|
media.section_type,
|
||||||
|
media.plex_media_id
|
||||||
)
|
)
|
||||||
|
|
||||||
"""Database functions.
|
"""Database functions.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from datetime import datetime
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
from yattag import Doc
|
from yattag import Doc
|
||||||
|
from yattag import indent
|
||||||
import os, sys
|
import os, sys
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@@ -56,6 +57,63 @@ class PseudoDailyScheduleController():
|
|||||||
|
|
||||||
return backgroundImgURL
|
return backgroundImgURL
|
||||||
|
|
||||||
|
def get_xml_from_daily_schedule(self, currentTime, bgImageURL, datalist):
|
||||||
|
|
||||||
|
now = datetime.now()
|
||||||
|
|
||||||
|
time = now.strftime("%B %d, %Y")
|
||||||
|
|
||||||
|
doc, tag, text, line = Doc(
|
||||||
|
|
||||||
|
).ttl()
|
||||||
|
|
||||||
|
doc.asis('<?xml version="1.0" encoding="UTF-8"?>')
|
||||||
|
|
||||||
|
with tag('schedule', currently_playing_bg_image=bgImageURL if bgImageURL != None else ''):
|
||||||
|
|
||||||
|
for row in datalist:
|
||||||
|
|
||||||
|
timeB = datetime.strptime(row[8], '%I:%M %p')
|
||||||
|
|
||||||
|
if currentTime == None:
|
||||||
|
|
||||||
|
with tag('time',
|
||||||
|
('data-key', str(row[12])),
|
||||||
|
('data-current', 'false'),
|
||||||
|
('data-type', str(row[11])),
|
||||||
|
('data-title', str(row[3])),
|
||||||
|
('data-start-time', str(row[8])),
|
||||||
|
):
|
||||||
|
|
||||||
|
text(row[8])
|
||||||
|
|
||||||
|
elif currentTime.hour == timeB.hour and currentTime.minute == timeB.minute:
|
||||||
|
|
||||||
|
with tag('time',
|
||||||
|
('data-key', str(row[12])),
|
||||||
|
('data-current', 'true'),
|
||||||
|
('data-type', str(row[11])),
|
||||||
|
('data-title', str(row[3])),
|
||||||
|
('data-start-time', str(row[8])),
|
||||||
|
):
|
||||||
|
|
||||||
|
text(row[8])
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
with tag('time',
|
||||||
|
('data-key', str(row[12])),
|
||||||
|
('data-current', 'false'),
|
||||||
|
('data-type', str(row[11])),
|
||||||
|
('data-title', str(row[3])),
|
||||||
|
('data-start-time', str(row[8])),
|
||||||
|
):
|
||||||
|
|
||||||
|
text(row[8])
|
||||||
|
|
||||||
|
return indent(doc.getvalue())
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
*
|
*
|
||||||
* Get the generated html for the .html file that is the schedule.
|
* Get the generated html for the .html file that is the schedule.
|
||||||
@@ -176,7 +234,7 @@ class PseudoDailyScheduleController():
|
|||||||
text(row[8])
|
text(row[8])
|
||||||
|
|
||||||
|
|
||||||
return doc.getvalue()
|
return indent(doc.getvalue())
|
||||||
|
|
||||||
'''
|
'''
|
||||||
*
|
*
|
||||||
@@ -207,6 +265,35 @@ class PseudoDailyScheduleController():
|
|||||||
|
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
|
'''
|
||||||
|
*
|
||||||
|
* Create 'schedules' dir & write the generated xml to .xml file.
|
||||||
|
* @param data: xml string
|
||||||
|
* @return null
|
||||||
|
*
|
||||||
|
'''
|
||||||
|
def write_xml_to_file(self, data):
|
||||||
|
|
||||||
|
now = datetime.now()
|
||||||
|
|
||||||
|
fileName = "pseudo_schedule.xml"
|
||||||
|
|
||||||
|
writepath = './schedules/'
|
||||||
|
|
||||||
|
if not os.path.exists(writepath):
|
||||||
|
|
||||||
|
os.makedirs(writepath)
|
||||||
|
|
||||||
|
if os.path.exists(writepath+fileName):
|
||||||
|
|
||||||
|
os.remove(writepath+fileName)
|
||||||
|
|
||||||
|
mode = 'a' if os.path.exists(writepath) else 'w'
|
||||||
|
|
||||||
|
with open(writepath+fileName, mode) as f:
|
||||||
|
|
||||||
|
f.write(data)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
*
|
*
|
||||||
* Trigger "playMedia()" on the Python Plex API for specified media.
|
* Trigger "playMedia()" on the Python Plex API for specified media.
|
||||||
@@ -283,6 +370,7 @@ class PseudoDailyScheduleController():
|
|||||||
print("Ok end time found")
|
print("Ok end time found")
|
||||||
|
|
||||||
self.write_schedule_to_file(self.get_html_from_daily_schedule(None, None, datalist))
|
self.write_schedule_to_file(self.get_html_from_daily_schedule(None, None, datalist))
|
||||||
|
self.write_xml_to_file(self.get_xml_from_daily_schedule(None, None, datalist))
|
||||||
|
|
||||||
break
|
break
|
||||||
'''
|
'''
|
||||||
@@ -328,6 +416,19 @@ class PseudoDailyScheduleController():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
"""Generate / write XML to file
|
||||||
|
"""
|
||||||
|
self.write_xml_to_file(
|
||||||
|
self.get_xml_from_daily_schedule(
|
||||||
|
timeB,
|
||||||
|
self.get_show_photo(
|
||||||
|
row[11],
|
||||||
|
row[6] if row[11] == "TV Shows" else row[3]
|
||||||
|
),
|
||||||
|
datalist
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.my_logger.debug('Trying to play: ' + row[3])
|
self.my_logger.debug('Trying to play: ' + row[3])
|
||||||
|
|
||||||
break
|
break
|
||||||
@@ -337,3 +438,10 @@ class PseudoDailyScheduleController():
|
|||||||
if datalistLengthMonitor >= len(datalist):
|
if datalistLengthMonitor >= len(datalist):
|
||||||
|
|
||||||
self.check_for_end_time(datalist)
|
self.check_for_end_time(datalist)
|
||||||
|
|
||||||
|
def make_xml_schedule(self, datalist):
|
||||||
|
|
||||||
|
print "+++++ ", "Writing XML / HTML to file."
|
||||||
|
|
||||||
|
self.write_schedule_to_file(self.get_html_from_daily_schedule(None, None, datalist))
|
||||||
|
self.write_xml_to_file(self.get_xml_from_daily_schedule(None, None, datalist))
|
||||||
@@ -26,7 +26,8 @@ class Video(Media):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
):
|
):
|
||||||
|
|
||||||
super(Video, self).__init__(
|
super(Video, self).__init__(
|
||||||
@@ -38,5 +39,6 @@ class Video(Media):
|
|||||||
day_of_week,
|
day_of_week,
|
||||||
is_strict_time,
|
is_strict_time,
|
||||||
time_shift,
|
time_shift,
|
||||||
overlap_max
|
overlap_max,
|
||||||
|
plex_media_id
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user