Beispiel #1
0
    def get_user_friendly_name(self, user=None, user_id=None):
        if user_id:
            monitor_db = database.MonitorDatabase()
            query = 'select username, ' \
                    '(CASE WHEN friendly_name IS NULL THEN username ELSE friendly_name END),' \
                    'do_notify, keep_history, custom_avatar_url as thumb ' \
                    'FROM users WHERE user_id = ?'
            result = monitor_db.select(query, args=[user_id])
            if result:
                user_detail = {
                    'user_id': user_id,
                    'user': result[0][0],
                    'friendly_name': result[0][1],
                    'thumb': result[0][4],
                    'do_notify': helpers.checked(result[0][2]),
                    'keep_history': helpers.checked(result[0][3])
                }
                return user_detail
            else:
                user_detail = {
                    'user_id': user_id,
                    'user': '',
                    'friendly_name': '',
                    'do_notify': '',
                    'thumb': '',
                    'keep_history': ''
                }
                return user_detail
        elif user:
            monitor_db = database.MonitorDatabase()
            query = 'select user_id, ' \
                    '(CASE WHEN friendly_name IS NULL THEN username ELSE friendly_name END),' \
                    'do_notify, keep_history, custom_avatar_url as thumb  ' \
                    'FROM users WHERE username = ?'
            result = monitor_db.select(query, args=[user])
            if result:
                user_detail = {
                    'user_id': result[0][0],
                    'user': user,
                    'friendly_name': result[0][1],
                    'thumb': result[0][4],
                    'do_notify': helpers.checked(result[0][2]),
                    'keep_history': helpers.checked(result[0][3])
                }
                return user_detail
            else:
                user_detail = {
                    'user_id': None,
                    'user': user,
                    'friendly_name': '',
                    'do_notify': '',
                    'thumb': '',
                    'keep_history': ''
                }
                return user_detail

        return None
Beispiel #2
0
    def get_user_friendly_name(self, user=None, user_id=None):
        if user_id:
            monitor_db = database.MonitorDatabase()
            query = 'select username, ' \
                    '(CASE WHEN friendly_name IS NULL THEN username ELSE friendly_name END),' \
                    'do_notify, keep_history, custom_avatar_url as thumb ' \
                    'FROM users WHERE user_id = ?'
            result = monitor_db.select(query, args=[user_id])
            if result:
                user_detail = {'user_id': user_id,
                               'user': result[0][0],
                               'friendly_name': result[0][1],
                               'thumb': result[0][4],
                               'do_notify': helpers.checked(result[0][2]),
                               'keep_history': helpers.checked(result[0][3])
                               }
                return user_detail
            else:
                user_detail = {'user_id': user_id,
                               'user': '',
                               'friendly_name': '',
                               'do_notify': '',
                               'thumb': '',
                               'keep_history': ''}
                return user_detail
        elif user:
            monitor_db = database.MonitorDatabase()
            query = 'select user_id, ' \
                    '(CASE WHEN friendly_name IS NULL THEN username ELSE friendly_name END),' \
                    'do_notify, keep_history, custom_avatar_url as thumb  ' \
                    'FROM users WHERE username = ?'
            result = monitor_db.select(query, args=[user])
            if result:
                user_detail = {'user_id': result[0][0],
                               'user': user,
                               'friendly_name': result[0][1],
                               'thumb': result[0][4],
                               'do_notify': helpers.checked(result[0][2]),
                               'keep_history': helpers.checked(result[0][3])}
                return user_detail
            else:
                user_detail = {'user_id': None,
                               'user': user,
                               'friendly_name': '',
                               'do_notify': '',
                               'thumb': '',
                               'keep_history': ''}
                return user_detail

        return None
Beispiel #3
0
    def get_notification_agent_config(self, config_id, **kwargs):
        config = notifiers.get_notification_agent_config(config_id=config_id)

        checkboxes = {'email_tls': checked(plexpy.CONFIG.EMAIL_TLS)}

        return serve_template(templatename="notification_config.html", title="Notification Configuration",
                              data=config, checkboxes=checkboxes)
Beispiel #4
0
    def return_config_options(self):
        config_option = [{'label': 'From',
                          'value': plexpy.CONFIG.EMAIL_FROM,
                          'name': 'email_from',
                          'description': 'Who should the sender be.',
                          'input_type': 'text'
                          },
                         {'label': 'To',
                          'value': plexpy.CONFIG.EMAIL_TO,
                          'name': 'email_to',
                          'description': 'Who should the recipeint be.',
                          'input_type': 'text'
                          },
                         {'label': 'SMTP Server',
                          'value': plexpy.CONFIG.EMAIL_SMTP_SERVER,
                          'name': 'email_smtp_server',
                          'description': 'Host for the SMTP server.',
                          'input_type': 'text'
                          },
                         {'label': 'SMTP Port',
                          'value': plexpy.CONFIG.EMAIL_SMTP_PORT,
                          'name': 'email_smtp_port',
                          'description': 'Port for the SMTP server.',
                          'input_type': 'number'
                          },
                         {'label': 'SMTP User',
                          'value': plexpy.CONFIG.EMAIL_SMTP_USER,
                          'name': 'email_smtp_user',
                          'description': 'User for the SMTP server.',
                          'input_type': 'text'
                          },
                         {'label': 'SMTP Password',
                          'value': plexpy.CONFIG.EMAIL_SMTP_PASSWORD,
                          'name': 'email_smtp_password',
                          'description': 'Password for the SMTP server.',
                          'input_type': 'password'
                          },
                         {'label': 'TLS',
                          'value': checked(plexpy.CONFIG.EMAIL_TLS),
                          'name': 'email_tls',
                          'description': 'Does the server use encryption.',
                          'input_type': 'checkbox'
                          }
                         ]

        return config_option
Beispiel #5
0
    def return_config_options(self):
        config_option = [{
            'label': 'From',
            'value': plexpy.CONFIG.EMAIL_FROM,
            'name': 'email_from',
            'description': 'Who should the sender be.',
            'input_type': 'text'
        }, {
            'label': 'To',
            'value': plexpy.CONFIG.EMAIL_TO,
            'name': 'email_to',
            'description': 'Who should the recipeint be.',
            'input_type': 'text'
        }, {
            'label': 'SMTP Server',
            'value': plexpy.CONFIG.EMAIL_SMTP_SERVER,
            'name': 'email_smtp_server',
            'description': 'Host for the SMTP server.',
            'input_type': 'text'
        }, {
            'label': 'SMTP Port',
            'value': plexpy.CONFIG.EMAIL_SMTP_PORT,
            'name': 'email_smtp_port',
            'description': 'Port for the SMTP server.',
            'input_type': 'number'
        }, {
            'label': 'SMTP User',
            'value': plexpy.CONFIG.EMAIL_SMTP_USER,
            'name': 'email_smtp_user',
            'description': 'User for the SMTP server.',
            'input_type': 'text'
        }, {
            'label': 'SMTP Password',
            'value': plexpy.CONFIG.EMAIL_SMTP_PASSWORD,
            'name': 'email_smtp_password',
            'description': 'Password for the SMTP server.',
            'input_type': 'password'
        }, {
            'label': 'TLS',
            'value': checked(plexpy.CONFIG.EMAIL_TLS),
            'name': 'email_tls',
            'description': 'Does the server use encryption.',
            'input_type': 'checkbox'
        }]

        return config_option
Beispiel #6
0
    def get_user_list(self, kwargs=None):
        data_tables = datatables.DataTables()

        columns = [
            'session_history.id', 'users.user_id as user_id',
            'users.custom_avatar_url as user_thumb',
            '(case when users.friendly_name is null then users.username else \
                    users.friendly_name end) as friendly_name',
            'MAX(session_history.started) as last_seen',
            'session_history.ip_address as ip_address',
            'COUNT(session_history.id) as plays',
            'session_history.platform as platform',
            'session_history.player as player',
            'session_history_metadata.full_title as last_watched',
            'session_history_metadata.thumb',
            'session_history_metadata.parent_thumb',
            'session_history_metadata.grandparent_thumb',
            'session_history_metadata.media_type',
            'session_history.rating_key as rating_key',
            'session_history_media_info.video_decision',
            'users.username as user', 'users.do_notify as do_notify',
            'users.keep_history as keep_history'
        ]
        try:
            query = data_tables.ssp_query(
                table_name='users',
                columns=columns,
                custom_where=[],
                group_by=['users.user_id'],
                join_types=[
                    'LEFT OUTER JOIN', 'LEFT OUTER JOIN', 'LEFT OUTER JOIN'
                ],
                join_tables=[
                    'session_history', 'session_history_metadata',
                    'session_history_media_info'
                ],
                join_evals=[
                    ['session_history.user_id', 'users.user_id'],
                    ['session_history.id', 'session_history_metadata.id'],
                    ['session_history.id', 'session_history_media_info.id']
                ],
                kwargs=kwargs)
        except:
            logger.warn("Unable to execute database query.")
            return {
                'recordsFiltered': 0,
                'recordsTotal': 0,
                'draw': 0,
                'data': 'null',
                'error': 'Unable to execute database query.'
            }

        users = query['result']

        rows = []
        for item in users:
            if item["media_type"] == 'episode' and item["parent_thumb"]:
                thumb = item["parent_thumb"]
            elif item["media_type"] == 'episode':
                thumb = item["grandparent_thumb"]
            else:
                thumb = item["thumb"]

            if not item['user_thumb'] or item['user_thumb'] == '':
                user_thumb = common.DEFAULT_USER_THUMB
            else:
                user_thumb = item['user_thumb']

            # Rename Mystery platform names
            platform_names = {
                'Mystery 3': 'Playstation 3',
                'Mystery 4': 'Playstation 4',
                'Mystery 5': 'Xbox 360'
            }
            platform = platform_names.get(item["platform"], item["platform"])

            row = {
                "id": item['id'],
                "plays": item['plays'],
                "last_seen": item['last_seen'],
                "friendly_name": item['friendly_name'],
                "ip_address": item['ip_address'],
                "platform": platform,
                "player": item['player'],
                "last_watched": item['last_watched'],
                "thumb": thumb,
                "media_type": item['media_type'],
                "rating_key": item['rating_key'],
                "video_decision": item['video_decision'],
                "user_thumb": user_thumb,
                "user": item["user"],
                "user_id": item['user_id'],
                "do_notify": helpers.checked(item['do_notify']),
                "keep_history": helpers.checked(item['keep_history'])
            }

            rows.append(row)

        dict = {
            'recordsFiltered': query['filteredCount'],
            'recordsTotal': query['totalCount'],
            'data': rows,
            'draw': query['draw']
        }

        return dict
