Move live key to main metadata dict

This commit is contained in:
JonnyWong16 2020-02-17 16:11:26 -08:00
parent af521b4058
commit ba465a0d15
3 changed files with 35 additions and 23 deletions

View file

@ -85,7 +85,7 @@ DOCUMENTATION :: END
<div class="col-md-12"> <div class="col-md-12">
<div class="summary-navbar-list"> <div class="summary-navbar-list">
<ul class="list-unstyled breadcrumb"> <ul class="list-unstyled breadcrumb">
% if media_info['live']: % if data['live']:
<li>Live TV</li> <li>Live TV</li>
<span class="breadcrumb-arrow"><i class="fa fa-chevron-right"></i></span> <span class="breadcrumb-arrow"><i class="fa fa-chevron-right"></i></span>
% if data['media_type'] == 'movie': % if data['media_type'] == 'movie':
@ -151,10 +151,10 @@ DOCUMENTATION :: END
<div class="summary-content-poster hidden-xs hidden-sm"> <div class="summary-content-poster hidden-xs hidden-sm">
% if data['media_type'] == 'track': % if data['media_type'] == 'track':
<a href="${config['pms_web_url']}#!/server/${config['pms_identifier']}/details?key=%2Flibrary%2Fmetadata%2F${data['parent_rating_key']}" target="_blank" title="View on Plex Web"> <a href="${config['pms_web_url']}#!/server/${config['pms_identifier']}/details?key=%2Flibrary%2Fmetadata%2F${data['parent_rating_key']}" target="_blank" title="View on Plex Web">
% elif not media_info['live']: % elif not data['live']:
<a href="${config['pms_web_url']}#!/server/${config['pms_identifier']}/details?key=%2Flibrary%2Fmetadata%2F${data['rating_key']}" target="_blank" title="View on Plex Web"> <a href="${config['pms_web_url']}#!/server/${config['pms_identifier']}/details?key=%2Flibrary%2Fmetadata%2F${data['rating_key']}" target="_blank" title="View on Plex Web">
% endif % endif
% if media_info['live']: % if data['live']:
<div class="summary-poster-face" style="background-image: url(pms_image_proxy?img=${data['grandparent_thumb'] or data['thumb']}&rating_key=${data['rating_key']}&width=300&height=450&fallback=poster-live);"> <div class="summary-poster-face" style="background-image: url(pms_image_proxy?img=${data['grandparent_thumb'] or data['thumb']}&rating_key=${data['rating_key']}&width=300&height=450&fallback=poster-live);">
<div class="summary-poster-face-overlay"> <div class="summary-poster-face-overlay">
<span></span> <span></span>
@ -190,12 +190,12 @@ DOCUMENTATION :: END
% endif % endif
% endif % endif
% endif % endif
% if not media_info['live']: % if not data['live']:
</a> </a>
% endif % endif
</div> </div>
<div class="summary-content-title"> <div class="summary-content-title">
% if media_info['live']: % if data['live']:
% if data['media_type'] == 'movie': % if data['media_type'] == 'movie':
<h1>&nbsp;</h1><h1>${data['title']}</h1> <h1>&nbsp;</h1><h1>${data['title']}</h1>
% elif data['media_type'] == 'episode': % elif data['media_type'] == 'episode':
@ -227,7 +227,7 @@ DOCUMENTATION :: END
</div> </div>
<div class="summary-content-wrapper"> <div class="summary-content-wrapper">
<div class="col-md-9"> <div class="col-md-9">
% if data['media_type'] == 'movie' or media_info['live']: % if data['media_type'] == 'movie' or data['live']:
<div class="summary-content-padding hidden-xs hidden-sm" style="height: 305px;"> <div class="summary-content-padding hidden-xs hidden-sm" style="height: 305px;">
% elif data['media_type'] in ('show', 'season', 'collection'): % elif data['media_type'] in ('show', 'season', 'collection'):
<div class="summary-content-padding hidden-xs hidden-sm" style="height: 270px;"> <div class="summary-content-padding hidden-xs hidden-sm" style="height: 270px;">
@ -476,7 +476,7 @@ DOCUMENTATION :: END
</span> </span>
</div> </div>
% endif % endif
% if not media_info['live']: % if not data['live']:
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-dark" data-toggle="modal" aria-pressed="false" autocomplete="off" id="send-recently-added-notification" <button class="btn btn-dark" data-toggle="modal" aria-pressed="false" autocomplete="off" id="send-recently-added-notification"
data-id="${data['rating_key']}"> data-id="${data['rating_key']}">

View file

@ -1077,7 +1077,6 @@ class DataFactory(object):
'video_framerate': item['video_framerate'], 'video_framerate': item['video_framerate'],
'audio_codec': item['audio_codec'], 'audio_codec': item['audio_codec'],
'audio_channels': item['audio_channels'], 'audio_channels': item['audio_channels'],
'live': item['live'],
'channel_call_sign': item['channel_call_sign'], 'channel_call_sign': item['channel_call_sign'],
'channel_identifier': item['channel_identifier'], 'channel_identifier': item['channel_identifier'],
'channel_thumb': item['channel_thumb'] 'channel_thumb': item['channel_thumb']
@ -1116,6 +1115,7 @@ class DataFactory(object):
'labels': labels, 'labels': labels,
'library_name': section_name, 'library_name': section_name,
'section_id': item['section_id'], 'section_id': item['section_id'],
'live': item['live'],
'media_info': media_info 'media_info': media_info
} }
metadata_list.append(metadata) metadata_list.append(metadata)

