Add get_children_metadata API command

This commit is contained in:
JonnyWong16 2021-02-02 13:39:14 -08:00
parent 5b5ccee23b
commit 270af26b82
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 87 additions and 7 deletions

View file

@ -2293,6 +2293,10 @@ class PmsConnect(object):
Output: array
"""
default_return = {'children_count': 0,
'children_list': []
}
if media_type == 'playlist':
children_data = self.get_playlist_items(rating_key, output_format='xml')
elif get_grandchildren:
@ -2304,7 +2308,7 @@ class PmsConnect(object):
xml_head = children_data.getElementsByTagName('MediaContainer')
except Exception as e:
logger.warn("Tautulli Pmsconnect :: Unable to parse XML for get_item_children: %s." % e)
return []
return default_return
children_list = []
@ -2312,10 +2316,7 @@ class PmsConnect(object):
if a.getAttribute('size'):
if a.getAttribute('size') == '0':
logger.debug("Tautulli Pmsconnect :: No children data.")
children_list = {'children_count': 0,
'children_list': []
}
return children_list
return default_return
result_data = []
@ -2356,8 +2357,8 @@ class PmsConnect(object):
media_type = 'photo_album'
children_output = {'media_type': media_type,
'section_id': helpers.get_xml_attr(m, 'librarySectionID'),
'library_name': helpers.get_xml_attr(m, 'librarySectionTitle'),
'section_id': helpers.get_xml_attr(a, 'librarySectionID'),
'library_name': helpers.get_xml_attr(a, 'librarySectionTitle'),
'rating_key': helpers.get_xml_attr(m, 'ratingKey'),
'parent_rating_key': helpers.get_xml_attr(m, 'parentRatingKey'),
'grandparent_rating_key': helpers.get_xml_attr(m, 'grandparentRatingKey'),

View file

@ -4479,6 +4479,85 @@ class WebInterface(object):
else:
return serve_template(templatename="info_collection_list.html", data=None, title=title)
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))
@addtoapi("get_children_metadata")
def get_children_metadata_details(self, rating_key='', media_type=None, **kwargs):
""" Get the metadata for the children of a media item.
```
Required parameters:
rating_key (str): Rating key of the item
media_type (str): Media type of the item
Optional parameters:
None
Returns:
json:
{"children_count": 9,
"children_type": "season",
"title": "Game of Thrones",
"children_list": [
{...},
{"actors": [],
"added_at": "1403553078",
"art": "/library/metadata/1219/art/1562110346",
"audience_rating": "",
"audience_rating_image": "",
"banner": "",
"content_rating": "",
"directors": [],
"duration": "",
"full_title": "Season 1"
"genres": [],
"grandparent_rating_key": "",
"grandparent_thumb": "",
"grandparent_title": "",
"guid": "com.plexapp.agents.thetvdb://121361/1?lang=en",
"labels": [],
"last_viewed_at": "1589992348",
"library_name": "TV Shows",
"media_index": "1",
"media_type": "season",
"original_title": "",
"originally_available_at": "",
"parent_media_index": "1",
"parent_rating_key": "1219",
"parent_thumb": "/library/metadata/1219/thumb/1562110346",
"parent_title": "Game of Thrones",
"rating": "",
"rating_image": "",
"rating_key": "1220",
"section_id": "2",
"sort_title": "",
"studio": "",
"summary": "",
"tagline": "",
"thumb": "/library/metadata/1220/thumb/1602176313",
"title": "Season 1",
"updated_at": "1602176313",
"user_rating": "",
"writers": [],
"year": ""
},
{...},
{...}
]
}
```
"""
pms_connect = pmsconnect.PmsConnect()
metadata = pms_connect.get_item_children(rating_key=rating_key,
media_type=media_type)
if metadata:
return metadata
else:
logger.warn("Unable to retrieve data for get_children_metadata_details.")
return metadata
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))