Beispiel #7
0
    def config(self):
        interface_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/')
        interface_list = [
            name for name in os.listdir(interface_dir)
            if os.path.isdir(os.path.join(interface_dir, name))
        ]

        # Initialise blank passwords so we do not expose them in the html forms
        # but users are still able to clear them
        if plexpy.CONFIG.HTTP_PASSWORD != '':
            http_password = '******'
        else:
            http_password = ''

        config = {
            "http_host":
            plexpy.CONFIG.HTTP_HOST,
            "http_username":
            plexpy.CONFIG.HTTP_USERNAME,
            "http_port":
            plexpy.CONFIG.HTTP_PORT,
            "http_password":
            http_password,
            "launch_browser":
            checked(plexpy.CONFIG.LAUNCH_BROWSER),
            "enable_https":
            checked(plexpy.CONFIG.ENABLE_HTTPS),
            "https_cert":
            plexpy.CONFIG.HTTPS_CERT,
            "https_key":
            plexpy.CONFIG.HTTPS_KEY,
            "api_enabled":
            checked(plexpy.CONFIG.API_ENABLED),
            "api_key":
            plexpy.CONFIG.API_KEY,
            "update_db_interval":
            plexpy.CONFIG.UPDATE_DB_INTERVAL,
            "freeze_db":
            checked(plexpy.CONFIG.FREEZE_DB),
            "log_dir":
            plexpy.CONFIG.LOG_DIR,
            "cache_dir":
            plexpy.CONFIG.CACHE_DIR,
            "interface_list":
            interface_list,
            "growl_enabled":
            checked(plexpy.CONFIG.GROWL_ENABLED),
            "growl_host":
            plexpy.CONFIG.GROWL_HOST,
            "growl_password":
            plexpy.CONFIG.GROWL_PASSWORD,
            "prowl_enabled":
            checked(plexpy.CONFIG.PROWL_ENABLED),
            "prowl_keys":
            plexpy.CONFIG.PROWL_KEYS,
            "prowl_priority":
            plexpy.CONFIG.PROWL_PRIORITY,
            "xbmc_enabled":
            checked(plexpy.CONFIG.XBMC_ENABLED),
            "xbmc_host":
            plexpy.CONFIG.XBMC_HOST,
            "xbmc_username":
            plexpy.CONFIG.XBMC_USERNAME,
            "xbmc_password":
            plexpy.CONFIG.XBMC_PASSWORD,
            "plex_enabled":
            checked(plexpy.CONFIG.PLEX_ENABLED),
            "plex_client_host":
            plexpy.CONFIG.PLEX_CLIENT_HOST,
            "plex_username":
            plexpy.CONFIG.PLEX_USERNAME,
            "plex_password":
            plexpy.CONFIG.PLEX_PASSWORD,
            "nma_enabled":
            checked(plexpy.CONFIG.NMA_ENABLED),
            "nma_apikey":
            plexpy.CONFIG.NMA_APIKEY,
            "nma_priority":
            int(plexpy.CONFIG.NMA_PRIORITY),
            "pushalot_enabled":
            checked(plexpy.CONFIG.PUSHALOT_ENABLED),
            "pushalot_apikey":
            plexpy.CONFIG.PUSHALOT_APIKEY,
            "pushover_enabled":
            checked(plexpy.CONFIG.PUSHOVER_ENABLED),
            "pushover_keys":
            plexpy.CONFIG.PUSHOVER_KEYS,
            "pushover_apitoken":
            plexpy.CONFIG.PUSHOVER_APITOKEN,
            "pushover_priority":
            plexpy.CONFIG.PUSHOVER_PRIORITY,
            "pushbullet_enabled":
            checked(plexpy.CONFIG.PUSHBULLET_ENABLED),
            "pushbullet_apikey":
            plexpy.CONFIG.PUSHBULLET_APIKEY,
            "pushbullet_deviceid":
            plexpy.CONFIG.PUSHBULLET_DEVICEID,
            "twitter_enabled":
            checked(plexpy.CONFIG.TWITTER_ENABLED),
            "osx_notify_enabled":
            checked(plexpy.CONFIG.OSX_NOTIFY_ENABLED),
            "osx_notify_app":
            plexpy.CONFIG.OSX_NOTIFY_APP,
            "boxcar_enabled":
            checked(plexpy.CONFIG.BOXCAR_ENABLED),
            "boxcar_token":
            plexpy.CONFIG.BOXCAR_TOKEN,
            "cache_sizemb":
            plexpy.CONFIG.CACHE_SIZEMB,
            "email_enabled":
            checked(plexpy.CONFIG.EMAIL_ENABLED),
            "email_from":
            plexpy.CONFIG.EMAIL_FROM,
            "email_to":
            plexpy.CONFIG.EMAIL_TO,
            "email_smtp_server":
            plexpy.CONFIG.EMAIL_SMTP_SERVER,
            "email_smtp_user":
            plexpy.CONFIG.EMAIL_SMTP_USER,
            "email_smtp_password":
            plexpy.CONFIG.EMAIL_SMTP_PASSWORD,
            "email_smtp_port":
            int(plexpy.CONFIG.EMAIL_SMTP_PORT),
            "email_tls":
            checked(plexpy.CONFIG.EMAIL_TLS),
            "pms_ip":
            plexpy.CONFIG.PMS_IP,
            "pms_logs_folder":
            plexpy.CONFIG.PMS_LOGS_FOLDER,
            "pms_port":
            plexpy.CONFIG.PMS_PORT,
            "pms_token":
            plexpy.CONFIG.PMS_TOKEN,
            "pms_use_bif":
            checked(plexpy.CONFIG.PMS_USE_BIF),
            "pms_uuid":
            plexpy.CONFIG.PMS_UUID,
            "plexwatch_database":
            plexpy.CONFIG.PLEXWATCH_DATABASE,
            "date_format":
            plexpy.CONFIG.DATE_FORMAT,
            "time_format":
            plexpy.CONFIG.TIME_FORMAT,
            "grouping_global_history":
            checked(plexpy.CONFIG.GROUPING_GLOBAL_HISTORY),
            "grouping_user_history":
            checked(plexpy.CONFIG.GROUPING_USER_HISTORY),
            "grouping_charts":
            checked(plexpy.CONFIG.GROUPING_CHARTS)
        }

        return serve_template(templatename="config.html",
                              title="Settings",
                              config=config)
Beispiel #8
0
    def welcome(self, **kwargs):
        config = {
            "launch_browser": checked(plexpy.CONFIG.LAUNCH_BROWSER),
            "refresh_users_on_startup": checked(plexpy.CONFIG.REFRESH_USERS_ON_STARTUP),
            "pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER,
            "pms_ip": plexpy.CONFIG.PMS_IP,
            "pms_is_remote": checked(plexpy.CONFIG.PMS_IS_REMOTE),
            "pms_port": plexpy.CONFIG.PMS_PORT,
            "pms_token": plexpy.CONFIG.PMS_TOKEN,
            "pms_ssl": checked(plexpy.CONFIG.PMS_SSL),
            "pms_uuid": plexpy.CONFIG.PMS_UUID,
            "tv_notify_enable": checked(plexpy.CONFIG.TV_NOTIFY_ENABLE),
            "movie_notify_enable": checked(plexpy.CONFIG.MOVIE_NOTIFY_ENABLE),
            "music_notify_enable": checked(plexpy.CONFIG.MUSIC_NOTIFY_ENABLE),
            "tv_notify_on_start": checked(plexpy.CONFIG.TV_NOTIFY_ON_START),
            "movie_notify_on_start": checked(plexpy.CONFIG.MOVIE_NOTIFY_ON_START),
            "music_notify_on_start": checked(plexpy.CONFIG.MUSIC_NOTIFY_ON_START),
            "video_logging_enable": checked(plexpy.CONFIG.VIDEO_LOGGING_ENABLE),
            "music_logging_enable": checked(plexpy.CONFIG.MUSIC_LOGGING_ENABLE),
            "logging_ignore_interval": plexpy.CONFIG.LOGGING_IGNORE_INTERVAL,
            "check_github": checked(plexpy.CONFIG.CHECK_GITHUB),
        }

        # The setup wizard just refreshes the page on submit so we must redirect to home if config set.
        # Also redirecting to home if a PMS token already exists - will remove this in future.
        if plexpy.CONFIG.FIRST_RUN_COMPLETE or plexpy.CONFIG.PMS_TOKEN:
            raise cherrypy.HTTPRedirect("home")
        else:
            return serve_template(templatename="welcome.html", title="Welcome", config=config)
