Add season/episode/album/track count to notification parameters

This commit is contained in:
JonnyWong16 2018-03-16 09:42:32 -07:00
parent feb762ce8b
commit b505286caf
2 changed files with 23 additions and 4 deletions

View file

@ -391,6 +391,10 @@ NOTIFICATION_PARAMETERS = [
{'name': 'Episode Number 00', 'type': 'int', 'value': 'episode_num00', 'description': 'The two digit episode number.', 'example': 'e.g. 06, or 06-10'}, {'name': 'Episode Number 00', 'type': 'int', 'value': 'episode_num00', 'description': 'The two digit episode number.', 'example': 'e.g. 06, or 06-10'},
{'name': 'Track Number', 'type': 'int', 'value': 'track_num', 'description': 'The track number.', 'example': 'e.g. 4, or 4-10'}, {'name': 'Track Number', 'type': 'int', 'value': 'track_num', 'description': 'The track number.', 'example': 'e.g. 4, or 4-10'},
{'name': 'Track Number 00', 'type': 'int', 'value': 'track_num00', 'description': 'The two digit track number.', 'example': 'e.g. 04, or 04-10'}, {'name': 'Track Number 00', 'type': 'int', 'value': 'track_num00', 'description': 'The two digit track number.', 'example': 'e.g. 04, or 04-10'},
{'name': 'Season Count', 'type': 'int', 'value': 'season_count', 'description': 'The number of seasons.'},
{'name': 'Episode Count', 'type': 'int', 'value': 'episode_count', 'description': 'The number of episodes.'},
{'name': 'Album Count', 'type': 'int', 'value': 'album_count', 'description': 'The number of albums.'},
{'name': 'Track Count', 'type': 'int', 'value': 'track_count', 'description': 'The number of tracks.'},
{'name': 'Year', 'type': 'int', 'value': 'year', 'description': 'The release year for the item.'}, {'name': 'Year', 'type': 'int', 'value': 'year', 'description': 'The release year for the item.'},
{'name': 'Release Date', 'type': 'int', 'value': 'release_date', 'description': 'The release date (in date format) for the item.'}, {'name': 'Release Date', 'type': 'int', 'value': 'release_date', 'description': 'The release date (in date format) for the item.'},
{'name': 'Air Date', 'type': 'str', 'value': 'air_date', 'description': 'The air date (in date format) for the item.'}, {'name': 'Air Date', 'type': 'str', 'value': 'air_date', 'description': 'The air date (in date format) for the item.'},

View file

@ -640,13 +640,17 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
album_name = '' album_name = ''
track_name = '' track_name = ''
num, num00 = format_group_index([helpers.cast_to_int(d['media_index']) child_num = [helpers.cast_to_int(
for d in child_metadata if d['parent_rating_key'] == rating_key]) d['media_index']) for d in child_metadata if d['parent_rating_key'] == rating_key]
num, num00 = format_group_index(child_num)
season_num, season_num00 = num, num00 season_num, season_num00 = num, num00
episode_num, episode_num00 = '', '' episode_num, episode_num00 = '', ''
track_num, track_num00 = '', '' track_num, track_num00 = '', ''
child_count = len(child_num)
grandchild_count = ''
elif ((manual_trigger or plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_PARENT) elif ((manual_trigger or plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_PARENT)
and notify_params['media_type'] in ('season', 'album')): and notify_params['media_type'] in ('season', 'album')):
show_name = notify_params['parent_title'] show_name = notify_params['parent_title']
@ -654,14 +658,19 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
artist_name = notify_params['parent_title'] artist_name = notify_params['parent_title']
album_name = notify_params['title'] album_name = notify_params['title']
track_name = '' track_name = ''
season_num = str(notify_params['media_index']).zfill(1) season_num = str(notify_params['media_index']).zfill(1)
season_num00 = str(notify_params['media_index']).zfill(2) season_num00 = str(notify_params['media_index']).zfill(2)
num, num00 = format_group_index([helpers.cast_to_int(d['media_index']) grandchild_num = [helpers.cast_to_int(
for d in child_metadata if d['parent_rating_key'] == rating_key]) d['media_index']) for d in child_metadata if d['parent_rating_key'] == rating_key]
num, num00 = format_group_index(grandchild_num)
episode_num, episode_num00 = num, num00 episode_num, episode_num00 = num, num00
track_num, track_num00 = num, num00 track_num, track_num00 = num, num00
child_count = 1
grandchild_count = len(grandchild_num)
else: else:
show_name = notify_params['grandparent_title'] show_name = notify_params['grandparent_title']
episode_name = notify_params['title'] episode_name = notify_params['title']
@ -674,6 +683,8 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
episode_num00 = str(notify_params['media_index']).zfill(2) episode_num00 = str(notify_params['media_index']).zfill(2)
track_num = str(notify_params['media_index']).zfill(1) track_num = str(notify_params['media_index']).zfill(1)
track_num00 = str(notify_params['media_index']).zfill(2) track_num00 = str(notify_params['media_index']).zfill(2)
child_count = 1
grandchild_count = 1
available_params = { available_params = {
# Global paramaters # Global paramaters
@ -783,6 +794,10 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
'episode_num00': episode_num00, 'episode_num00': episode_num00,
'track_num': track_num, 'track_num': track_num,
'track_num00': track_num00, 'track_num00': track_num00,
'season_count': child_count,
'episode_count': grandchild_count,
'album_count': child_count,
'track_count': grandchild_count,
'year': notify_params['year'], 'year': notify_params['year'],
'release_date': arrow.get(notify_params['originally_available_at']).format(date_format) 'release_date': arrow.get(notify_params['originally_available_at']).format(date_format)
if notify_params['originally_available_at'] else '', if notify_params['originally_available_at'] else '',