diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html index f710532a..60df76ae 100644 --- a/data/interfaces/default/info.html +++ b/data/interfaces/default/info.html @@ -388,7 +388,7 @@ DOCUMENTATION :: END % if query:
- Search Results for ${query['title']} + Search Results for ${query['query_string']}
@@ -549,8 +549,9 @@ DOCUMENTATION :: END url: 'get_search_results_children', type: "GET", async: true, - data: { query: "${query['title']}", - media_type: "${query['media_type']}" + data: {'query': "${query['query_string']}", + 'media_type': "${query['media_type']}", + 'season_index': "${query['parent_media_index']}" }, complete: function(xhr, status) { $("#search-results-list").html(xhr.responseText); } diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index d29813e1..2dfda9cb 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -783,7 +783,8 @@ class DataFactory(object): monitor_db = database.MonitorDatabase() if rating_key: - query = 'SELECT rating_key, parent_rating_key, grandparent_rating_key, title, parent_title, grandparent_title, media_type ' \ + query = 'SELECT rating_key, parent_rating_key, grandparent_rating_key, title, parent_title, grandparent_title, ' \ + 'media_index, parent_media_index, media_type ' \ 'FROM session_history_metadata ' \ 'WHERE rating_key = ? ' \ 'OR parent_rating_key = ? ' \ @@ -794,34 +795,46 @@ class DataFactory(object): result = [] query = {} - title = None + query_string = None media_type = None for item in result: + title = item['title'] + parent_title = item['parent_title'] + grandparent_title = item['grandparent_title'] + media_index = item['media_index'] + parent_media_index = item['parent_media_index'] + if str(item['rating_key']) == rating_key: - title = item['title'] + query_string = item['title'] media_type = item['media_type'] elif str(item['parent_rating_key']) == rating_key: if item['media_type'] == 'episode': - title = item['grandparent_title'] + query_string = item['grandparent_title'] media_type = 'season' elif item['media_type'] == 'track': - title = item['parent_title'] + query_string = item['parent_title'] media_type = 'album' elif str(item['grandparent_rating_key']) == rating_key: if item['media_type'] == 'episode': - title = item['grandparent_title'] + query_string = item['grandparent_title'] media_type = 'show' elif item['media_type'] == 'track': - title = item['grandparent_title'] + query_string = item['grandparent_title'] media_type = 'artist' - if title and media_type: - query = {'title': title.replace('"', ''), + if query_string and media_type: + query = {'query_string': query_string.replace('"', ''), + 'title': title, + 'parent_title': parent_title, + 'grandparent_title': grandparent_title, + 'media_index': media_index, + 'parent_media_index': parent_media_index, 'media_type': media_type, - 'rating_key': rating_key} + 'rating_key': rating_key + } else: return None diff --git a/plexpy/webserve.py b/plexpy/webserve.py index b951554a..252dd078 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -1340,13 +1340,18 @@ class WebInterface(object): logger.warn('Unable to retrieve data.') @cherrypy.expose - def get_search_results_children(self, query, media_type=None, **kwargs): + def get_search_results_children(self, query, media_type=None, season_index=None, **kwargs): pms_connect = pmsconnect.PmsConnect() result = pms_connect.get_search_results(query) if media_type: result['results_list'] = {media_type: result['results_list'][media_type]} + if media_type == 'season' and season_index: + for season in result['results_list']['season']: + if season['index'] == season_index: + result['results_list']['season'] = [season] + break if result: return serve_template(templatename="info_search_results_list.html", data=result, title="Search Result List")