Beispiel #9
0
    def settings(self):
        interface_dir = os.path.join(plexpy.PROG_DIR, "data/interfaces/")
        interface_list = [
            name for name in os.listdir(interface_dir) if os.path.isdir(os.path.join(interface_dir, name))
        ]

        # Initialise blank passwords so we do not expose them in the html forms
        # but users are still able to clear them
        if plexpy.CONFIG.HTTP_PASSWORD != "":
            http_password = "******"
        else:
            http_password = ""

        config = {
            "http_host": plexpy.CONFIG.HTTP_HOST,
            "http_username": plexpy.CONFIG.HTTP_USERNAME,
            "http_port": plexpy.CONFIG.HTTP_PORT,
            "http_password": http_password,
            "launch_browser": checked(plexpy.CONFIG.LAUNCH_BROWSER),
            "enable_https": checked(plexpy.CONFIG.ENABLE_HTTPS),
            "https_cert": plexpy.CONFIG.HTTPS_CERT,
            "https_key": plexpy.CONFIG.HTTPS_KEY,
            "api_enabled": checked(plexpy.CONFIG.API_ENABLED),
            "api_key": plexpy.CONFIG.API_KEY,
            "update_db_interval": plexpy.CONFIG.UPDATE_DB_INTERVAL,
            "freeze_db": checked(plexpy.CONFIG.FREEZE_DB),
            "log_dir": plexpy.CONFIG.LOG_DIR,
            "cache_dir": plexpy.CONFIG.CACHE_DIR,
            "check_github": checked(plexpy.CONFIG.CHECK_GITHUB),
            "interface_list": interface_list,
            "growl_enabled": checked(plexpy.CONFIG.GROWL_ENABLED),
            "growl_host": plexpy.CONFIG.GROWL_HOST,
            "growl_password": plexpy.CONFIG.GROWL_PASSWORD,
            "prowl_enabled": checked(plexpy.CONFIG.PROWL_ENABLED),
            "prowl_keys": plexpy.CONFIG.PROWL_KEYS,
            "prowl_priority": plexpy.CONFIG.PROWL_PRIORITY,
            "xbmc_enabled": checked(plexpy.CONFIG.XBMC_ENABLED),
            "xbmc_host": plexpy.CONFIG.XBMC_HOST,
            "xbmc_username": plexpy.CONFIG.XBMC_USERNAME,
            "xbmc_password": plexpy.CONFIG.XBMC_PASSWORD,
            "plex_enabled": checked(plexpy.CONFIG.PLEX_ENABLED),
            "plex_client_host": plexpy.CONFIG.PLEX_CLIENT_HOST,
            "plex_username": plexpy.CONFIG.PLEX_USERNAME,
            "plex_password": plexpy.CONFIG.PLEX_PASSWORD,
            "nma_enabled": checked(plexpy.CONFIG.NMA_ENABLED),
            "nma_apikey": plexpy.CONFIG.NMA_APIKEY,
            "nma_priority": int(plexpy.CONFIG.NMA_PRIORITY),
            "pushalot_enabled": checked(plexpy.CONFIG.PUSHALOT_ENABLED),
            "pushalot_apikey": plexpy.CONFIG.PUSHALOT_APIKEY,
            "pushover_enabled": checked(plexpy.CONFIG.PUSHOVER_ENABLED),
            "pushover_keys": plexpy.CONFIG.PUSHOVER_KEYS,
            "pushover_apitoken": plexpy.CONFIG.PUSHOVER_APITOKEN,
            "pushover_priority": plexpy.CONFIG.PUSHOVER_PRIORITY,
            "pushbullet_enabled": checked(plexpy.CONFIG.PUSHBULLET_ENABLED),
            "pushbullet_apikey": plexpy.CONFIG.PUSHBULLET_APIKEY,
            "pushbullet_deviceid": plexpy.CONFIG.PUSHBULLET_DEVICEID,
            "twitter_enabled": checked(plexpy.CONFIG.TWITTER_ENABLED),
            "osx_notify_enabled": checked(plexpy.CONFIG.OSX_NOTIFY_ENABLED),
            "osx_notify_app": plexpy.CONFIG.OSX_NOTIFY_APP,
            "boxcar_enabled": checked(plexpy.CONFIG.BOXCAR_ENABLED),
            "boxcar_token": plexpy.CONFIG.BOXCAR_TOKEN,
            "cache_sizemb": plexpy.CONFIG.CACHE_SIZEMB,
            "email_enabled": checked(plexpy.CONFIG.EMAIL_ENABLED),
            "email_from": plexpy.CONFIG.EMAIL_FROM,
            "email_to": plexpy.CONFIG.EMAIL_TO,
            "email_smtp_server": plexpy.CONFIG.EMAIL_SMTP_SERVER,
            "email_smtp_user": plexpy.CONFIG.EMAIL_SMTP_USER,
            "email_smtp_password": plexpy.CONFIG.EMAIL_SMTP_PASSWORD,
            "email_smtp_port": int(plexpy.CONFIG.EMAIL_SMTP_PORT),
            "email_tls": checked(plexpy.CONFIG.EMAIL_TLS),
            "pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER,
            "pms_ip": plexpy.CONFIG.PMS_IP,
            "pms_logs_folder": plexpy.CONFIG.PMS_LOGS_FOLDER,
            "pms_port": plexpy.CONFIG.PMS_PORT,
            "pms_token": plexpy.CONFIG.PMS_TOKEN,
            "pms_ssl": checked(plexpy.CONFIG.PMS_SSL),
            "pms_use_bif": checked(plexpy.CONFIG.PMS_USE_BIF),
            "pms_uuid": plexpy.CONFIG.PMS_UUID,
            "plexwatch_database": plexpy.CONFIG.PLEXWATCH_DATABASE,
            "date_format": plexpy.CONFIG.DATE_FORMAT,
            "time_format": plexpy.CONFIG.TIME_FORMAT,
            "grouping_global_history": checked(plexpy.CONFIG.GROUPING_GLOBAL_HISTORY),
            "grouping_user_history": checked(plexpy.CONFIG.GROUPING_USER_HISTORY),
            "grouping_charts": checked(plexpy.CONFIG.GROUPING_CHARTS),
            "tv_notify_enable": checked(plexpy.CONFIG.TV_NOTIFY_ENABLE),
            "movie_notify_enable": checked(plexpy.CONFIG.MOVIE_NOTIFY_ENABLE),
            "music_notify_enable": checked(plexpy.CONFIG.MUSIC_NOTIFY_ENABLE),
            "tv_notify_on_start": checked(plexpy.CONFIG.TV_NOTIFY_ON_START),
            "movie_notify_on_start": checked(plexpy.CONFIG.MOVIE_NOTIFY_ON_START),
            "music_notify_on_start": checked(plexpy.CONFIG.MUSIC_NOTIFY_ON_START),
            "tv_notify_on_stop": checked(plexpy.CONFIG.TV_NOTIFY_ON_STOP),
            "movie_notify_on_stop": checked(plexpy.CONFIG.MOVIE_NOTIFY_ON_STOP),
            "music_notify_on_stop": checked(plexpy.CONFIG.MUSIC_NOTIFY_ON_STOP),
            "tv_notify_on_pause": checked(plexpy.CONFIG.TV_NOTIFY_ON_PAUSE),
            "movie_notify_on_pause": checked(plexpy.CONFIG.MOVIE_NOTIFY_ON_PAUSE),
            "music_notify_on_pause": checked(plexpy.CONFIG.MUSIC_NOTIFY_ON_PAUSE),
            "monitoring_interval": plexpy.CONFIG.MONITORING_INTERVAL,
            "refresh_users_interval": plexpy.CONFIG.REFRESH_USERS_INTERVAL,
            "refresh_users_on_startup": checked(plexpy.CONFIG.REFRESH_USERS_ON_STARTUP),
            "ip_logging_enable": checked(plexpy.CONFIG.IP_LOGGING_ENABLE),
            "video_logging_enable": checked(plexpy.CONFIG.VIDEO_LOGGING_ENABLE),
            "music_logging_enable": checked(plexpy.CONFIG.MUSIC_LOGGING_ENABLE),
            "logging_ignore_interval": plexpy.CONFIG.LOGGING_IGNORE_INTERVAL,
            "pms_is_remote": checked(plexpy.CONFIG.PMS_IS_REMOTE),
            "notify_watched_percent": plexpy.CONFIG.NOTIFY_WATCHED_PERCENT,
            "notify_on_start_subject_text": plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT,
            "notify_on_start_body_text": plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT,
            "notify_on_stop_subject_text": plexpy.CONFIG.NOTIFY_ON_STOP_SUBJECT_TEXT,
            "notify_on_stop_body_text": plexpy.CONFIG.NOTIFY_ON_STOP_BODY_TEXT,
            "notify_on_watched_subject_text": plexpy.CONFIG.NOTIFY_ON_WATCHED_SUBJECT_TEXT,
            "notify_on_watched_body_text": plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT,
        }

        return serve_template(templatename="settings.html", title="Settings", config=config)
