Add fake Live TV library

This commit is contained in:
JonnyWong16 2020-02-22 14:02:03 -08:00
parent bcd0691b33
commit 1dd1c6f67f
6 changed files with 42 additions and 0 deletions

View file

@ -36,6 +36,7 @@ DOCUMENTATION :: END
<%def name="body()"> <%def name="body()">
% if data: % if data:
<% <%
from plexpy.common import LIVE_TV_SECTION_ID
from plexpy.helpers import page from plexpy.helpers import page
%> %>
<div class="container-fluid"> <div class="container-fluid">
@ -78,8 +79,10 @@ DOCUMENTATION :: END
<li class="active"><a href="#tabs-profile" role="tab" data-toggle="tab">Profile</a></li> <li class="active"><a href="#tabs-profile" role="tab" data-toggle="tab">Profile</a></li>
<li><a id="history-tab-btn" href="#tabs-history" role="tab" data-toggle="tab">History</a></li> <li><a id="history-tab-btn" href="#tabs-history" role="tab" data-toggle="tab">History</a></li>
% if _session['user_group'] == 'admin': % if _session['user_group'] == 'admin':
% if data['section_id'] != LIVE_TV_SECTION_ID:
<li><a id="media-info-tab-btn" href="#tabs-mediainfo" role="tab" data-toggle="tab">Media Info</a></li> <li><a id="media-info-tab-btn" href="#tabs-mediainfo" role="tab" data-toggle="tab">Media Info</a></li>
% endif % endif
% endif
</ul> </ul>
</div> </div>
</div> </div>
@ -146,6 +149,7 @@ DOCUMENTATION :: END
</div> </div>
</div> </div>
</div> </div>
% if data['section_id'] != LIVE_TV_SECTION_ID:
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@ -171,6 +175,7 @@ DOCUMENTATION :: END
</div> </div>
</div> </div>
</div> </div>
% endif
</div> </div>
<div role="tabpanel" class="tab-pane" id="tabs-history"> <div role="tabpanel" class="tab-pane" id="tabs-history">
<div class="container-fluid"> <div class="container-fluid">
@ -351,6 +356,7 @@ DOCUMENTATION :: END
<script src="${http_root}js/dataTables.bootstrap.min.js"></script> <script src="${http_root}js/dataTables.bootstrap.min.js"></script>
<script src="${http_root}js/dataTables.bootstrap.pagination.js"></script> <script src="${http_root}js/dataTables.bootstrap.pagination.js"></script>
% if data: % if data:
<% from plexpy.common import LIVE_TV_SECTION_ID %>
<script> <script>
% if str(data['section_id']).isdigit(): % if str(data['section_id']).isdigit():
var section_id = ${data['section_id']}; var section_id = ${data['section_id']};
@ -529,7 +535,9 @@ DOCUMENTATION :: END
} }
recentlyWatched(); recentlyWatched();
% if data['section_id'] != LIVE_TV_SECTION_ID:
recentlyAdded(); recentlyAdded();
% endif
function highlightWatchedScrollerButton() { function highlightWatchedScrollerButton() {
var scroller = $("#recently-watched-row-scroller"); var scroller = $("#recently-watched-row-scroller");

View file

@ -149,6 +149,10 @@ class ActivityProcessor(object):
timestamp = {'started': started} timestamp = {'started': started}
self.db.upsert('sessions', timestamp, keys) self.db.upsert('sessions', timestamp, keys)
# Add Live TV library if it hasn't been added
if values['live']:
libraries.add_live_tv_library()
return True return True
def write_session_history(self, session=None, import_metadata=None, is_import=False, import_ignore_interval=0): def write_session_history(self, session=None, import_metadata=None, is_import=False, import_ignore_interval=0):

View file

@ -42,6 +42,9 @@ ONLINE_POSTER_THUMB = "https://tautulli.com/images/poster.png"
ONLINE_COVER_THUMB = "https://tautulli.com/images/cover.png" ONLINE_COVER_THUMB = "https://tautulli.com/images/cover.png"
ONLINE_ART = "https://tautulli.com/images/art.png" ONLINE_ART = "https://tautulli.com/images/art.png"
LIVE_TV_SECTION_ID = 999999 # Fake section_id for Live TV library
LIVE_TV_SECTION_NAME = "Live TV" # Fake section_name for Live TV library
DEFAULT_IMAGES = { DEFAULT_IMAGES = {
'poster': DEFAULT_POSTER_THUMB, 'poster': DEFAULT_POSTER_THUMB,
'cover': DEFAULT_COVER_THUMB, 'cover': DEFAULT_COVER_THUMB,

View file

@ -68,6 +68,7 @@ _CONFIG_DEFINITIONS = {
'PMS_UPDATE_CHECK_INTERVAL': (int, 'Advanced', 24), 'PMS_UPDATE_CHECK_INTERVAL': (int, 'Advanced', 24),
'PMS_WEB_URL': (str, 'PMS', 'https://app.plex.tv/desktop'), 'PMS_WEB_URL': (str, 'PMS', 'https://app.plex.tv/desktop'),
'TIME_FORMAT': (str, 'General', 'HH:mm'), 'TIME_FORMAT': (str, 'General', 'HH:mm'),
'ADD_LIVE_TV_LIBRARY': (int, 'Advanced', 1),
'ANON_REDIRECT': (str, 'General', 'http://www.nullrefer.com/?'), 'ANON_REDIRECT': (str, 'General', 'http://www.nullrefer.com/?'),
'API_ENABLED': (int, 'General', 1), 'API_ENABLED': (int, 'General', 1),
'API_KEY': (str, 'General', ''), 'API_KEY': (str, 'General', ''),

View file

@ -88,6 +88,29 @@ def refresh_libraries():
return False return False
def add_live_tv_library():
if not plexpy.CONFIG.ADD_LIVE_TV_LIBRARY:
return
logger.info(u"Tautulli Libraries :: Adding Live TV library to the database.")
monitor_db = database.MonitorDatabase()
section_keys = {'server_id': plexpy.CONFIG.PMS_IDENTIFIER,
'section_id': common.LIVE_TV_SECTION_ID}
section_values = {'server_id': plexpy.CONFIG.PMS_IDENTIFIER,
'section_id': common.LIVE_TV_SECTION_ID,
'section_name': common.LIVE_TV_SECTION_NAME,
'section_type': 'live'
}
result = monitor_db.upsert('library_sections', key_dict=section_keys, value_dict=section_values)
if result == 'insert':
plexpy.CONFIG.__setattr__('ADD_LIVE_TV_LIBRARY', 0)
plexpy.CONFIG.write()
def update_section_ids(): def update_section_ids():
plexpy.CONFIG.UPDATE_SECTION_IDS = -1 plexpy.CONFIG.UPDATE_SECTION_IDS = -1

View file

@ -1267,6 +1267,9 @@ class PmsConnect(object):
# Get additional metadata from metadata.provider.plex.tv # Get additional metadata from metadata.provider.plex.tv
if not plex_guid and metadata['live']: if not plex_guid and metadata['live']:
metadata['section_id'] = common.LIVE_TV_SECTION_ID
metadata['library_name'] = common.LIVE_TV_SECTION_NAME
plextv_metadata = self.get_metadata_details(plex_guid=metadata['guid']) plextv_metadata = self.get_metadata_details(plex_guid=metadata['guid'])
if plextv_metadata: if plextv_metadata:
keys_to_update = ['summary', 'rating', 'thumb', 'grandparent_thumb', 'duration', keys_to_update = ['summary', 'rating', 'thumb', 'grandparent_thumb', 'duration',