Fix library recenly watched missing live key

This commit is contained in:
JonnyWong16 2020-02-17 10:51:44 -08:00
parent 8f19cdccfd
commit fa0b547b32

View file

@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Tautulli. If not, see <http://www.gnu.org/licenses/>. # along with Tautulli. If not, see <http://www.gnu.org/licenses/>.
import arrow
import json import json
import os import os
@ -883,7 +884,7 @@ class Libraries(object):
'session_history.rating_key, session_history.parent_rating_key, session_history.grandparent_rating_key, ' \ 'session_history.rating_key, session_history.parent_rating_key, session_history.grandparent_rating_key, ' \
'title, parent_title, grandparent_title, original_title, ' \ 'title, parent_title, grandparent_title, original_title, ' \
'thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, ' \ 'thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, ' \
'year, started, user, content_rating, labels, section_id ' \ 'year, originally_available_at, added_at, live, started, user, content_rating, labels, section_id ' \
'FROM session_history_metadata ' \ 'FROM session_history_metadata ' \
'JOIN session_history ON session_history_metadata.id = session_history.id ' \ 'JOIN session_history ON session_history_metadata.id = session_history.id ' \
'WHERE section_id = ? ' \ 'WHERE section_id = ? ' \
@ -904,6 +905,13 @@ class Libraries(object):
else: else:
thumb = row['thumb'] thumb = row['thumb']
if row['live']:
# Fake Live TV air date using added_at timestamp
originally_available_at = row['originally_available_at'] or arrow.get(row['added_at']).format(
'YYYY-MM-DD')
else:
originally_available_at = row['originally_available_at']
recent_output = {'row_id': row['id'], recent_output = {'row_id': row['id'],
'media_type': row['media_type'], 'media_type': row['media_type'],
'rating_key': row['rating_key'], 'rating_key': row['rating_key'],
@ -917,6 +925,8 @@ class Libraries(object):
'media_index': row['media_index'], 'media_index': row['media_index'],
'parent_media_index': row['parent_media_index'], 'parent_media_index': row['parent_media_index'],
'year': row['year'], 'year': row['year'],
'originally_available_at': originally_available_at,
'live': row['live'],
'time': row['started'], 'time': row['started'],
'user': row['user'], 'user': row['user'],
'section_id': row['section_id'], 'section_id': row['section_id'],