diff --git a/data/interfaces/default/css/plexpy.css b/data/interfaces/default/css/plexpy.css index ff44dbea..649f36ac 100644 --- a/data/interfaces/default/css/plexpy.css +++ b/data/interfaces/default/css/plexpy.css @@ -33,6 +33,33 @@ select.input-sm { color: #999; outline: none; } +select[multiple] { + height: 125px; + margin: 5px 0 5px 0; + color: #fff; + border: 0px solid #444; + background: #555; + padding: 2px 2px; + background-color: #555; + border-radius: 3px; + transition: background-color .3s; +} +select[multiple]:focus { + outline: 0; + outline: thin dotted \9; + color: #555; + background-color: #fff; + transition: background-color .3s; +} +select[multiple]:focus::-webkit-scrollbar-thumb { + background-color: rgba(0,0,0,.15); +} +select[multiple] option { + padding: 6px 10px; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; +} img { -webkit-box-sizing: content-box; -moz-box-sizing: content-box; diff --git a/data/interfaces/default/home_stats.html b/data/interfaces/default/home_stats.html index 01fb0cdd..36c17d7f 100644 --- a/data/interfaces/default/home_stats.html +++ b/data/interfaces/default/home_stats.html @@ -17,19 +17,19 @@ data[array_index]['rows'] :: Usable parameters row_id Return the db row id for a metadata item if one exists -== Only if 'stat_id' is 'top_tv' or 'popular_tv' or 'top_movies' or 'popular_movies' or 'last_watched' == +== Only if 'stat_id' is 'top_tv' or 'popular_tv' or 'top_movies' or 'popular_movies' or 'top_music' or 'popular_music' or 'last_watched' == thumb Return the thumb for the media item. -== Only if 'stat_id' is 'top_tv' or 'popular_tv' == +== Only if 'stat_id' is 'top_tv' or 'popular_tv' or 'top_music' or 'popular_music' == grandparent_thumb Returns location of the item's thumbnail. Use with pms_image_proxy. rating_key Returns the unique identifier for the media item. title Returns the title for the associated stat. -== Only if 'stat_id' is 'top_tv' or 'top_movies' or 'top_user' or 'top_platform' == +== Only if 'stat_id' is 'top_tv' or 'top_movies' or 'top_music' or 'top_user' or 'top_platform' == total_plays Returns the count for the associated stat. total_duration Returns the total duration for the associated stat. -== Only of 'stat_id' is 'popular_tv' or 'popular_movies' == +== Only of 'stat_id' is 'popular_tv' or 'popular_movies' or 'popular_music' == users_watched Returns the count for the associated stat. == Only if 'stat_id' is 'top_user' or 'last_watched' == @@ -372,6 +372,158 @@ DOCUMENTATION :: END % endif + % elif top_stat['stat_id'] == 'top_music' and top_stat['rows']: +
+
  • +
    +
    +

    Most Listened to Artist

    +
    +
    +

    + + ${top_stat['rows'][0]['title']} + +

    + % if top_stat['stat_type'] == 'total_plays': +

    ${top_stat['rows'][0]['total_plays']}

    +

    plays

    + % else: + ${top_stat['rows'][0]['total_duration'] | hd} + % endif +
    +
    + + % if top_stat['rows'][0]['grandparent_thumb']: +
    +
    +
    + % else: +
    +
    +
    + % endif +
    + %if len(top_stat['rows']) > 1: +
    + + % endif +
  • +
    + % elif top_stat['stat_id'] == 'popular_music' and top_stat['rows']: +
    +
  • +
    +
    +

    Most Popular Artist

    +
    +
    +

    + + ${top_stat['rows'][0]['title']} + +

    +

    ${top_stat['rows'][0]['users_watched']}

    +

    users

    +
    +
    + + % if top_stat['rows'][0]['grandparent_thumb'] != '': +
    +
    +
    + % else: +
    +
    +
    + % endif +
    + %if len(top_stat['rows']) > 1: +
    + + % endif +
  • +
    % elif top_stat['stat_id'] == 'top_users' and top_stat['rows']:
  • diff --git a/data/interfaces/default/index.html b/data/interfaces/default/index.html index ed983ca6..5f8caeba 100644 --- a/data/interfaces/default/index.html +++ b/data/interfaces/default/index.html @@ -16,6 +16,7 @@
  • + % if config['home_stats_cards'] > 'watch_statistics':
    @@ -27,6 +28,8 @@
    + % endif + % if config['home_library_cards'] > 'library_statistics':
    @@ -38,6 +41,7 @@
    + % endif
    @@ -82,15 +86,12 @@ currentActivity(); setInterval(currentActivity, 15000); - function getHomeStats(days, stat_type, stat_count, notify_watched_percent) { + function getHomeStats(days) { $.ajax({ url: 'home_stats', cache: false, async: true, - data: {time_range: days, - stat_type: stat_type, - stat_count: stat_count, - notify_watched_percent: notify_watched_percent}, + data: { }, complete: function(xhr, status) { $("#home-stats").html(xhr.responseText); } @@ -168,10 +169,7 @@ } }); - getHomeStats(${config['home_stats_length']}, - ${config['home_stats_type']}, - ${config['home_stats_count']}, - ${config['notify_watched_percent']}); + getHomeStats(); getLibraryStatsHeader(); getLibraryStats(); diff --git a/data/interfaces/default/library_stats.html b/data/interfaces/default/library_stats.html index 34ef2a91..12e7135c 100644 --- a/data/interfaces/default/library_stats.html +++ b/data/interfaces/default/library_stats.html @@ -73,6 +73,6 @@ DOCUMENTATION :: END % endfor % else: -
    Unable to retrieve data from database. Please check your settings. +
    Unable to retrieve data from server. Please check your settings.

    % endif \ No newline at end of file diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index d13e8700..90a0c185 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -34,14 +34,15 @@ available_notification_agents = notifiers.available_notification_agents()
    @@ -83,10 +84,33 @@ available_notification_agents = notifiers.available_notification_agents()

    Set your preferred time format. Click here to see the parameter list.

    +

    +
    +
    -

    Homepage Statistics

    +

    Watch Statistics

    +
    + +
    +
    + +
    +
    +

    Select the cards to show in the watch statistics on the home page. Select none to disable.

    +
    @@ -95,7 +119,7 @@ available_notification_agents = notifiers.available_notification_agents()
    -

    Specify the number of days for the statistics on the home page. Default is 30 days.

    +

    Specify the number of days for the watch statistics on the home page. Default is 30 days.

    @@ -105,7 +129,7 @@ available_notification_agents = notifiers.available_notification_agents()
    -

    Specify the number of items to show in the top lists for the statistics on the home page. Max is 10 items, default is 5 items, 0 to disable.

    +

    Specify the number of items to show in the top lists for the watch statistics on the home page. Max is 10 items, default is 5 items, 0 to disable.

    Use play duration instead of play count to generate statistics.

    + +
    +

    Library Statistics

    +
    + +
    + +
    +
    + +
    +
    +

    Select the cards to show in the library statistics on the home page. Select none to disable.

    +

    + -
    +

    Web Interface

    @@ -164,7 +205,7 @@ available_notification_agents = notifiers.available_notification_agents()

    -
    +

    Authentication

    @@ -216,7 +257,7 @@ available_notification_agents = notifiers.available_notification_agents()

    -
    +

    Plex Media Server

    @@ -272,7 +313,7 @@ available_notification_agents = notifiers.available_notification_agents()
    -
    +

    Plex.tv Authentication

    @@ -315,7 +356,7 @@ available_notification_agents = notifiers.available_notification_agents()

    -
    +

    Extra Settings

    @@ -334,7 +375,7 @@ available_notification_agents = notifiers.available_notification_agents()

    -
    +

    Monitoring Settings

    @@ -416,7 +457,7 @@ available_notification_agents = notifiers.available_notification_agents()

    -
    +

    Global Notification Toggles

    @@ -566,7 +607,7 @@ available_notification_agents = notifiers.available_notification_agents()

    -
    +

    Notification Agents

    @@ -1178,6 +1219,47 @@ $(document).ready(function() { } var accordion = new Accordion($('#accordion'), false); + + var cards = "${config['home_stats_cards']}".split(/[\s,]+/); + cards.forEach(function (item) { + $('#card-'+item).prop('selected', !$(this).prop('selected')); + }); + $('#home_stats_cards').on('mousedown', function(e) { + e.preventDefault(); + var scroll = this.scrollTop; + e.target.selected = !e.target.selected; + this.scrollTop = scroll; + }).on('mousemove', function(e) { + e.preventDefault() + }); + + $.ajax({ + url: 'get_server_children', + data: { }, + async: true, + complete: function (xhr, status) { + server_children_info = $.parseJSON(xhr.responseText); + libraries_list = server_children_info.libraries_list; + for (var i in libraries_list) { + title = libraries_list[i].title; + key = libraries_list[i].key; + $('#home_library_cards').append('') + } + var cards = "${config['home_library_cards']}".split(/[\s,]+/); + cards.forEach(function (item) { + $('#card-'+item).prop('selected', !$(this).prop('selected')); + }); + } + }); + $('#home_library_cards').on('mousedown', function(e) { + e.preventDefault(); + var scroll = this.scrollTop; + e.target.selected = !e.target.selected; + this.scrollTop = scroll; + }).on('mousemove', function(e) { + e.preventDefault() + }); + }); diff --git a/plexpy/config.py b/plexpy/config.py index 9d41b67a..73034be2 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -82,9 +82,11 @@ _CONFIG_DEFINITIONS = { 'GROWL_ON_RESUME': (int, 'Growl', 0), 'GROWL_ON_BUFFER': (int, 'Growl', 0), 'GROWL_ON_WATCHED': (int, 'Growl', 0), + 'HOME_LIBRARY_CARDS': (str, 'General', 'library_statistics_first'), 'HOME_STATS_LENGTH': (int, 'General', 30), 'HOME_STATS_TYPE': (int, 'General', 0), 'HOME_STATS_COUNT': (int, 'General', 5), + 'HOME_STATS_CARDS': (str, 'General', 'watch_statistics, top_tv, popular_tv, top_movies, popular_movies, top_music, popular_music, top_users, top_platforms, last_watched'), 'HTTPS_CERT': (str, 'General', ''), 'HTTPS_KEY': (str, 'General', ''), 'HTTP_HOST': (str, 'General', '0.0.0.0'), diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 5412922d..52d21e42 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -131,22 +131,14 @@ class DataFactory(object): return dict - def get_home_stats(self, time_range='30', stat_type='0', stat_count='5', notify_watched_percent='85'): + def get_home_stats(self, time_range='30', stats_type='0', stats_count='5', stats_cards='', notify_watched_percent='85'): monitor_db = database.MonitorDatabase() - if not time_range.isdigit(): - time_range = '30' + sort_type = 'total_plays' if stats_type == '0' else 'total_duration' - sort_type = 'total_plays' if stat_type == '0' else 'total_duration' - - if not time_range.isdigit(): - 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", "last_watched"] home_stats = [] - for stat in stats_queries: + for stat in stats_cards: if 'top_tv' in stat: top_tv = [] try: @@ -166,7 +158,7 @@ class DataFactory(object): '>= datetime("now", "-%s days", "localtime") ' \ 'AND session_history_metadata.media_type = "episode" ' \ 'GROUP BY session_history_metadata.grandparent_title ' \ - 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stat_count) + 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stats_count) result = monitor_db.select(query) except: logger.warn("Unable to execute database query.") @@ -202,6 +194,10 @@ class DataFactory(object): 'session_history_metadata.grandparent_rating_key, ' \ 'MAX(session_history.started) as last_watch, ' \ 'COUNT(session_history.id) as total_plays, ' \ + 'SUM(case when session_history.stopped > 0 ' \ + 'then (session_history.stopped - session_history.started) ' \ + ' - (case when session_history.paused_counter is NULL then 0 else session_history.paused_counter end) ' \ + 'else 0 end) as total_duration, ' \ 'session_history_metadata.grandparent_thumb ' \ 'FROM session_history_metadata ' \ 'JOIN session_history ON session_history_metadata.id = session_history.id ' \ @@ -209,8 +205,8 @@ class DataFactory(object): '>= datetime("now", "-%s days", "localtime") ' \ 'AND session_history_metadata.media_type = "episode" ' \ 'GROUP BY session_history_metadata.grandparent_title ' \ - 'ORDER BY users_watched DESC, total_plays DESC ' \ - 'LIMIT %s' % (time_range, stat_count) + 'ORDER BY users_watched DESC, %s DESC ' \ + 'LIMIT %s' % (time_range, sort_type, stats_count) result = monitor_db.select(query) except: logger.warn("Unable to execute database query.") @@ -222,7 +218,7 @@ class DataFactory(object): 'rating_key': item[3], 'last_play': item[4], 'total_plays': item[5], - 'grandparent_thumb': item[6], + 'grandparent_thumb': item[7], 'thumb': '', 'user': '', 'friendly_name': '', @@ -254,7 +250,7 @@ class DataFactory(object): '>= datetime("now", "-%s days", "localtime") ' \ 'AND session_history_metadata.media_type = "movie" ' \ 'GROUP BY session_history_metadata.full_title ' \ - 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stat_count) + 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stats_count) result = monitor_db.select(query) except: logger.warn("Unable to execute database query.") @@ -290,6 +286,10 @@ class DataFactory(object): 'session_history_metadata.rating_key, ' \ 'MAX(session_history.started) as last_watch, ' \ 'COUNT(session_history.id) as total_plays, ' \ + 'SUM(case when session_history.stopped > 0 ' \ + 'then (session_history.stopped - session_history.started) ' \ + ' - (case when session_history.paused_counter is NULL then 0 else session_history.paused_counter end) ' \ + 'else 0 end) as total_duration, ' \ 'session_history_metadata.thumb ' \ 'FROM session_history_metadata ' \ 'JOIN session_history ON session_history_metadata.id = session_history.id ' \ @@ -297,8 +297,8 @@ class DataFactory(object): '>= datetime("now", "-%s days", "localtime") ' \ 'AND session_history_metadata.media_type = "movie" ' \ 'GROUP BY session_history_metadata.full_title ' \ - 'ORDER BY users_watched DESC, total_plays DESC ' \ - 'LIMIT %s' % (time_range, stat_count) + 'ORDER BY users_watched DESC, %s DESC ' \ + 'LIMIT %s' % (time_range, sort_type, stats_count) result = monitor_db.select(query) except: logger.warn("Unable to execute database query.") @@ -311,7 +311,7 @@ class DataFactory(object): 'last_play': item[4], 'total_plays': item[5], 'grandparent_thumb': '', - 'thumb': item[6], + 'thumb': item[7], 'user': '', 'friendly_name': '', 'platform_type': '', @@ -323,6 +323,98 @@ class DataFactory(object): home_stats.append({'stat_id': stat, 'rows': popular_movies}) + elif 'top_music' in stat: + top_music = [] + try: + query = 'SELECT session_history_metadata.id, ' \ + 'session_history_metadata.grandparent_title, ' \ + 'COUNT(session_history_metadata.grandparent_title) as total_plays, ' \ + 'SUM(case when session_history.stopped > 0 ' \ + 'then (session_history.stopped - session_history.started) ' \ + ' - (case when session_history.paused_counter is NULL then 0 else session_history.paused_counter end) ' \ + 'else 0 end) as total_duration, ' \ + 'session_history_metadata.grandparent_rating_key, ' \ + 'MAX(session_history.started) as last_watch,' \ + 'session_history_metadata.grandparent_thumb ' \ + 'FROM session_history_metadata ' \ + 'JOIN session_history on session_history_metadata.id = session_history.id ' \ + 'WHERE datetime(session_history.stopped, "unixepoch", "localtime") ' \ + '>= datetime("now", "-%s days", "localtime") ' \ + 'AND session_history_metadata.media_type = "track" ' \ + 'GROUP BY session_history_metadata.grandparent_title ' \ + 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stats_count) + result = monitor_db.select(query) + except: + logger.warn("Unable to execute database query.") + return None + + for item in result: + row = {'title': item[1], + 'total_plays': item[2], + 'total_duration': item[3], + 'users_watched': '', + 'rating_key': item[4], + 'last_play': item[5], + 'grandparent_thumb': item[6], + 'thumb': '', + 'user': '', + 'friendly_name': '', + 'platform_type': '', + 'platform': '', + 'row_id': item[0] + } + top_music.append(row) + + home_stats.append({'stat_id': stat, + 'stat_type': sort_type, + 'rows': top_music}) + + elif 'popular_music' in stat: + popular_music = [] + try: + query = 'SELECT session_history_metadata.id, ' \ + 'session_history_metadata.grandparent_title, ' \ + 'COUNT(DISTINCT session_history.user_id) as users_watched, ' \ + 'session_history_metadata.grandparent_rating_key, ' \ + 'MAX(session_history.started) as last_watch, ' \ + 'COUNT(session_history.id) as total_plays, ' \ + 'SUM(case when session_history.stopped > 0 ' \ + 'then (session_history.stopped - session_history.started) ' \ + ' - (case when session_history.paused_counter is NULL then 0 else session_history.paused_counter end) ' \ + 'else 0 end) as total_duration, ' \ + 'session_history_metadata.grandparent_thumb ' \ + 'FROM session_history_metadata ' \ + 'JOIN session_history ON session_history_metadata.id = session_history.id ' \ + 'WHERE datetime(session_history.stopped, "unixepoch", "localtime") ' \ + '>= datetime("now", "-%s days", "localtime") ' \ + 'AND session_history_metadata.media_type = "track" ' \ + 'GROUP BY session_history_metadata.grandparent_title ' \ + 'ORDER BY users_watched DESC, %s DESC ' \ + 'LIMIT %s' % (time_range, sort_type, stats_count) + result = monitor_db.select(query) + except: + logger.warn("Unable to execute database query.") + return None + + for item in result: + row = {'title': item[1], + 'users_watched': item[2], + 'rating_key': item[3], + 'last_play': item[4], + 'total_plays': item[5], + 'grandparent_thumb': item[7], + 'thumb': '', + 'user': '', + 'friendly_name': '', + 'platform_type': '', + 'platform': '', + 'row_id': item[0] + } + popular_music.append(row) + + home_stats.append({'stat_id': stat, + 'rows': popular_music}) + elif 'top_users' in stat: top_users = [] try: @@ -343,7 +435,7 @@ class DataFactory(object): 'WHERE datetime(session_history.stopped, "unixepoch", "localtime") >= ' \ 'datetime("now", "-%s days", "localtime") '\ 'GROUP BY session_history.user_id ' \ - 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stat_count) + 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stats_count) result = monitor_db.select(query) except: logger.warn("Unable to execute database query.") @@ -391,7 +483,7 @@ class DataFactory(object): 'WHERE datetime(session_history.stopped, "unixepoch", "localtime") ' \ '>= datetime("now", "-%s days", "localtime") ' \ 'GROUP BY session_history.platform ' \ - 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stat_count) + 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stats_count) result = monitor_db.select(query) except: logger.warn("Unable to execute database query.") @@ -447,7 +539,7 @@ class DataFactory(object): 'AND percent_complete >= %s ' \ 'GROUP BY session_history_metadata.full_title ' \ 'ORDER BY last_watch DESC ' \ - 'LIMIT %s' % (time_range, notify_watched_percent, stat_count) + 'LIMIT %s' % (time_range, notify_watched_percent, stats_count) result = monitor_db.select(query) except: logger.warn("Unable to execute database query.") diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 25b23253..0fa2e061 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1208,7 +1208,7 @@ class PmsConnect(object): 'title': helpers.get_xml_attr(xml_head[0], 'title1'), 'libraries_list': libraries_list } - + return output """ @@ -1270,11 +1270,11 @@ class PmsConnect(object): return output """ - Return processed and validated server statistics. + Return processed and validated library statistics. Output: array """ - def get_library_stats(self): + def get_library_stats(self, library_cards=''): server_libraries = self.get_server_children() server_library_stats = [] @@ -1285,7 +1285,10 @@ class PmsConnect(object): for library in libraries_list: library_type = library['type'] section_key = library['key'] - library_list = self.get_library_children(library_type, section_key) + if section_key in library_cards: + library_list = self.get_library_children(library_type, section_key) + else: + continue if library_list['library_count'] != '0': library_stats = {'title': library['title'], diff --git a/plexpy/webserve.py b/plexpy/webserve.py index de5af414..2851605d 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -66,10 +66,9 @@ class WebInterface(object): def home(self): config = { "home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH, - "home_stats_type": plexpy.CONFIG.HOME_STATS_TYPE, - "home_stats_count": plexpy.CONFIG.HOME_STATS_COUNT, - "pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER, - "notify_watched_percent": plexpy.CONFIG.NOTIFY_WATCHED_PERCENT + "home_stats_cards": plexpy.CONFIG.HOME_STATS_CARDS, + "home_library_cards": plexpy.CONFIG.HOME_LIBRARY_CARDS, + "pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER } return serve_template(templatename="index.html", title="Home", config=config) @@ -122,11 +121,19 @@ class WebInterface(object): return json.dumps(formats) @cherrypy.expose - def home_stats(self, time_range='30', stat_type='0', stat_count='5', notify_watched_percent='85', **kwargs): + def home_stats(self, **kwargs): data_factory = datafactory.DataFactory() + + time_range = plexpy.CONFIG.HOME_STATS_LENGTH + stats_type = plexpy.CONFIG.HOME_STATS_TYPE + stats_count = plexpy.CONFIG.HOME_STATS_COUNT + stats_cards = plexpy.CONFIG.HOME_STATS_CARDS.split(', ') + notify_watched_percent = plexpy.CONFIG.NOTIFY_WATCHED_PERCENT + stats_data = data_factory.get_home_stats(time_range=time_range, - stat_type=stat_type, - stat_count=stat_count, + stats_type=stats_type, + stats_count=stats_count, + stats_cards=stats_cards, notify_watched_percent=notify_watched_percent) return serve_template(templatename="home_stats.html", title="Stats", data=stats_data) @@ -134,7 +141,21 @@ class WebInterface(object): @cherrypy.expose def library_stats(self, **kwargs): pms_connect = pmsconnect.PmsConnect() - stats_data = pms_connect.get_library_stats() + + library_cards = plexpy.CONFIG.HOME_LIBRARY_CARDS.split(', ') + + if library_cards == ['library_statistics_first']: + library_cards = ['library_statistics'] + server_children = pms_connect.get_server_children() + server_libraries = server_children['libraries_list'] + + for library in server_libraries: + library_cards.append(library['key']) + + plexpy.CONFIG.HOME_LIBRARY_CARDS = ', '.join(library_cards) + plexpy.CONFIG.write() + + stats_data = pms_connect.get_library_stats(library_cards=library_cards) return serve_template(templatename="library_stats.html", title="Library Stats", data=stats_data) @@ -472,6 +493,8 @@ class WebInterface(object): "home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH, "home_stats_type": checked(plexpy.CONFIG.HOME_STATS_TYPE), "home_stats_count": plexpy.CONFIG.HOME_STATS_COUNT, + "home_stats_cards": plexpy.CONFIG.HOME_STATS_CARDS, + "home_library_cards": plexpy.CONFIG.HOME_LIBRARY_CARDS, "buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD, "buffer_wait": plexpy.CONFIG.BUFFER_WAIT } @@ -524,6 +547,14 @@ class WebInterface(object): if kwargs['pms_ip'] != plexpy.CONFIG.PMS_IP: refresh_users = True + if 'home_stats_cards' in kwargs: + if kwargs['home_stats_cards'] != 'watch_statistics': + kwargs['home_stats_cards'] = ', '.join(kwargs['home_stats_cards']) + + if 'home_library_cards' in kwargs: + if kwargs['home_library_cards'] != 'library_statistics': + kwargs['home_library_cards'] = ', '.join(kwargs['home_library_cards']) + plexpy.CONFIG.process_kwargs(kwargs) # Write the config @@ -1121,6 +1152,18 @@ class WebInterface(object): else: logger.warn('Unable to retrieve data.') + @cherrypy.expose + def get_server_children(self, **kwargs): + + pms_connect = pmsconnect.PmsConnect() + result = pms_connect.get_server_children() + + if result: + cherrypy.response.headers['Content-type'] = 'application/json' + return json.dumps(result) + else: + logger.warn('Unable to retrieve data.') + @cherrypy.expose def get_activity(self, **kwargs):