diff --git a/data/interfaces/default/css/plexpy.css b/data/interfaces/default/css/plexpy.css index 649f36ac..60d76b35 100644 --- a/data/interfaces/default/css/plexpy.css +++ b/data/interfaces/default/css/plexpy.css @@ -1248,9 +1248,33 @@ a:hover .summary-poster-face-track .summary-poster-face-overlay span { } .item-children-wrapper { } +.item-children-section-title { + position: relative; + padding: 10px; + background-color: #2c2c2c; + border-bottom: 1px solid #3d3d3d; + border-top: 1px solid #282828; + height: 50px; + line-height: 22px; + padding: 13px 20px; + margin: 20px 0; +} +.item-children-section-title h4 { + position: relative; + margin: 0; + line-height: 22px; + color: #fff; + font-size: 16px; + text-align: center; + text-transform: uppercase; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} .item-children-instance { list-style: none; margin: 0; + overflow: hidden; } .item-children-instance li { float: left; diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html index 02b97a10..1c1e8f4b 100644 --- a/data/interfaces/default/info.html +++ b/data/interfaces/default/info.html @@ -32,6 +32,14 @@ directors Returns an array of directors. studio Returns the name of the studio. originally_available_at Returns the air date of the item. +query :: Usable parameters + +== Global keys == +rating_key Returns the unique identifier for the media item. +media_type Returns the type of media. Either 'movie', 'show', 'season', 'episode', 'artist', 'album', or 'track'. +title Returns the title for the search query. + + DOCUMENTATION :: END @@ -361,11 +369,34 @@ DOCUMENTATION :: END % else:
-
-

- Error retrieving item data. This media may not be available in the Plex Media Server database - anymore. -

+
+
+
+
+

+ Error retrieving item metadata. This media item is not available in the Plex Media Server library. +

+ % if query: +

+ If the item has been moved, please select the correct match below to update the PlexPy database. +

+ % endif +
+
+
+
+ % if query: +
+
+ Search Results for ${query['title']} +
+
+
+
+
+ % endif +
+
@@ -381,13 +412,6 @@ DOCUMENTATION :: END % if data: -% if data['type'] == 'movie' or data['type'] == 'show' or data['type'] == 'episode': - -% endif % if data['type'] == 'show' or data['type'] == 'artist': % endif +% if data['rating']: + +% endif +% elif query: + % endif diff --git a/data/interfaces/default/info_search_results_list.html b/data/interfaces/default/info_search_results_list.html new file mode 100644 index 00000000..cdc05b83 --- /dev/null +++ b/data/interfaces/default/info_search_results_list.html @@ -0,0 +1,222 @@ +<%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 == +results_count Returns the number of search results. +results_list Returns a dictionary of search result types. + +data['results_list'] :: Usable paramaters + +== media_type keys == +movie Returns an array of movie results +show Returns an array of show results +season Returns an array of season results +episode Returns an array of episode results +artist Returns an array of artist results +album Returns an array of album results +track Returns an array of track results + +data['results_list'][media_type] :: Usable paramaters + +== Global keys == +rating_key Returns the unique identifier for the media item. +type Returns the type of media. Either 'movie', 'episode' or 'show' or 'season'. +art Returns the location of the item's artwork +title Returns the name of the episode, show, season or movie. +duration Returns the standard runtime of the media. +content_rating Returns the age rating for the media. +summary Returns a brief description of the media plot. +grandparent_title Returns the name of the TV show. +parent_index Returns the season number of the TV show. +index Returns the episode number. +parent_thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. +writers Returns an array of writers. +thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. +parent_title Returns the name of the TV show. +rating Returns the 5 star rating value for the movie. Between 1 and 5. +year Returns the release year of the movie. +genres Returns an array of genres. +actors Returns an array of actors. +directors Returns an array of directors. +studio Returns the name of the studio. +originally_available_at Returns the air date of the item. + +DOCUMENTATION :: END + + +% if data != None: +% if data['results_count'] > 0: +% if 'movie' in data['results_list'] and data['results_list']['movie']: +
+
+

Movies

+
+ +
+% endif +% if 'show' in data['results_list'] and data['results_list']['show']: +
+
+

TV Shows

+
+ +
+% endif +% if 'season' in data['results_list'] and data['results_list']['season']: +
+
+

Seasons

+
+ +
+% endif +% if 'episode' in data['results_list'] and data['results_list']['episode']: +
+
+

Episodes

+
+ +
+% endif +% if 'artist' in data['results_list'] and data['results_list']['artist']: +
+
+

Artists

+
+ +
+% endif +% if 'album' in data['results_list'] and data['results_list']['album']: +
+
+

Albums

+
+ +
+% endif +% if 'track' in data['results_list'] and data['results_list']['track']: +
+
+

Tracks

+
+ +
+% endif +% else: +
+ No search results found. +
+% endif +% endif + diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 2343ce42..991201cc 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -779,3 +779,48 @@ class DataFactory(object): else: return 'Unable to delete items. Input user_id not valid.' + def get_search_query(self, rating_key=''): + monitor_db = database.MonitorDatabase() + + if rating_key: + query = 'SELECT rating_key, parent_rating_key, grandparent_rating_key, title, parent_title, grandparent_title, media_type ' \ + 'FROM session_history_metadata ' \ + 'WHERE rating_key = ? ' \ + 'OR parent_rating_key = ? ' \ + 'OR grandparent_rating_key = ? ' \ + 'LIMIT 1' + result = monitor_db.select(query=query, args=[rating_key, rating_key, rating_key]) + else: + result = [] + + query = {} + title = None + media_type = None + + for item in result: + if str(item['rating_key']) == rating_key: + title = item['title'] + media_type = item['media_type'] + + elif str(item['parent_rating_key']) == rating_key: + title = item['parent_title'] + if item['media_type'] == episode: + media_type = 'season' + elif item['media_type'] == track: + media_type = 'album' + + elif str(item['grandparent_rating_key']) == rating_key: + title = item['grandparent_title'] + if item['media_type'] == episode: + media_type = 'show' + elif item['media_type'] == track: + media_type = 'artist' + + if title and media_type: + query = {'title': title, + 'media_type': media_type, + 'rating_key': rating_key} + else: + return None + + return query diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index e7701788..95b41f24 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1382,13 +1382,13 @@ class PmsConnect(object): return [] search_results_count = 0 - search_results_list = {'movies': [], - 'shows': [], - 'seasons': [], - 'episodes': [], - 'artists': [], - 'albums': [], - 'tracks': [] + search_results_list = {'movie': [], + 'show': [], + 'season': [], + 'episode': [], + 'artist': [], + 'album': [], + 'track': [] } totalSize = 0 @@ -1409,9 +1409,9 @@ class PmsConnect(object): rating_key = helpers.get_xml_attr(result, 'ratingKey') metadata = self.get_metadata_details(rating_key=rating_key) if metadata['metadata']['type'] == 'movie': - search_results_list['movies'].append(metadata['metadata']) + search_results_list['movie'].append(metadata['metadata']) elif metadata['metadata']['type'] == 'episode': - search_results_list['episodes'].append(metadata['metadata']) + search_results_list['episode'].append(metadata['metadata']) search_results_count += 1 if a.getElementsByTagName('Directory'): @@ -1420,13 +1420,13 @@ class PmsConnect(object): rating_key = helpers.get_xml_attr(result, 'ratingKey') metadata = self.get_metadata_details(rating_key=rating_key) if metadata['metadata']['type'] == 'show': - search_results_list['shows'].append(metadata['metadata']) + search_results_list['show'].append(metadata['metadata']) elif metadata['metadata']['type'] == 'season': - search_results_list['seasons'].append(metadata['metadata']) + search_results_list['season'].append(metadata['metadata']) elif metadata['metadata']['type'] == 'artist': - search_results_list['artists'].append(metadata['metadata']) + search_results_list['artist'].append(metadata['metadata']) elif metadata['metadata']['type'] == 'album': - search_results_list['albums'].append(metadata['metadata']) + search_results_list['album'].append(metadata['metadata']) search_results_count += 1 if a.getElementsByTagName('Track'): @@ -1434,7 +1434,7 @@ class PmsConnect(object): for result in result_data: rating_key = helpers.get_xml_attr(result, 'ratingKey') metadata = self.get_metadata_details(rating_key=rating_key) - search_results_list['tracks'].append(metadata['metadata']) + search_results_list['track'].append(metadata['metadata']) search_results_count += 1 output = {'results_count': search_results_count, diff --git a/plexpy/webserve.py b/plexpy/webserve.py index d082e85f..28983de1 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -749,6 +749,7 @@ class WebInterface(object): @cherrypy.expose def info(self, item_id=None, source=None, **kwargs): metadata = None + query = None config = { "pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER @@ -762,12 +763,15 @@ class WebInterface(object): result = pms_connect.get_metadata_details(rating_key=item_id) if result: metadata = result['metadata'] + else: + data_factory = datafactory.DataFactory() + query = data_factory.get_search_query(rating_key=item_id) if metadata: return serve_template(templatename="info.html", data=metadata, title="Info", config=config) else: logger.warn('Unable to retrieve data.') - return serve_template(templatename="info.html", data=None, title="Info") + return serve_template(templatename="info.html", data=None, query=query, title="Info") @cherrypy.expose def get_user_recently_watched(self, user=None, user_id=None, limit='10', **kwargs):