Filter season search by season index

This commit is contained in:
Jonathan Wong 2015-09-24 23:41:15 -07:00
parent c45a903f9f
commit 91446d01a7
3 changed files with 33 additions and 14 deletions

View file

@ -388,7 +388,7 @@ DOCUMENTATION :: END
% if query:
<div class='table-card-header'>
<div class="header-bar">
<span>Search Results for <strong>${query['title']}</strong></span>
<span>Search Results for <strong>${query['query_string']}</strong></span>
</div>
</div>
<div class='table-card-back'>
@ -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); }

View file

@ -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:
if str(item['rating_key']) == rating_key:
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:
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

View file

@ -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")