View file

@ -719,7 +719,8 @@ class PmsConnect(object):
'labels': labels, 'labels': labels,
'collections': collections, 'collections': collections,
'full_title': helpers.get_xml_attr(metadata_main, 'title'), 'full_title': helpers.get_xml_attr(metadata_main, 'title'),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'show': elif metadata_type == 'show':
@ -771,7 +772,8 @@ class PmsConnect(object):
'labels': labels, 'labels': labels,
'collections': collections, 'collections': collections,
'full_title': helpers.get_xml_attr(metadata_main, 'title'), 'full_title': helpers.get_xml_attr(metadata_main, 'title'),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'season': elif metadata_type == 'season':
@ -821,7 +823,8 @@ class PmsConnect(object):
'collections': show_details.get('collections', []), 'collections': show_details.get('collections', []),
'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle'), 'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle'),
helpers.get_xml_attr(metadata_main, 'title')), helpers.get_xml_attr(metadata_main, 'title')),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'episode': elif metadata_type == 'episode':
@ -887,7 +890,8 @@ class PmsConnect(object):
'collections': show_details.get('collections', []), 'collections': show_details.get('collections', []),
'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'grandparentTitle'), 'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'grandparentTitle'),
helpers.get_xml_attr(metadata_main, 'title')), helpers.get_xml_attr(metadata_main, 'title')),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'artist': elif metadata_type == 'artist':
@ -934,7 +938,8 @@ class PmsConnect(object):
'labels': labels, 'labels': labels,
'collections': collections, 'collections': collections,
'full_title': helpers.get_xml_attr(metadata_main, 'title'), 'full_title': helpers.get_xml_attr(metadata_main, 'title'),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'album': elif metadata_type == 'album':
@ -984,7 +989,8 @@ class PmsConnect(object):
'collections': collections, 'collections': collections,
'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle'), 'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle'),
helpers.get_xml_attr(metadata_main, 'title')), helpers.get_xml_attr(metadata_main, 'title')),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'track': elif metadata_type == 'track':
@ -1036,7 +1042,8 @@ class PmsConnect(object):
'collections': album_details.get('collections', []), 'collections': album_details.get('collections', []),
'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'title'), 'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'title'),
track_artist), track_artist),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'photo_album': elif metadata_type == 'photo_album':
@ -1083,7 +1090,8 @@ class PmsConnect(object):
'labels': labels, 'labels': labels,
'collections': collections, 'collections': collections,
'full_title': helpers.get_xml_attr(metadata_main, 'title'), 'full_title': helpers.get_xml_attr(metadata_main, 'title'),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'photo': elif metadata_type == 'photo':
@ -1133,7 +1141,8 @@ class PmsConnect(object):
'collections': photo_album_details.get('collections', []), 'collections': photo_album_details.get('collections', []),
'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle') or library_name, 'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle') or library_name,
helpers.get_xml_attr(metadata_main, 'title')), helpers.get_xml_attr(metadata_main, 'title')),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'collection': elif metadata_type == 'collection':
@ -1184,7 +1193,8 @@ class PmsConnect(object):
'labels': labels, 'labels': labels,
'collections': collections, 'collections': collections,
'full_title': helpers.get_xml_attr(metadata_main, 'title'), 'full_title': helpers.get_xml_attr(metadata_main, 'title'),
'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
elif metadata_type == 'clip': elif metadata_type == 'clip':
@ -1232,12 +1242,17 @@ class PmsConnect(object):
'collections': collections, 'collections': collections,
'full_title': helpers.get_xml_attr(metadata_main, 'title'), 'full_title': helpers.get_xml_attr(metadata_main, 'title'),
'extra_type': helpers.get_xml_attr(metadata_main, 'extraType'), 'extra_type': helpers.get_xml_attr(metadata_main, 'extraType'),
'sub_type': helpers.get_xml_attr(metadata_main, 'subtype') 'sub_type': helpers.get_xml_attr(metadata_main, 'subtype'),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
} }
else: else:
return metadata return metadata
# Fake Live TV air date using added_at timestamp
if metadata['live'] and not metadata['originally_available_at']:
metadata['originally_available_at'] = helpers.timestamp_to_iso_date(metadata['added_at'])
if metadata and media_info: if metadata and media_info:
medias = [] medias = []
media_items = metadata_main.getElementsByTagName('Media') media_items = metadata_main.getElementsByTagName('Media')
@ -1342,10 +1357,7 @@ class PmsConnect(object):
'parts': parts 'parts': parts
} }
live = int(helpers.get_xml_attr(metadata_main, 'live') == '1') if metadata['live']:
if live:
media_info['live'] = live
media_info['channel_call_sign'] = helpers.get_xml_attr(media, 'channelCallSign') media_info['channel_call_sign'] = helpers.get_xml_attr(media, 'channelCallSign')
media_info['channel_identifier'] = helpers.get_xml_attr(media, 'channelIdentifier') media_info['channel_identifier'] = helpers.get_xml_attr(media, 'channelIdentifier')
media_info['channel_thumb'] = helpers.get_xml_attr(media, 'channelThumb') media_info['channel_thumb'] = helpers.get_xml_attr(media, 'channelThumb')