diff --git a/data/interfaces/default/info_children_list.html b/data/interfaces/default/info_children_list.html new file mode 100644 index 00000000..53e9935c --- /dev/null +++ b/data/interfaces/default/info_children_list.html @@ -0,0 +1,102 @@ +<%doc> +USAGE DOCUMENTATION :: PLEASE LEAVE THIS AT THE TOP OF THIS FILE + +For Mako templating syntax documentation please visit: http://docs.makotemplates.org/en/latest/ + +Filename: info_children_list.html +Version: 0.1 +Variable names: data [list] + +data :: Usable parameters + +== Global keys == +children_type Returns the type of children in the array. +children_count Returns the number of episodes in the array. +children_list Returns an array of episodes. + +data['children_list'] :: Usable paramaters + +== Global keys == +rating_key Returns the unique identifier for the media item. +index Returns the episode number. +title Returns the name of the episode. +thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. +parent_thumb Returns the location of the item's parent thumbnail. Use with pms_image_proxy. + +DOCUMENTATION :: END + + +% if data != None: +% if data['children_count'] > 0: +
+ +
+% endif +% endif + diff --git a/data/interfaces/default/info_episode_list.html b/data/interfaces/default/info_episode_list.html deleted file mode 100644 index 11651969..00000000 --- a/data/interfaces/default/info_episode_list.html +++ /dev/null @@ -1,53 +0,0 @@ -<%doc> -USAGE DOCUMENTATION :: PLEASE LEAVE THIS AT THE TOP OF THIS FILE - -For Mako templating syntax documentation please visit: http://docs.makotemplates.org/en/latest/ - -Filename: info_episode_list.html -Version: 0.1 -Variable names: data [list] - -data :: Usable parameters - -== Global keys == -episode_count Returns the number of episodes in the array. -episode_list Returns an array of episodes. - -data['episode_list'] :: Usable paramaters - -== Global keys == -rating_key Returns the unique identifier for the media item. -thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. -title Returns the name of the episode. -index Returns the episode number. - -DOCUMENTATION :: END - - -% if data != None: -% if data['episode_count'] > 0: -
- -
-% endif -% endif - diff --git a/data/interfaces/default/info_season_list.html b/data/interfaces/default/info_season_list.html deleted file mode 100644 index 6da68e0e..00000000 --- a/data/interfaces/default/info_season_list.html +++ /dev/null @@ -1,55 +0,0 @@ -<%doc> -USAGE DOCUMENTATION :: PLEASE LEAVE THIS AT THE TOP OF THIS FILE - -For Mako templating syntax documentation please visit: http://docs.makotemplates.org/en/latest/ - -Filename: info_season_list.html -Version: 0.1 -Variable names: data [list] - -data :: Usable parameters - -== Global keys == -season_count Returns the number of seasons in the array. -season_list Returns an array of seasons. - -data['season_list'] :: Usable paramaters - -== Global keys == -rating_key Returns the unique identifier for the media item. -thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. -title Returns the name of the season. -index Returns the season number. - -DOCUMENTATION :: END - - -% if data != None: -% if data['season_count'] > 0: -
- -
-% endif -% endif \ No newline at end of file diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 12d2ffdf..25b23253 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -90,31 +90,14 @@ class PmsConnect(object): return request """ - Return list of seasons in requested show. + Return list of children in requested library item. Parameters required: rating_key { ratingKey of parent } Optional parameters: output_format { dict, json } Output: array """ - def get_season_list(self, rating_key='', output_format=''): - uri = '/library/metadata/' + rating_key + '/children' - request = self.request_handler.make_request(uri=uri, - proto=self.protocol, - request_type='GET', - output_format=output_format) - - return request - - """ - Return list of episodes in requested season. - - Parameters required: rating_key { ratingKey of parent } - Optional parameters: output_format { dict, json } - - Output: array - """ - def get_episode_list(self, rating_key='', output_format=''): + def get_children_list(self, rating_key='', output_format=''): uri = '/library/metadata/' + rating_key + '/children' request = self.request_handler.make_request(uri=uri, proto=self.protocol, @@ -1056,86 +1039,55 @@ class PmsConnect(object): return session_output """ - Return processed and validated season list. + Return processed and validated children list. Output: array """ - def get_show_children(self, rating_key=''): - season_data = self.get_season_list(rating_key, output_format='xml') + def get_item_children(self, rating_key=''): + children_data = self.get_children_list(rating_key, output_format='xml') try: - xml_head = season_data.getElementsByTagName('MediaContainer') + xml_head = children_data.getElementsByTagName('MediaContainer') except: - logger.warn("Unable to parse XML for get_season_list.") + logger.warn("Unable to parse XML for get_children_list.") return [] - season_list = [] + children_list = [] for a in xml_head: if a.getAttribute('size'): if a.getAttribute('size') == '0': - logger.debug(u"No season data.") - season_list = {'season_count': '0', - 'season_list': [] - } - return season_list + logger.debug(u"No children data.") + children_list = {'children_count': '0', + 'children_list': [] + } + return parent_list + + result_data = [] if a.getElementsByTagName('Directory'): result_data = a.getElementsByTagName('Directory') - for result in result_data: - season_output = {'rating_key': helpers.get_xml_attr(result, 'ratingKey'), - 'index': helpers.get_xml_attr(result, 'index'), - 'title': helpers.get_xml_attr(result, 'title'), - 'thumb': helpers.get_xml_attr(result, 'thumb'), - 'parent_thumb': helpers.get_xml_attr(a, 'thumb') - } - season_list.append(season_output) - - output = {'season_count': helpers.get_xml_attr(xml_head[0], 'size'), - 'title': helpers.get_xml_attr(xml_head[0], 'title2'), - 'season_list': season_list - } - - return output - - """ - Return processed and validated episode list. - - Output: array - """ - def get_season_children(self, rating_key=''): - episode_data = self.get_episode_list(rating_key, output_format='xml') - - try: - xml_head = episode_data.getElementsByTagName('MediaContainer') - except: - logger.warn("Unable to parse XML for get_episode_list.") - return [] - - episode_list = [] - - for a in xml_head: - if a.getAttribute('size'): - if a.getAttribute('size') == '0': - logger.debug(u"No episode data.") - episode_list = {'episode_count': '0', - 'episode_list': [] - } - return episode_list - if a.getElementsByTagName('Video'): result_data = a.getElementsByTagName('Video') - for result in result_data: - episode_output = {'rating_key': helpers.get_xml_attr(result, 'ratingKey'), - 'index': helpers.get_xml_attr(result, 'index'), - 'title': helpers.get_xml_attr(result, 'title'), - 'thumb': helpers.get_xml_attr(result, 'thumb') - } - episode_list.append(episode_output) + if a.getElementsByTagName('Track'): + result_data = a.getElementsByTagName('Track') - output = {'episode_count': helpers.get_xml_attr(xml_head[0], 'size'), + if result_data: + for result in result_data: + children_output = {'rating_key': helpers.get_xml_attr(result, 'ratingKey'), + 'index': helpers.get_xml_attr(result, 'index'), + 'title': helpers.get_xml_attr(result, 'title'), + 'thumb': helpers.get_xml_attr(result, 'thumb'), + 'parent_thumb': helpers.get_xml_attr(a, 'thumb'), + 'duration': helpers.get_xml_attr(result, 'duration') + } + children_list.append(children_output) + + + output = {'children_count': helpers.get_xml_attr(xml_head[0], 'size'), + 'children_type': helpers.get_xml_attr(xml_head[0], 'viewGroup'), 'title': helpers.get_xml_attr(xml_head[0], 'title2'), - 'episode_list': episode_list + 'children_list': children_list } return output diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 6f9b9d2e..6bb6f9ac 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -821,28 +821,16 @@ class WebInterface(object): return serve_template(templatename="user_platform_stats.html", data=None, title="Platform Stats") @cherrypy.expose - def get_show_children(self, rating_key='', **kwargs): + def get_item_children(self, rating_key='', **kwargs): pms_connect = pmsconnect.PmsConnect() - result = pms_connect.get_show_children(rating_key) + result = pms_connect.get_item_children(rating_key) if result: - return serve_template(templatename="info_season_list.html", data=result, title="Season List") + return serve_template(templatename="info_children_list.html", data=result, title="Children List") else: logger.warn('Unable to retrieve data.') - return serve_template(templatename="info_season_list.html", data=None, title="Season List") - - @cherrypy.expose - def get_season_children(self, rating_key='', **kwargs): - - pms_connect = pmsconnect.PmsConnect() - result = pms_connect.get_season_children(rating_key) - - if result: - return serve_template(templatename="info_episode_list.html", data=result, title="Episode List") - else: - logger.warn('Unable to retrieve data.') - return serve_template(templatename="info_episode_list.html", data=None, title="Episode List") + return serve_template(templatename="info_children_list.html", data=None, title="Children List") @cherrypy.expose def get_metadata_json(self, rating_key='', **kwargs):