Update marker notification parameters

This commit is contained in:
JonnyWong16 2023-02-16 16:20:25 -08:00
parent 97af214ac1
commit 9be3bbbf0f
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 18 additions and 26 deletions

View file

@ -427,12 +427,10 @@ NOTIFICATION_PARAMETERS = [
{'name': 'Optimized Version Profile', 'type': 'str', 'value': 'optimized_version_profile', 'description': 'The optimized version profile of the stream.'}, {'name': 'Optimized Version Profile', 'type': 'str', 'value': 'optimized_version_profile', 'description': 'The optimized version profile of the stream.'},
{'name': 'Synced Version', 'type': 'int', 'value': 'synced_version', 'description': 'If the stream is an synced version.', 'example': '0 or 1'}, {'name': 'Synced Version', 'type': 'int', 'value': 'synced_version', 'description': 'If the stream is an synced version.', 'example': '0 or 1'},
{'name': 'Live', 'type': 'int', 'value': 'live', 'description': 'If the stream is live TV.', 'example': '0 or 1'}, {'name': 'Live', 'type': 'int', 'value': 'live', 'description': 'If the stream is live TV.', 'example': '0 or 1'},
{'name': 'Intro Marker Start Time', 'type': 'int', 'value': 'intro_marker_start', 'description': 'The intro marker start time offset in milliseconds.'}, {'name': 'Marker Start Time', 'type': 'int', 'value': 'marker_start', 'description': 'The intro or credits marker start time offset in milliseconds.'},
{'name': 'Intro Marker End Time', 'type': 'int', 'value': 'intro_marker_end', 'description': 'The intro marker end time offset in milliseconds.'}, {'name': 'Marker End Time', 'type': 'int', 'value': 'marker_end', 'description': 'The intro or credits marker end time offset in milliseconds.'},
{'name': 'Credits Marker First', 'type': 'int', 'value': 'credits_marker_first', 'description': 'If the credits marker is the first marker.', 'example': '0 or 1'}, {'name': 'Credits Marker First', 'type': 'int', 'value': 'credits_marker_first', 'description': 'If the marker is the first credits marker.', 'example': '0 or 1'},
{'name': 'Credits Marker Final', 'type': 'int', 'value': 'credits_marker_final', 'description': 'If the credits marker is the final marker.', 'example': '0 or 1'}, {'name': 'Credits Marker Final', 'type': 'int', 'value': 'credits_marker_final', 'description': 'If the marker is the final credits marker.', 'example': '0 or 1'},
{'name': 'Credits Marker Start Time', 'type': 'int', 'value': 'credits_marker_start', 'description': 'The credits marker start time offset in milliseconds.'},
{'name': 'Credits Marker End Time', 'type': 'int', 'value': 'credits_marker_end', 'description': 'The credits marker end time offset in milliseconds.'},
{'name': 'Channel Call Sign', 'type': 'str', 'value': 'channel_call_sign', 'description': 'The Live TV channel call sign.'}, {'name': 'Channel Call Sign', 'type': 'str', 'value': 'channel_call_sign', 'description': 'The Live TV channel call sign.'},
{'name': 'Channel Identifier', 'type': 'str', 'value': 'channel_identifier', 'description': 'The Live TV channel number.'}, {'name': 'Channel Identifier', 'type': 'str', 'value': 'channel_identifier', 'description': 'The Live TV channel number.'},
{'name': 'Channel Thumb', 'type': 'str', 'value': 'channel_thumb', 'description': 'The URL for the Live TV channel logo.'}, {'name': 'Channel Thumb', 'type': 'str', 'value': 'channel_thumb', 'description': 'The URL for the Live TV channel logo.'},

View file

@ -940,19 +940,7 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
and audience_rating: and audience_rating:
audience_rating = helpers.get_percent(notify_params['audience_rating'], 10) audience_rating = helpers.get_percent(notify_params['audience_rating'], 10)
intro_markers, credits_markers = [], [] marker = kwargs.pop('marker', defaultdict(int))
for marker in metadata['markers']:
if marker['type'] == 'intro':
intro_markers.append(marker)
elif marker['type'] == 'credits':
credits_markers.append(marker)
intro_marker = defaultdict(int)
credits_marker = defaultdict(int)
if notify_action == 'on_intro' and intro_markers and notify_params['intro'] < len(intro_markers):
intro_marker = intro_markers[notify_params['intro']]
if notify_action == 'on_credits' and credits_markers and notify_params['credits'] < len(credits_markers):
credits_marker = credits_markers[notify_params['credits']]
now = arrow.now() now = arrow.now()
now_iso = now.isocalendar() now_iso = now.isocalendar()
@ -1033,12 +1021,10 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
'optimized_version_profile': notify_params['optimized_version_profile'], 'optimized_version_profile': notify_params['optimized_version_profile'],
'synced_version': notify_params['synced_version'], 'synced_version': notify_params['synced_version'],
'live': notify_params['live'], 'live': notify_params['live'],
'intro_marker_start': intro_marker['start_time_offset'], 'marker_start': marker['start_time_offset'],
'intro_marker_end': intro_marker['end_time_offset'], 'marker_end': marker['end_time_offset'],
'credits_marker_first': int(bool(credits_marker and notify_params['credits'] == 0)), 'credits_marker_first': int(marker['first']),
'credits_marker_final': int(credits_marker['final']), 'credits_marker_final': int(marker['final']),
'credits_marker_start': credits_marker['start_time_offset'],
'credits_marker_end': credits_marker['end_time_offset'],
'channel_call_sign': notify_params['channel_call_sign'], 'channel_call_sign': notify_params['channel_call_sign'],
'channel_identifier': notify_params['channel_identifier'], 'channel_identifier': notify_params['channel_identifier'],
'channel_thumb': notify_params['channel_thumb'], 'channel_thumb': notify_params['channel_thumb'],

View file

@ -776,12 +776,20 @@ class PmsConnect(object):
guids.append(helpers.get_xml_attr(guid, 'id')) guids.append(helpers.get_xml_attr(guid, 'id'))
if metadata_main.getElementsByTagName('Marker'): if metadata_main.getElementsByTagName('Marker'):
first = None
for marker in metadata_main.getElementsByTagName('Marker'): for marker in metadata_main.getElementsByTagName('Marker'):
marker_type = helpers.get_xml_attr(marker, 'type')
if marker_type == 'credits':
if first is None:
first = True
elif first is True:
first = False
markers.append({ markers.append({
'id': helpers.get_xml_attr(marker, 'id'), 'id': helpers.cast_to_int(helpers.get_xml_attr(marker, 'id')),
'type': helpers.get_xml_attr(marker, 'type'), 'type': helpers.get_xml_attr(marker, 'type'),
'start_time_offset': helpers.cast_to_int(helpers.get_xml_attr(marker, 'startTimeOffset')), 'start_time_offset': helpers.cast_to_int(helpers.get_xml_attr(marker, 'startTimeOffset')),
'end_time_offset': helpers.cast_to_int(helpers.get_xml_attr(marker, 'endTimeOffset')), 'end_time_offset': helpers.cast_to_int(helpers.get_xml_attr(marker, 'endTimeOffset')),
'first': first if marker_type == 'credits' else False,
'final': helpers.bool_true(helpers.get_xml_attr(marker, 'final')) 'final': helpers.bool_true(helpers.get_xml_attr(marker, 'final'))
}) })