Beispiel #10
0
    def config(self):
        interface_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/')
        interface_list = [name for name in os.listdir(interface_dir) if
                          os.path.isdir(os.path.join(interface_dir, name))]

        # Initialise blank passwords so we do not expose them in the html forms
        # but users are still able to clear them
        if plexpy.CONFIG.HTTP_PASSWORD != '':
            http_password = '******'
        else:
            http_password = ''
        if plexpy.CONFIG.PMS_PASSWORD != '':
            pms_password = '******'
        else:
            pms_password = ''

        config = {
            "http_host": plexpy.CONFIG.HTTP_HOST,
            "http_username": plexpy.CONFIG.HTTP_USERNAME,
            "http_port": plexpy.CONFIG.HTTP_PORT,
            "http_password": http_password,
            "launch_browser": checked(plexpy.CONFIG.LAUNCH_BROWSER),
            "enable_https": checked(plexpy.CONFIG.ENABLE_HTTPS),
            "https_cert": plexpy.CONFIG.HTTPS_CERT,
            "https_key": plexpy.CONFIG.HTTPS_KEY,
            "api_enabled": checked(plexpy.CONFIG.API_ENABLED),
            "api_key": plexpy.CONFIG.API_KEY,
            "update_db_interval": plexpy.CONFIG.UPDATE_DB_INTERVAL,
            "freeze_db": checked(plexpy.CONFIG.FREEZE_DB),
            "log_dir": plexpy.CONFIG.LOG_DIR,
            "cache_dir": plexpy.CONFIG.CACHE_DIR,
            "interface_list": interface_list,
            "growl_enabled": checked(plexpy.CONFIG.GROWL_ENABLED),
            "growl_host": plexpy.CONFIG.GROWL_HOST,
            "growl_password": plexpy.CONFIG.GROWL_PASSWORD,
            "prowl_enabled": checked(plexpy.CONFIG.PROWL_ENABLED),
            "prowl_keys": plexpy.CONFIG.PROWL_KEYS,
            "prowl_priority": plexpy.CONFIG.PROWL_PRIORITY,
            "xbmc_enabled": checked(plexpy.CONFIG.XBMC_ENABLED),
            "xbmc_host": plexpy.CONFIG.XBMC_HOST,
            "xbmc_username": plexpy.CONFIG.XBMC_USERNAME,
            "xbmc_password": plexpy.CONFIG.XBMC_PASSWORD,
            "lms_enabled": checked(plexpy.CONFIG.LMS_ENABLED),
            "lms_host": plexpy.CONFIG.LMS_HOST,
            "plex_enabled": checked(plexpy.CONFIG.PLEX_ENABLED),
            "plex_client_host": plexpy.CONFIG.PLEX_CLIENT_HOST,
            "plex_username": plexpy.CONFIG.PLEX_USERNAME,
            "plex_password": plexpy.CONFIG.PLEX_PASSWORD,
            "nma_enabled": checked(plexpy.CONFIG.NMA_ENABLED),
            "nma_apikey": plexpy.CONFIG.NMA_APIKEY,
            "nma_priority": int(plexpy.CONFIG.NMA_PRIORITY),
            "pushalot_enabled": checked(plexpy.CONFIG.PUSHALOT_ENABLED),
            "pushalot_apikey": plexpy.CONFIG.PUSHALOT_APIKEY,
            "synoindex_enabled": checked(plexpy.CONFIG.SYNOINDEX_ENABLED),
            "pushover_enabled": checked(plexpy.CONFIG.PUSHOVER_ENABLED),
            "pushover_keys": plexpy.CONFIG.PUSHOVER_KEYS,
            "pushover_apitoken": plexpy.CONFIG.PUSHOVER_APITOKEN,
            "pushover_priority": plexpy.CONFIG.PUSHOVER_PRIORITY,
            "pushbullet_enabled": checked(plexpy.CONFIG.PUSHBULLET_ENABLED),
            "pushbullet_apikey": plexpy.CONFIG.PUSHBULLET_APIKEY,
            "pushbullet_deviceid": plexpy.CONFIG.PUSHBULLET_DEVICEID,
            "subsonic_enabled": checked(plexpy.CONFIG.SUBSONIC_ENABLED),
            "subsonic_host": plexpy.CONFIG.SUBSONIC_HOST,
            "subsonic_username": plexpy.CONFIG.SUBSONIC_USERNAME,
            "subsonic_password": plexpy.CONFIG.SUBSONIC_PASSWORD,
            "twitter_enabled": checked(plexpy.CONFIG.TWITTER_ENABLED),
            "osx_notify_enabled": checked(plexpy.CONFIG.OSX_NOTIFY_ENABLED),
            "osx_notify_app": plexpy.CONFIG.OSX_NOTIFY_APP,
            "boxcar_enabled": checked(plexpy.CONFIG.BOXCAR_ENABLED),
            "boxcar_token": plexpy.CONFIG.BOXCAR_TOKEN,
            "cache_sizemb": plexpy.CONFIG.CACHE_SIZEMB,
            "mpc_enabled": checked(plexpy.CONFIG.MPC_ENABLED),
            "email_enabled": checked(plexpy.CONFIG.EMAIL_ENABLED),
            "email_from": plexpy.CONFIG.EMAIL_FROM,
            "email_to": plexpy.CONFIG.EMAIL_TO,
            "email_smtp_server": plexpy.CONFIG.EMAIL_SMTP_SERVER,
            "email_smtp_user": plexpy.CONFIG.EMAIL_SMTP_USER,
            "email_smtp_password": plexpy.CONFIG.EMAIL_SMTP_PASSWORD,
            "email_smtp_port": int(plexpy.CONFIG.EMAIL_SMTP_PORT),
            "email_tls": checked(plexpy.CONFIG.EMAIL_TLS),
            "pms_ip": plexpy.CONFIG.PMS_IP,
            "pms_port": plexpy.CONFIG.PMS_PORT,
            "pms_username": plexpy.CONFIG.PMS_USERNAME,
            "pms_password": pms_password,
            "plexwatch_database": plexpy.CONFIG.PLEXWATCH_DATABASE,
            "date_format": plexpy.CONFIG.DATE_FORMAT,
            "time_format": plexpy.CONFIG.TIME_FORMAT,
            "grouping_global_history": checked(plexpy.CONFIG.GROUPING_GLOBAL_HISTORY),
            "grouping_user_history": checked(plexpy.CONFIG.GROUPING_USER_HISTORY),
            "grouping_charts": checked(plexpy.CONFIG.GROUPING_CHARTS)
        }

        return serve_template(templatename="config.html", title="Settings", config=config)
Beispiel #11
0
def available_notification_agents():
    agents = [{'name': 'Growl',
               'id': AGENT_IDS['Growl'],
               'config_prefix': 'growl',
               'has_config': True,
               'state': checked(plexpy.CONFIG.GROWL_ENABLED),
               'on_play': plexpy.CONFIG.GROWL_ON_PLAY,
               'on_stop': plexpy.CONFIG.GROWL_ON_STOP,
               'on_watched': plexpy.CONFIG.GROWL_ON_WATCHED
               },
              {'name': 'Prowl',
               'id': AGENT_IDS['Prowl'],
               'config_prefix': 'prowl',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PROWL_ENABLED),
               'on_play': plexpy.CONFIG.PROWL_ON_PLAY,
               'on_stop': plexpy.CONFIG.PROWL_ON_STOP,
               'on_watched': plexpy.CONFIG.PROWL_ON_WATCHED
               },
              {'name': 'XBMC',
               'id': AGENT_IDS['XBMC'],
               'config_prefix': 'xbmc',
               'has_config': True,
               'state': checked(plexpy.CONFIG.XBMC_ENABLED),
               'on_play': plexpy.CONFIG.XBMC_ON_PLAY,
               'on_stop': plexpy.CONFIG.XBMC_ON_STOP,
               'on_watched': plexpy.CONFIG.XBMC_ON_WATCHED
               },
              {'name': 'Plex',
               'id': AGENT_IDS['Plex'],
               'config_prefix': 'plex',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PLEX_ENABLED),
               'on_play': plexpy.CONFIG.PLEX_ON_PLAY,
               'on_stop': plexpy.CONFIG.PLEX_ON_STOP,
               'on_watched': plexpy.CONFIG.PLEX_ON_WATCHED
               },
              {'name': 'NotifyMyAndroid',
               'id': AGENT_IDS['NMA'],
               'config_prefix': 'nma',
               'has_config': True,
               'state': checked(plexpy.CONFIG.NMA_ENABLED),
               'on_play': plexpy.CONFIG.NMA_ON_PLAY,
               'on_stop': plexpy.CONFIG.NMA_ON_STOP,
               'on_watched': plexpy.CONFIG.NMA_ON_WATCHED
               },
              {'name': 'Pushalot',
               'id': AGENT_IDS['Pushalot'],
               'config_prefix': 'pushalot',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PUSHALOT_ENABLED),
               'on_play': plexpy.CONFIG.PUSHALOT_ON_PLAY,
               'on_stop': plexpy.CONFIG.PUSHALOT_ON_STOP,
               'on_watched': plexpy.CONFIG.PUSHALOT_ON_WATCHED
               },
              {'name': 'Pushbullet',
               'id': AGENT_IDS['Pushbullet'],
               'config_prefix': 'pushbullet',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PUSHBULLET_ENABLED),
               'on_play': plexpy.CONFIG.PUSHBULLET_ON_PLAY,
               'on_stop': plexpy.CONFIG.PUSHBULLET_ON_STOP,
               'on_watched': plexpy.CONFIG.PUSHBULLET_ON_WATCHED
               },
              {'name': 'Pushover',
               'id': AGENT_IDS['Pushover'],
               'config_prefix': 'pushover',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PUSHOVER_ENABLED),
               'on_play': plexpy.CONFIG.PUSHOVER_ON_PLAY,
               'on_stop': plexpy.CONFIG.PUSHOVER_ON_STOP,
               'on_watched': plexpy.CONFIG.PUSHOVER_ON_WATCHED
               },
              {'name': 'OSX Notify',
               'id': AGENT_IDS['OSX Notify'],
               'config_prefix': 'osx_notify',
               'has_config': True,
               'state': checked(plexpy.CONFIG.OSX_NOTIFY_ENABLED),
               'on_play': plexpy.CONFIG.OSX_NOTIFY_ON_PLAY,
               'on_stop': plexpy.CONFIG.OSX_NOTIFY_ON_STOP,
               'on_watched': plexpy.CONFIG.OSX_NOTIFY_ON_WATCHED
               },
              {'name': 'Boxcar2',
               'id': AGENT_IDS['Boxcar2'],
               'config_prefix': 'boxcar',
               'has_config': True,
               'state': checked(plexpy.CONFIG.BOXCAR_ENABLED),
               'on_play': plexpy.CONFIG.BOXCAR_ON_PLAY,
               'on_stop': plexpy.CONFIG.BOXCAR_ON_STOP,
               'on_watched': plexpy.CONFIG.BOXCAR_ON_WATCHED
               },
              {'name': 'E-mail',
               'id': AGENT_IDS['Email'],
               'config_prefix': 'email',
               'has_config': True,
               'state': checked(plexpy.CONFIG.EMAIL_ENABLED),
               'on_play': plexpy.CONFIG.EMAIL_ON_PLAY,
               'on_stop': plexpy.CONFIG.EMAIL_ON_STOP,
               'on_watched': plexpy.CONFIG.EMAIL_ON_WATCHED
               }
              ]

    return agents
