mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Filter season search by season index
This commit is contained in:
parent
c45a903f9f
commit
91446d01a7
3 changed files with 33 additions and 14 deletions
|
@ -388,7 +388,7 @@ DOCUMENTATION :: END
|
||||||
% if query:
|
% if query:
|
||||||
<div class='table-card-header'>
|
<div class='table-card-header'>
|
||||||
<div class="header-bar">
|
<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>
|
</div>
|
||||||
<div class='table-card-back'>
|
<div class='table-card-back'>
|
||||||
|
@ -549,8 +549,9 @@ DOCUMENTATION :: END
|
||||||
url: 'get_search_results_children',
|
url: 'get_search_results_children',
|
||||||
type: "GET",
|
type: "GET",
|
||||||
async: true,
|
async: true,
|
||||||
data: { query: "${query['title']}",
|
data: {'query': "${query['query_string']}",
|
||||||
media_type: "${query['media_type']}"
|
'media_type': "${query['media_type']}",
|
||||||
|
'season_index': "${query['parent_media_index']}"
|
||||||
},
|
},
|
||||||
complete: function(xhr, status) {
|
complete: function(xhr, status) {
|
||||||
$("#search-results-list").html(xhr.responseText); }
|
$("#search-results-list").html(xhr.responseText); }
|
||||||
|
|
|
@ -783,7 +783,8 @@ class DataFactory(object):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if rating_key:
|
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 ' \
|
'FROM session_history_metadata ' \
|
||||||
'WHERE rating_key = ? ' \
|
'WHERE rating_key = ? ' \
|
||||||
'OR parent_rating_key = ? ' \
|
'OR parent_rating_key = ? ' \
|
||||||
|
@ -794,34 +795,46 @@ class DataFactory(object):
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
query = {}
|
query = {}
|
||||||
title = None
|
query_string = None
|
||||||
media_type = None
|
media_type = None
|
||||||
|
|
||||||
for item in result:
|
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:
|
if str(item['rating_key']) == rating_key:
|
||||||
title = item['title']
|
query_string = item['title']
|
||||||
media_type = item['media_type']
|
media_type = item['media_type']
|
||||||
|
|
||||||
elif str(item['parent_rating_key']) == rating_key:
|
elif str(item['parent_rating_key']) == rating_key:
|
||||||
if item['media_type'] == 'episode':
|
if item['media_type'] == 'episode':
|
||||||
title = item['grandparent_title']
|
query_string = item['grandparent_title']
|
||||||
media_type = 'season'
|
media_type = 'season'
|
||||||
elif item['media_type'] == 'track':
|
elif item['media_type'] == 'track':
|
||||||
title = item['parent_title']
|
query_string = item['parent_title']
|
||||||
media_type = 'album'
|
media_type = 'album'
|
||||||
|
|
||||||
elif str(item['grandparent_rating_key']) == rating_key:
|
elif str(item['grandparent_rating_key']) == rating_key:
|
||||||
if item['media_type'] == 'episode':
|
if item['media_type'] == 'episode':
|
||||||
title = item['grandparent_title']
|
query_string = item['grandparent_title']
|
||||||
media_type = 'show'
|
media_type = 'show'
|
||||||
elif item['media_type'] == 'track':
|
elif item['media_type'] == 'track':
|
||||||
title = item['grandparent_title']
|
query_string = item['grandparent_title']
|
||||||
media_type = 'artist'
|
media_type = 'artist'
|
||||||
|
|
||||||
if title and media_type:
|
if query_string and media_type:
|
||||||
query = {'title': title.replace('"', ''),
|
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,
|
'media_type': media_type,
|
||||||
'rating_key': rating_key}
|
'rating_key': rating_key
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -1340,13 +1340,18 @@ class WebInterface(object):
|
||||||
logger.warn('Unable to retrieve data.')
|
logger.warn('Unable to retrieve data.')
|
||||||
|
|
||||||
@cherrypy.expose
|
@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()
|
pms_connect = pmsconnect.PmsConnect()
|
||||||
result = pms_connect.get_search_results(query)
|
result = pms_connect.get_search_results(query)
|
||||||
|
|
||||||
if media_type:
|
if media_type:
|
||||||
result['results_list'] = {media_type: result['results_list'][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:
|
if result:
|
||||||
return serve_template(templatename="info_search_results_list.html", data=result, title="Search Result List")
|
return serve_template(templatename="info_search_results_list.html", data=result, title="Search Result List")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue