From 16b1b2a781bcded1f7a27ad1b4519748619f6bb8 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Thu, 27 Aug 2015 14:41:12 -0700 Subject: [PATCH 1/7] Add episode number to info navbar --- data/interfaces/default/info.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html index 04185bf5..6b7eddbb 100644 --- a/data/interfaces/default/info.html +++ b/data/interfaces/default/info.html @@ -73,7 +73,7 @@ DOCUMENTATION :: END Season ${data['parent_index']} - ${data['title']} + Eipsode ${data['index']} - ${data['title']} % endif From 9fc44f793b8c958328fc6c7363e3db1625860469 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Thu, 27 Aug 2015 15:31:54 -0700 Subject: [PATCH 2/7] Change episodes default to art on dashboard --- data/interfaces/default/current_activity.html | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/data/interfaces/default/current_activity.html b/data/interfaces/default/current_activity.html index 92d28b0e..de2610e1 100644 --- a/data/interfaces/default/current_activity.html +++ b/data/interfaces/default/current_activity.html @@ -68,21 +68,22 @@ DOCUMENTATION :: END % endif
+ % if a['type'] == 'movie' and not a['indexes']:
+ % elif a['type'] == 'episode' and not a['indexes']: +
% elif a['indexes']: - + % else: - % if a['type'] == 'episode': -
- % elif a['type'] == 'track': + % if a['type'] == 'track':
% elif a['type'] == 'clip':
% else: -
+
% endif % endif
@@ -208,11 +209,6 @@ DOCUMENTATION :: END $(this).html(millisecondsToMinutes($(this).text(), false)); }); - // Tooltips - $('.dashboard-activity-metadata-platform').each(function() { - $(this).tooltip(); - }); - // Show/Hide activity info $('.btn-activity-info').on('click', function(e) { e.preventDefault(); From a682cd31afa429a1772553b383096f4fd6769023 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Thu, 27 Aug 2015 15:38:39 -0700 Subject: [PATCH 3/7] Remove video fields from stream info modal if item is a track --- data/interfaces/default/stream_data.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/data/interfaces/default/stream_data.html b/data/interfaces/default/stream_data.html index 6aba69ec..c0cf86fd 100644 --- a/data/interfaces/default/stream_data.html +++ b/data/interfaces/default/stream_data.html @@ -54,6 +54,7 @@ DOCUMENTATION :: END

Stream Details

+ % if data['media_type'] != 'track':
Video
    % if data['transcode_video_dec'] != 'direct play': @@ -74,6 +75,7 @@ DOCUMENTATION :: END
  • Video Height: ${data['height']}
  • % endif
+ % endif
Audio
    % if data['transcode_audio_dec'] != 'direct play': @@ -91,11 +93,14 @@ DOCUMENTATION :: END

    Media Source Details

    • Container: ${data['container']}
    • + % if data['media_type'] != 'track':
    • Resolution: ${data['height']}p
    • + % endif
    • Bitrate: ${data['bitrate']} kbps
+ % if data['media_type'] != 'track':

Video Source Details

  • Width: ${data['width']}
  • @@ -104,6 +109,7 @@ DOCUMENTATION :: END
  • Video Frame Rate: ${data['video_framerate']}
  • Video Codec: ${data['video_codec']}
+ % endif

Audio Source Details

- + % elif top_stat['stat_id'] == 'last_watched' and top_stat['rows']: +
+
  • +
    + +
    +
    + % if top_stat['rows'][0]['user_id']: + + % else: + + % endif + ${top_stat['rows'][0]['friendly_name']} + +
    +

    + + + - ${top_stat['rows'][0]['platform_type']} +

    +
    +
    + + % if top_stat['rows'][0]['thumb']: +
    +
    +
    + % else: +
    +
    +
    + % endif +
    + %if len(top_stat['rows']) > 1: +
    + + % endif +
  • +
    % endif % endfor diff --git a/data/interfaces/default/index.html b/data/interfaces/default/index.html index 8a31845c..9c1c361f 100644 --- a/data/interfaces/default/index.html +++ b/data/interfaces/default/index.html @@ -110,6 +110,17 @@ }); }); + var date_format = 'YYYY-MM-DD'; + var time_format = 'hh:mm a'; + $.ajax({ + url: 'get_date_formats', + type: 'GET', + success: function(data) { + date_format = data.date_format; + time_format = data.time_format; + } + }); + getHomeStats(${config['home_stats_length']}, ${config['home_stats_type']}, ${config['home_stats_count']}); diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index c7fed0d7..9607ed3c 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -143,7 +143,7 @@ class DataFactory(object): stat_count = '5' # This actually determines the output order in the home page - stats_queries = ["top_tv", "popular_tv", "top_movies", "popular_movies", "top_users", "top_platforms"] + stats_queries = ["top_tv", "popular_tv", "top_movies", "popular_movies", "top_users", "top_platforms", "last_watched"] home_stats = [] for stat in stats_queries: @@ -361,7 +361,7 @@ class DataFactory(object): 'total_plays': item[2], 'total_duration': item[3], 'last_play': item[4], - 'thumb': user_thumb, + 'user_thumb': user_thumb, 'grandparent_thumb': '', 'users_watched': '', 'rating_key': '', @@ -418,6 +418,59 @@ class DataFactory(object): 'stat_type': sort_type, 'rows': top_platform}) + elif 'last_watched' in stat: + last_watched = [] + try: + query = 'SELECT session_history_metadata.id, ' \ + 'session_history.user, ' \ + '(case when users.friendly_name is null then session_history.user else ' \ + 'users.friendly_name end) as friendly_name,' \ + 'users.user_id, ' \ + 'users.custom_avatar_url as user_thumb, ' \ + 'session_history_metadata.full_title, ' \ + 'session_history_metadata.rating_key, ' \ + 'session_history_metadata.thumb, ' \ + 'session_history_metadata.grandparent_thumb, ' \ + 'MAX(session_history.started) as last_watch, ' \ + 'session_history.player as platform ' \ + 'FROM session_history_metadata ' \ + 'JOIN session_history ON session_history_metadata.id = session_history.id ' \ + 'LEFT OUTER JOIN users ON session_history.user_id = users.user_id ' \ + 'WHERE datetime(session_history.stopped, "unixepoch", "localtime") ' \ + '>= datetime("now", "-%s days", "localtime") ' \ + 'AND (session_history_metadata.media_type = "movie" ' \ + 'OR session_history_metadata.media_type = "episode") ' \ + 'GROUP BY session_history_metadata.full_title ' \ + 'ORDER BY last_watch DESC ' \ + 'LIMIT %s' % (time_range, stat_count) + result = monitor_db.select(query) + except: + logger.warn("Unable to execute database query.") + return None + + for item in result: + if not item[8] or item[8] == '': + thumb = item[7] + else: + thumb = item[8] + + row = {'row_id': item[0], + 'user': item[1], + 'friendly_name': item[2], + 'user_id': item[3], + 'user_thumb': item[4], + 'title': item[5], + 'rating_key': item[6], + 'thumb': thumb, + 'grandparent_thumb': item[8], + 'last_watch': item[9], + 'platform': item[10], + } + last_watched.append(row) + + home_stats.append({'stat_id': stat, + 'rows': last_watched}) + return home_stats def get_stream_details(self, row_id=None): From 85a3f1553138eda28ef5cbcce46dd142187cf6e8 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Fri, 28 Aug 2015 01:31:35 -0700 Subject: [PATCH 5/7] Fix platform_type missing for last watched home stats --- plexpy/datafactory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 9607ed3c..c45b9de0 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -464,7 +464,7 @@ class DataFactory(object): 'thumb': thumb, 'grandparent_thumb': item[8], 'last_watch': item[9], - 'platform': item[10], + 'platform_type': item[10], } last_watched.append(row) From 53c98d0acc089491c90462c6fd721c3dd7c6195c Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Fri, 28 Aug 2015 11:32:58 -0700 Subject: [PATCH 6/7] Fix typo --- data/interfaces/default/info.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html index 6b7eddbb..08c5005b 100644 --- a/data/interfaces/default/info.html +++ b/data/interfaces/default/info.html @@ -73,7 +73,7 @@ DOCUMENTATION :: END Season ${data['parent_index']} - Eipsode ${data['index']} - ${data['title']} + Episode ${data['index']} - ${data['title']} % endif
    From 9b03ffbaa12bd4aaac46eb2fad91bd346f71ee62 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Fri, 28 Aug 2015 13:05:45 -0700 Subject: [PATCH 7/7] Fix season_list --- plexpy/pmsconnect.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 1c7e3f38..f23eb32d 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -842,9 +842,9 @@ class PmsConnect(object): if a.getAttribute('size'): if a.getAttribute('size') == '0': logger.debug(u"No season data.") - episode_list = {'season_count': '0', - 'season_list': [] - } + season_list = {'season_count': '0', + 'season_list': [] + } return season_list if a.getElementsByTagName('Directory'):