Beispiel #12
0
    def get_datatables_list(self, kwargs=None):
        data_tables = datatables.DataTables()

        custom_where = ['users.deleted_user', 0]

        columns = ['users.user_id',
                   '(CASE WHEN users.friendly_name IS NULL OR TRIM(users.friendly_name) = "" \
                    THEN users.username ELSE users.friendly_name END) AS friendly_name',
                   'users.thumb AS user_thumb',
                   'users.custom_avatar_url AS custom_thumb',
                   'COUNT(session_history.id) AS plays',
                   'SUM(CASE WHEN session_history.stopped > 0 THEN (session_history.stopped - session_history.started) \
                    ELSE 0 END) - SUM(CASE WHEN session_history.paused_counter IS NULL THEN 0 ELSE \
                    session_history.paused_counter END) AS duration',
                   'MAX(session_history.started) AS last_seen',
                   'MAX(session_history.id) AS id',
                   'session_history_metadata.full_title AS last_played',
                   'session_history.ip_address',
                   'session_history.platform',
                   'session_history.player',
                   'session_history.rating_key',
                   'session_history_metadata.media_type',
                   'session_history_metadata.thumb',
                   'session_history_metadata.parent_thumb',
                   'session_history_metadata.grandparent_thumb',
                   'session_history_metadata.parent_title',
                   'session_history_metadata.year',
                   'session_history_metadata.media_index',
                   'session_history_metadata.parent_media_index',
                   'session_history_media_info.video_decision',
                   'session_history_media_info.audio_decision',
                   'users.do_notify as do_notify',
                   'users.keep_history as keep_history'
                   ]
        try:
            query = data_tables.ssp_query(table_name='users',
                                          columns=columns,
                                          custom_where=[custom_where],
                                          group_by=['users.user_id'],
                                          join_types=['LEFT OUTER JOIN',
                                                      'LEFT OUTER JOIN',
                                                      'LEFT OUTER JOIN'],
                                          join_tables=['session_history',
                                                       'session_history_metadata',
                                                       'session_history_media_info'],
                                          join_evals=[['session_history.user_id', 'users.user_id'],
                                                      ['session_history.id', 'session_history_metadata.id'],
                                                      ['session_history.id', 'session_history_media_info.id']],
                                          kwargs=kwargs)
        except Exception as e:
            logger.warn(u"PlexPy Users :: Unable to execute database query for get_list: %s." % e)
            return {'recordsFiltered': 0,
                    'recordsTotal': 0,
                    'draw': 0,
                    'data': 'null',
                    'error': 'Unable to execute database query.'}

        users = query['result']

        rows = []
        for item in users:
            if item['media_type'] == 'episode' and item['parent_thumb']:
                thumb = item['parent_thumb']
            elif item['media_type'] == 'episode':
                thumb = item['grandparent_thumb']
            else:
                thumb = item['thumb']

            if item['custom_thumb'] and item['custom_thumb'] != item['user_thumb']:
                user_thumb = item['custom_thumb']
            elif item['user_thumb']:
                user_thumb = item['user_thumb']
            else:
                user_thumb = common.DEFAULT_USER_THUMB

            # Rename Mystery platform names
            platform = common.PLATFORM_NAME_OVERRIDES.get(item['platform'], item['platform'])

            row = {'user_id': item['user_id'],
                   'friendly_name': item['friendly_name'],
                   'user_thumb': user_thumb,
                   'plays': item['plays'],
                   'duration': item['duration'],
                   'last_seen': item['last_seen'],
                   'last_played': item['last_played'],
                   'id': item['id'],
                   'ip_address': item['ip_address'],
                   'platform': platform,
                   'player': item['player'],
                   'rating_key': item['rating_key'],
                   'media_type': item['media_type'],
                   'thumb': thumb,
                   'parent_title': item['parent_title'],
                   'year': item['year'],
                   'media_index': item['media_index'],
                   'parent_media_index': item['parent_media_index'],
                   'video_decision': item['video_decision'],
                   'audio_decision': item['audio_decision'],
                   'do_notify': helpers.checked(item['do_notify']),
                   'keep_history': helpers.checked(item['keep_history'])
                   }

            rows.append(row)

        dict = {'recordsFiltered': query['filteredCount'],
                'recordsTotal': query['totalCount'],
                'data': rows,
                'draw': query['draw']
                }

        return dict
Beispiel #13
0
    def get_user_list(self, kwargs=None):
        data_tables = datatables.DataTables()

        columns = ['session_history.id',
                   'users.user_id as user_id',
                   'users.custom_avatar_url as user_thumb',
                   '(case when users.friendly_name is null then users.username else \
                    users.friendly_name end) as friendly_name',
                   'MAX(session_history.started) as last_seen',
                   'session_history.ip_address as ip_address',
                   'COUNT(session_history.id) as plays',
                   'session_history.player as platform',
                   'session_history_metadata.full_title as last_watched',
                   'session_history_metadata.thumb',
                   'session_history_metadata.parent_thumb',
                   'session_history_metadata.grandparent_thumb',
                   'session_history_metadata.media_type',
                   'session_history.rating_key as rating_key',
                   'session_history_media_info.video_decision',
                   'users.username as user',
                   'users.do_notify as do_notify',
                   'users.keep_history as keep_history'
                   ]
        try:
            query = data_tables.ssp_query(table_name='users',
                                          columns=columns,
                                          custom_where=[],
                                          group_by=['users.user_id'],
                                          join_types=['LEFT OUTER JOIN',
                                                      'LEFT OUTER JOIN',
                                                      'LEFT OUTER JOIN'],
                                          join_tables=['session_history',
                                                       'session_history_metadata',
                                                       'session_history_media_info'],
                                          join_evals=[['session_history.user_id', 'users.user_id'],
                                                      ['session_history.id', 'session_history_metadata.id'],
                                                      ['session_history.id', 'session_history_media_info.id']],
                                          kwargs=kwargs)
        except:
            logger.warn("Unable to execute database query.")
            return {'recordsFiltered': 0,
                    'recordsTotal': 0,
                    'draw': 0,
                    'data': 'null',
                    'error': 'Unable to execute database query.'}

        users = query['result']

        rows = []
        for item in users:
            if item["media_type"] == 'episode' and item["parent_thumb"]:
                thumb = item["parent_thumb"]
            elif item["media_type"] == 'episode':
                thumb = item["grandparent_thumb"]
            else:
                thumb = item["thumb"]

            if not item['user_thumb'] or item['user_thumb'] == '':
                user_thumb = common.DEFAULT_USER_THUMB
            else:
                user_thumb = item['user_thumb']

            row = {"id": item['id'],
                   "plays": item['plays'],
                   "last_seen": item['last_seen'],
                   "friendly_name": item['friendly_name'],
                   "ip_address": item['ip_address'],
                   "platform": item['platform'],
                   "last_watched": item['last_watched'],
                   "thumb": thumb,
                   "media_type": item['media_type'],
                   "rating_key": item['rating_key'],
                   "video_decision": item['video_decision'],
                   "user_thumb": user_thumb,
                   "user": item["user"],
                   "user_id": item['user_id'],
                   "do_notify": helpers.checked(item['do_notify']),
                   "keep_history": helpers.checked(item['keep_history'])
                   }

            rows.append(row)

        dict = {'recordsFiltered': query['filteredCount'],
                'recordsTotal': query['totalCount'],
                'data': rows,
                'draw': query['draw']
        }

        return dict
Beispiel #14
0
def available_notification_agents():
    agents = [{'name': 'Growl',
               'id': AGENT_IDS['Growl'],
               'config_prefix': 'growl',
               'has_config': True,
               'state': checked(plexpy.CONFIG.GROWL_ENABLED),
               'on_play': plexpy.CONFIG.GROWL_ON_PLAY,
               'on_stop': plexpy.CONFIG.GROWL_ON_STOP,
               'on_pause': plexpy.CONFIG.GROWL_ON_PAUSE,
               'on_resume': plexpy.CONFIG.GROWL_ON_RESUME,
               'on_buffer': plexpy.CONFIG.GROWL_ON_BUFFER,
               'on_watched': plexpy.CONFIG.GROWL_ON_WATCHED
               },
              {'name': 'Prowl',
               'id': AGENT_IDS['Prowl'],
               'config_prefix': 'prowl',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PROWL_ENABLED),
               'on_play': plexpy.CONFIG.PROWL_ON_PLAY,
               'on_stop': plexpy.CONFIG.PROWL_ON_STOP,
               'on_pause': plexpy.CONFIG.PROWL_ON_PAUSE,
               'on_resume': plexpy.CONFIG.PROWL_ON_RESUME,
               'on_buffer': plexpy.CONFIG.PROWL_ON_BUFFER,
               'on_watched': plexpy.CONFIG.PROWL_ON_WATCHED
               },
              {'name': 'XBMC',
               'id': AGENT_IDS['XBMC'],
               'config_prefix': 'xbmc',
               'has_config': True,
               'state': checked(plexpy.CONFIG.XBMC_ENABLED),
               'on_play': plexpy.CONFIG.XBMC_ON_PLAY,
               'on_stop': plexpy.CONFIG.XBMC_ON_STOP,
               'on_pause': plexpy.CONFIG.XBMC_ON_PAUSE,
               'on_resume': plexpy.CONFIG.XBMC_ON_RESUME,
               'on_buffer': plexpy.CONFIG.XBMC_ON_BUFFER,
               'on_watched': plexpy.CONFIG.XBMC_ON_WATCHED
               },
              {'name': 'Plex',
               'id': AGENT_IDS['Plex'],
               'config_prefix': 'plex',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PLEX_ENABLED),
               'on_play': plexpy.CONFIG.PLEX_ON_PLAY,
               'on_stop': plexpy.CONFIG.PLEX_ON_STOP,
               'on_pause': plexpy.CONFIG.PLEX_ON_PAUSE,
               'on_resume': plexpy.CONFIG.PLEX_ON_RESUME,
               'on_buffer': plexpy.CONFIG.PLEX_ON_BUFFER,
               'on_watched': plexpy.CONFIG.PLEX_ON_WATCHED
               },
              {'name': 'NotifyMyAndroid',
               'id': AGENT_IDS['NMA'],
               'config_prefix': 'nma',
               'has_config': True,
               'state': checked(plexpy.CONFIG.NMA_ENABLED),
               'on_play': plexpy.CONFIG.NMA_ON_PLAY,
               'on_stop': plexpy.CONFIG.NMA_ON_STOP,
               'on_pause': plexpy.CONFIG.NMA_ON_PAUSE,
               'on_resume': plexpy.CONFIG.NMA_ON_RESUME,
               'on_buffer': plexpy.CONFIG.NMA_ON_BUFFER,
               'on_watched': plexpy.CONFIG.NMA_ON_WATCHED
               },
              {'name': 'Pushalot',
               'id': AGENT_IDS['Pushalot'],
               'config_prefix': 'pushalot',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PUSHALOT_ENABLED),
               'on_play': plexpy.CONFIG.PUSHALOT_ON_PLAY,
               'on_stop': plexpy.CONFIG.PUSHALOT_ON_STOP,
               'on_pause': plexpy.CONFIG.PUSHALOT_ON_PAUSE,
               'on_resume': plexpy.CONFIG.PUSHALOT_ON_RESUME,
               'on_buffer': plexpy.CONFIG.PUSHALOT_ON_BUFFER,
               'on_watched': plexpy.CONFIG.PUSHALOT_ON_WATCHED
               },
              {'name': 'Pushbullet',
               'id': AGENT_IDS['Pushbullet'],
               'config_prefix': 'pushbullet',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PUSHBULLET_ENABLED),
               'on_play': plexpy.CONFIG.PUSHBULLET_ON_PLAY,
               'on_stop': plexpy.CONFIG.PUSHBULLET_ON_STOP,
               'on_pause': plexpy.CONFIG.PUSHBULLET_ON_PAUSE,
               'on_resume': plexpy.CONFIG.PUSHBULLET_ON_RESUME,
               'on_buffer': plexpy.CONFIG.PUSHBULLET_ON_BUFFER,
               'on_watched': plexpy.CONFIG.PUSHBULLET_ON_WATCHED
               },
              {'name': 'Pushover',
               'id': AGENT_IDS['Pushover'],
               'config_prefix': 'pushover',
               'has_config': True,
               'state': checked(plexpy.CONFIG.PUSHOVER_ENABLED),
               'on_play': plexpy.CONFIG.PUSHOVER_ON_PLAY,
               'on_stop': plexpy.CONFIG.PUSHOVER_ON_STOP,
               'on_pause': plexpy.CONFIG.PUSHOVER_ON_PAUSE,
               'on_resume': plexpy.CONFIG.PUSHOVER_ON_RESUME,
               'on_buffer': plexpy.CONFIG.PUSHOVER_ON_BUFFER,
               'on_watched': plexpy.CONFIG.PUSHOVER_ON_WATCHED
               },
              {'name': 'Boxcar2',
               'id': AGENT_IDS['Boxcar2'],
               'config_prefix': 'boxcar',
               'has_config': True,
               'state': checked(plexpy.CONFIG.BOXCAR_ENABLED),
               'on_play': plexpy.CONFIG.BOXCAR_ON_PLAY,
               'on_stop': plexpy.CONFIG.BOXCAR_ON_STOP,
               'on_pause': plexpy.CONFIG.BOXCAR_ON_PAUSE,
               'on_resume': plexpy.CONFIG.BOXCAR_ON_RESUME,
               'on_buffer': plexpy.CONFIG.BOXCAR_ON_BUFFER,
               'on_watched': plexpy.CONFIG.BOXCAR_ON_WATCHED
               },
              {'name': 'E-mail',
               'id': AGENT_IDS['Email'],
               'config_prefix': 'email',
               'has_config': True,
               'state': checked(plexpy.CONFIG.EMAIL_ENABLED),
               'on_play': plexpy.CONFIG.EMAIL_ON_PLAY,
               'on_stop': plexpy.CONFIG.EMAIL_ON_STOP,
               'on_pause': plexpy.CONFIG.EMAIL_ON_PAUSE,
               'on_resume': plexpy.CONFIG.EMAIL_ON_RESUME,
               'on_buffer': plexpy.CONFIG.EMAIL_ON_BUFFER,
               'on_watched': plexpy.CONFIG.EMAIL_ON_WATCHED
               }
              ]

    # OSX Notifications should only be visible if it can be used
    osx_notify = OSX_NOTIFY()
    if osx_notify.validate():
        agents.append({'name': 'OSX Notify',
                       'id': AGENT_IDS['OSX Notify'],
                       'config_prefix': 'osx_notify',
                       'has_config': True,
                       'state': checked(plexpy.CONFIG.OSX_NOTIFY_ENABLED),
                       'on_play': plexpy.CONFIG.OSX_NOTIFY_ON_PLAY,
                       'on_stop': plexpy.CONFIG.OSX_NOTIFY_ON_STOP,
                       'on_pause': plexpy.CONFIG.OSX_NOTIFY_ON_PAUSE,
                       'on_resume': plexpy.CONFIG.OSX_NOTIFY_ON_RESUME,
                       'on_buffer': plexpy.CONFIG.OSX_NOTIFY_ON_BUFFER,
                       'on_watched': plexpy.CONFIG.OSX_NOTIFY_ON_WATCHED
                       })

    return agents
Beispiel #15
0
def available_notification_agents():
    agents = [{
        'name': 'Growl',
        'id': AGENT_IDS['Growl'],
        'config_prefix': 'growl',
        'has_config': True,
        'state': checked(plexpy.CONFIG.GROWL_ENABLED),
        'on_play': plexpy.CONFIG.GROWL_ON_PLAY,
        'on_stop': plexpy.CONFIG.GROWL_ON_STOP,
        'on_pause': plexpy.CONFIG.GROWL_ON_PAUSE,
        'on_resume': plexpy.CONFIG.GROWL_ON_RESUME,
        'on_buffer': plexpy.CONFIG.GROWL_ON_BUFFER,
        'on_watched': plexpy.CONFIG.GROWL_ON_WATCHED
    }, {
        'name': 'Prowl',
        'id': AGENT_IDS['Prowl'],
        'config_prefix': 'prowl',
        'has_config': True,
        'state': checked(plexpy.CONFIG.PROWL_ENABLED),
        'on_play': plexpy.CONFIG.PROWL_ON_PLAY,
        'on_stop': plexpy.CONFIG.PROWL_ON_STOP,
        'on_pause': plexpy.CONFIG.PROWL_ON_PAUSE,
        'on_resume': plexpy.CONFIG.PROWL_ON_RESUME,
        'on_buffer': plexpy.CONFIG.PROWL_ON_BUFFER,
        'on_watched': plexpy.CONFIG.PROWL_ON_WATCHED
    }, {
        'name': 'XBMC',
        'id': AGENT_IDS['XBMC'],
        'config_prefix': 'xbmc',
        'has_config': True,
        'state': checked(plexpy.CONFIG.XBMC_ENABLED),
        'on_play': plexpy.CONFIG.XBMC_ON_PLAY,
        'on_stop': plexpy.CONFIG.XBMC_ON_STOP,
        'on_pause': plexpy.CONFIG.XBMC_ON_PAUSE,
        'on_resume': plexpy.CONFIG.XBMC_ON_RESUME,
        'on_buffer': plexpy.CONFIG.XBMC_ON_BUFFER,
        'on_watched': plexpy.CONFIG.XBMC_ON_WATCHED
    }, {
        'name': 'Plex',
        'id': AGENT_IDS['Plex'],
        'config_prefix': 'plex',
        'has_config': True,
        'state': checked(plexpy.CONFIG.PLEX_ENABLED),
        'on_play': plexpy.CONFIG.PLEX_ON_PLAY,
        'on_stop': plexpy.CONFIG.PLEX_ON_STOP,
        'on_pause': plexpy.CONFIG.PLEX_ON_PAUSE,
        'on_resume': plexpy.CONFIG.PLEX_ON_RESUME,
        'on_buffer': plexpy.CONFIG.PLEX_ON_BUFFER,
        'on_watched': plexpy.CONFIG.PLEX_ON_WATCHED
    }, {
        'name': 'NotifyMyAndroid',
        'id': AGENT_IDS['NMA'],
        'config_prefix': 'nma',
        'has_config': True,
        'state': checked(plexpy.CONFIG.NMA_ENABLED),
        'on_play': plexpy.CONFIG.NMA_ON_PLAY,
        'on_stop': plexpy.CONFIG.NMA_ON_STOP,
        'on_pause': plexpy.CONFIG.NMA_ON_PAUSE,
        'on_resume': plexpy.CONFIG.NMA_ON_RESUME,
        'on_buffer': plexpy.CONFIG.NMA_ON_BUFFER,
        'on_watched': plexpy.CONFIG.NMA_ON_WATCHED
    }, {
        'name': 'Pushalot',
        'id': AGENT_IDS['Pushalot'],
        'config_prefix': 'pushalot',
        'has_config': True,
        'state': checked(plexpy.CONFIG.PUSHALOT_ENABLED),
        'on_play': plexpy.CONFIG.PUSHALOT_ON_PLAY,
        'on_stop': plexpy.CONFIG.PUSHALOT_ON_STOP,
        'on_pause': plexpy.CONFIG.PUSHALOT_ON_PAUSE,
        'on_resume': plexpy.CONFIG.PUSHALOT_ON_RESUME,
        'on_buffer': plexpy.CONFIG.PUSHALOT_ON_BUFFER,
        'on_watched': plexpy.CONFIG.PUSHALOT_ON_WATCHED
    }, {
        'name': 'Pushbullet',
        'id': AGENT_IDS['Pushbullet'],
        'config_prefix': 'pushbullet',
        'has_config': True,
        'state': checked(plexpy.CONFIG.PUSHBULLET_ENABLED),
        'on_play': plexpy.CONFIG.PUSHBULLET_ON_PLAY,
        'on_stop': plexpy.CONFIG.PUSHBULLET_ON_STOP,
        'on_pause': plexpy.CONFIG.PUSHBULLET_ON_PAUSE,
        'on_resume': plexpy.CONFIG.PUSHBULLET_ON_RESUME,
        'on_buffer': plexpy.CONFIG.PUSHBULLET_ON_BUFFER,
        'on_watched': plexpy.CONFIG.PUSHBULLET_ON_WATCHED
    }, {
        'name': 'Pushover',
        'id': AGENT_IDS['Pushover'],
        'config_prefix': 'pushover',
        'has_config': True,
        'state': checked(plexpy.CONFIG.PUSHOVER_ENABLED),
        'on_play': plexpy.CONFIG.PUSHOVER_ON_PLAY,
        'on_stop': plexpy.CONFIG.PUSHOVER_ON_STOP,
        'on_pause': plexpy.CONFIG.PUSHOVER_ON_PAUSE,
        'on_resume': plexpy.CONFIG.PUSHOVER_ON_RESUME,
        'on_buffer': plexpy.CONFIG.PUSHOVER_ON_BUFFER,
        'on_watched': plexpy.CONFIG.PUSHOVER_ON_WATCHED
    }, {
        'name': 'Boxcar2',
        'id': AGENT_IDS['Boxcar2'],
        'config_prefix': 'boxcar',
        'has_config': True,
        'state': checked(plexpy.CONFIG.BOXCAR_ENABLED),
        'on_play': plexpy.CONFIG.BOXCAR_ON_PLAY,
        'on_stop': plexpy.CONFIG.BOXCAR_ON_STOP,
        'on_pause': plexpy.CONFIG.BOXCAR_ON_PAUSE,
        'on_resume': plexpy.CONFIG.BOXCAR_ON_RESUME,
        'on_buffer': plexpy.CONFIG.BOXCAR_ON_BUFFER,
        'on_watched': plexpy.CONFIG.BOXCAR_ON_WATCHED
    }, {
        'name': 'E-mail',
        'id': AGENT_IDS['Email'],
        'config_prefix': 'email',
        'has_config': True,
        'state': checked(plexpy.CONFIG.EMAIL_ENABLED),
        'on_play': plexpy.CONFIG.EMAIL_ON_PLAY,
        'on_stop': plexpy.CONFIG.EMAIL_ON_STOP,
        'on_pause': plexpy.CONFIG.EMAIL_ON_PAUSE,
        'on_resume': plexpy.CONFIG.EMAIL_ON_RESUME,
        'on_buffer': plexpy.CONFIG.EMAIL_ON_BUFFER,
        'on_watched': plexpy.CONFIG.EMAIL_ON_WATCHED
    }]

    # OSX Notifications should only be visible if it can be used
    osx_notify = OSX_NOTIFY()
    if osx_notify.validate():
        agents.append({
            'name': 'OSX Notify',
            'id': AGENT_IDS['OSX Notify'],
            'config_prefix': 'osx_notify',
            'has_config': True,
            'state': checked(plexpy.CONFIG.OSX_NOTIFY_ENABLED),
            'on_play': plexpy.CONFIG.OSX_NOTIFY_ON_PLAY,
            'on_stop': plexpy.CONFIG.OSX_NOTIFY_ON_STOP,
            'on_pause': plexpy.CONFIG.OSX_NOTIFY_ON_PAUSE,
            'on_resume': plexpy.CONFIG.OSX_NOTIFY_ON_RESUME,
            'on_buffer': plexpy.CONFIG.OSX_NOTIFY_ON_BUFFER,
            'on_watched': plexpy.CONFIG.OSX_NOTIFY_ON_WATCHED
        })

    return agents
Beispiel #16
0
    def get_datatables_list(self, kwargs=None):
        data_tables = datatables.DataTables()

        custom_where = ['library_sections.deleted_section', 0]

        columns = ['library_sections.section_id',
                   'library_sections.section_name',
                   'library_sections.section_type',
                   'library_sections.count',
                   'library_sections.parent_count',
                   'library_sections.child_count',
                   'library_sections.thumb AS library_thumb',
                   'library_sections.custom_thumb_url AS custom_thumb',
                   'library_sections.art',
                   'COUNT(session_history.id) AS plays',
                   'MAX(session_history.started) AS last_accessed',
                   'MAX(session_history.id) AS id',
                   'session_history_metadata.full_title AS last_played',
                   'session_history.rating_key',
                   'session_history_metadata.media_type',
                   'session_history_metadata.thumb',
                   'session_history_metadata.parent_thumb',
                   'session_history_metadata.grandparent_thumb',
                   'session_history_metadata.parent_title',
                   'session_history_metadata.year',
                   'session_history_metadata.media_index',
                   'session_history_metadata.parent_media_index',
                   'session_history_media_info.video_decision',
                   'library_sections.do_notify',
                   'library_sections.do_notify_created',
                   'library_sections.keep_history'
                   ]
        try:
            query = data_tables.ssp_query(table_name='library_sections',
                                          columns=columns,
                                          custom_where=[custom_where],
                                          group_by=['library_sections.server_id', 'library_sections.section_id'],
                                          join_types=['LEFT OUTER JOIN',
                                                      'LEFT OUTER JOIN',
                                                      'LEFT OUTER JOIN'],
                                          join_tables=['session_history_metadata',
                                                       'session_history',
                                                       'session_history_media_info'],
                                          join_evals=[['session_history_metadata.section_id', 'library_sections.section_id'],
                                                      ['session_history_metadata.id', 'session_history.id'],
                                                      ['session_history_metadata.id', 'session_history_media_info.id']],
                                          kwargs=kwargs)
        except Exception as e:
            logger.warn(u"PlexPy Libraries :: Unable to execute database query for get_list: %s." % e)
            return {'recordsFiltered': 0,
                    'recordsTotal': 0,
                    'draw': 0,
                    'data': 'null',
                    'error': 'Unable to execute database query.'}

        result = query['result']
        
        rows = []
        for item in result:
            if item['media_type'] == 'episode' and item['parent_thumb']:
                thumb = item['parent_thumb']
            elif item['media_type'] == 'episode':
                thumb = item['grandparent_thumb']
            else:
                thumb = item['thumb']

            if item['custom_thumb'] and item['custom_thumb'] != item['library_thumb']:
                library_thumb = item['custom_thumb']
            elif item['library_thumb']:
                library_thumb = item['library_thumb']
            else:
                library_thumb = common.DEFAULT_COVER_THUMB

            row = {'section_id': item['section_id'],
                   'section_name': item['section_name'],
                   'section_type': item['section_type'].capitalize(),
                   'count': item['count'],
                   'parent_count': item['parent_count'],
                   'child_count': item['child_count'],
                   'library_thumb': library_thumb,
                   'library_art': item['art'],
                   'plays': item['plays'],
                   'last_accessed': item['last_accessed'],
                   'id': item['id'],
                   'last_played': item['last_played'],
                   'rating_key': item['rating_key'],
                   'media_type': item['media_type'],
                   'thumb': thumb,
                   'parent_title': item['parent_title'],
                   'year': item['year'],
                   'media_index': item['media_index'],
                   'parent_media_index': item['parent_media_index'],
                   'do_notify': helpers.checked(item['do_notify']),
                   'do_notify_created': helpers.checked(item['do_notify_created']),
                   'keep_history': helpers.checked(item['keep_history'])
                   }

            rows.append(row)
        
        dict = {'recordsFiltered': query['filteredCount'],
                'recordsTotal': query['totalCount'],
                'data': rows,
                'draw': query['draw']
                }
        
        return dict
Beispiel #17
0
    def get_datatables_list(self, kwargs=None):
        default_return = {
            'recordsFiltered': 0,
            'recordsTotal': 0,
            'draw': 0,
            'data': 'null',
            'error': 'Unable to execute database query.'
        }

        data_tables = datatables.DataTables()

        custom_where = [['users.deleted_user', 0]]

        if session.get_session_user_id() and int(
                session.get_session_access_level()) < 3:
            custom_where.append(
                ['users.user_id',
                 session.get_session_user_id()])

        if kwargs.get('user_id'):
            custom_where.append(['users.user_id', kwargs.get('user_id')])

        columns = [
            'users.user_id',
            '(CASE WHEN users.friendly_name IS NULL OR TRIM(users.friendly_name) = "" \
                    THEN users.username ELSE users.friendly_name END) AS friendly_name',
            'users.thumb AS user_thumb',
            'users.custom_avatar_url AS custom_thumb',
            'COUNT(session_history.id) AS plays',
            'SUM(CASE WHEN session_history.stopped > 0 THEN (session_history.stopped - session_history.started) \
                    ELSE 0 END) - SUM(CASE WHEN session_history.paused_counter IS NULL THEN 0 ELSE \
                    session_history.paused_counter END) AS duration',
            'MAX(session_history.started) AS last_seen',
            'MAX(session_history.id) AS id',
            'session_history_metadata.full_title AS last_played',
            'servers.pms_name AS last_server', 'session_history.ip_address',
            'session_history.platform', 'session_history.player',
            'session_history.rating_key',
            'session_history_metadata.media_type',
            'session_history_metadata.thumb',
            'session_history_metadata.parent_thumb',
            'session_history_metadata.grandparent_thumb',
            'session_history_metadata.parent_title',
            'session_history_metadata.year',
            'session_history_metadata.media_index',
            'session_history_metadata.parent_media_index',
            'session_history_media_info.transcode_decision',
            'users.do_notify as do_notify',
            'users.keep_history as keep_history',
            'users.allow_guest as allow_guest'
        ]
        try:
            query = data_tables.ssp_query(
                table_name='users',
                columns=columns,
                custom_where=custom_where,
                group_by=['users.user_id'],
                join_types=[
                    'LEFT OUTER JOIN', 'LEFT OUTER JOIN', 'LEFT OUTER JOIN',
                    'LEFT OUTER JOIN'
                ],
                join_tables=[
                    'session_history', 'session_history_metadata',
                    'session_history_media_info', 'servers'
                ],
                join_evals=[
                    ['session_history.user_id', 'users.user_id'],
                    ['session_history.id', 'session_history_metadata.id'],
                    ['session_history.id', 'session_history_media_info.id'],
                    ['session_history.server_id', 'servers.id']
                ],
                kwargs=kwargs)
        except Exception as e:
            logger.warn(
                u"Tautulli Users :: Unable to execute database query for get_list: %s."
                % e)
            return default_return

        users = query['result']

        rows = []
        for item in users:
            if item['media_type'] == 'episode' and item['parent_thumb']:
                thumb = item['parent_thumb']
            elif item['media_type'] == 'episode':
                thumb = item['grandparent_thumb']
            else:
                thumb = item['thumb']

            if item['custom_thumb'] and item['custom_thumb'] != item[
                    'user_thumb']:
                user_thumb = item['custom_thumb']
            elif item['user_thumb']:
                user_thumb = item['user_thumb']
            else:
                user_thumb = common.DEFAULT_USER_THUMB

            # Rename Mystery platform names
            platform = common.PLATFORM_NAME_OVERRIDES.get(
                item['platform'], item['platform'])

            row = {
                'user_id': item['user_id'],
                'friendly_name': item['friendly_name'],
                'user_thumb': user_thumb,
                'plays': item['plays'],
                'duration': item['duration'],
                'last_seen': item['last_seen'],
                'last_played': item['last_played'],
                'last_server': item['last_server'],
                'id': item['id'],
                'ip_address': item['ip_address'],
                'platform': platform,
                'player': item['player'],
                'rating_key': item['rating_key'],
                'media_type': item['media_type'],
                'thumb': thumb,
                'parent_title': item['parent_title'],
                'year': item['year'],
                'media_index': item['media_index'],
                'parent_media_index': item['parent_media_index'],
                'transcode_decision': item['transcode_decision'],
                'do_notify': helpers.checked(item['do_notify']),
                'keep_history': helpers.checked(item['keep_history']),
                'allow_guest': item['allow_guest']
            }

            rows.append(row)

        dict = {
            'recordsFiltered': query['filteredCount'],
            'recordsTotal': query['totalCount'],
            'data': session.friendly_name_to_username(rows),
            'draw': query['draw']
        }

        return dict
Beispiel #18
0
    def get_datatables_list(self, kwargs=None):
        data_tables = datatables.DataTables()

        custom_where = ['library_sections.deleted_section', 0]

        columns = [
            'library_sections.section_id', 'library_sections.section_name',
            'library_sections.section_type', 'library_sections.count',
            'library_sections.parent_count', 'library_sections.child_count',
            'library_sections.thumb AS library_thumb',
            'library_sections.custom_thumb_url AS custom_thumb',
            'library_sections.art', 'COUNT(session_history.id) AS plays',
            'SUM(CASE WHEN session_history.stopped > 0 THEN (session_history.stopped - session_history.started) \
                    ELSE 0 END) - SUM(CASE WHEN session_history.paused_counter IS NULL THEN 0 ELSE \
                    session_history.paused_counter END) AS duration',
            'MAX(session_history.started) AS last_accessed',
            'MAX(session_history.id) AS id',
            'session_history_metadata.full_title AS last_played',
            'session_history.rating_key',
            'session_history_metadata.media_type',
            'session_history_metadata.thumb',
            'session_history_metadata.parent_thumb',
            'session_history_metadata.grandparent_thumb',
            'session_history_metadata.parent_title',
            'session_history_metadata.year',
            'session_history_metadata.media_index',
            'session_history_metadata.parent_media_index',
            'session_history_media_info.video_decision',
            'library_sections.do_notify', 'library_sections.do_notify_created',
            'library_sections.keep_history'
        ]
        try:
            query = data_tables.ssp_query(
                table_name='library_sections',
                columns=columns,
                custom_where=[custom_where],
                group_by=[
                    'library_sections.server_id', 'library_sections.section_id'
                ],
                join_types=[
                    'LEFT OUTER JOIN', 'LEFT OUTER JOIN', 'LEFT OUTER JOIN'
                ],
                join_tables=[
                    'session_history_metadata', 'session_history',
                    'session_history_media_info'
                ],
                join_evals=[[
                    'session_history_metadata.section_id',
                    'library_sections.section_id'
                ], ['session_history_metadata.id', 'session_history.id'],
                            [
                                'session_history_metadata.id',
                                'session_history_media_info.id'
                            ]],
                kwargs=kwargs)
        except Exception as e:
            logger.warn(
                u"PlexPy Libraries :: Unable to execute database query for get_list: %s."
                % e)
            return {
                'recordsFiltered': 0,
                'recordsTotal': 0,
                'draw': 0,
                'data': 'null',
                'error': 'Unable to execute database query.'
            }

        result = query['result']

        rows = []
        for item in result:
            if item['media_type'] == 'episode' and item['parent_thumb']:
                thumb = item['parent_thumb']
            elif item['media_type'] == 'episode':
                thumb = item['grandparent_thumb']
            else:
                thumb = item['thumb']

            if item['custom_thumb'] and item['custom_thumb'] != item[
                    'library_thumb']:
                library_thumb = item['custom_thumb']
            elif item['library_thumb']:
                library_thumb = item['library_thumb']
            else:
                library_thumb = common.DEFAULT_COVER_THUMB

            row = {
                'section_id': item['section_id'],
                'section_name': item['section_name'],
                'section_type': item['section_type'].capitalize(),
                'count': item['count'],
                'parent_count': item['parent_count'],
                'child_count': item['child_count'],
                'library_thumb': library_thumb,
                'library_art': item['art'],
                'plays': item['plays'],
                'duration': item['duration'],
                'last_accessed': item['last_accessed'],
                'id': item['id'],
                'last_played': item['last_played'],
                'rating_key': item['rating_key'],
                'media_type': item['media_type'],
                'thumb': thumb,
                'parent_title': item['parent_title'],
                'year': item['year'],
                'media_index': item['media_index'],
                'parent_media_index': item['parent_media_index'],
                'do_notify': helpers.checked(item['do_notify']),
                'do_notify_created':
                helpers.checked(item['do_notify_created']),
                'keep_history': helpers.checked(item['keep_history'])
            }

            rows.append(row)

        dict = {
            'recordsFiltered': query['filteredCount'],
            'recordsTotal': query['totalCount'],
            'data': rows,
            'draw': query['draw']
        }

        return dict