diff --git a/Tautulli.py b/Tautulli.py index b1fc79af..2517b8dc 100755 --- a/Tautulli.py +++ b/Tautulli.py @@ -104,8 +104,8 @@ def main(): plexpy.QUIET = True # Do an intial setup of the logger. - logger.initLogger(console=not plexpy.QUIET, log_dir=False, - verbose=plexpy.VERBOSE) + # Require verbose for pre-initilization to see critical errors + logger.initLogger(console=not plexpy.QUIET, log_dir=False, verbose=True) try: plexpy.SYS_TIMEZONE = tzlocal.get_localzone() diff --git a/data/interfaces/default/js/tables/history_table.js b/data/interfaces/default/js/tables/history_table.js index b605cdd2..60f55513 100644 --- a/data/interfaces/default/js/tables/history_table.js +++ b/data/interfaces/default/js/tables/history_table.js @@ -166,7 +166,7 @@ history_table_options = { thumb_popover = '' + cellData + parent_info + '' $(td).html('
' + media_type + ' ' + thumb_popover + '
'); } else if (rowData['media_type'] === 'episode') { - if (rowData['parent_media_index'] && rowData['media_index']) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } + if (!isNaN(parseInt(rowData['parent_media_index'])) && !isNaN(parseInt(rowData['media_index']))) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } media_type = ''; thumb_popover = '' + cellData + parent_info + '' $(td).html('
' + media_type + ' ' + thumb_popover + '
'); diff --git a/data/interfaces/default/js/tables/history_table_modal.js b/data/interfaces/default/js/tables/history_table_modal.js index 2ee57681..59d3357d 100644 --- a/data/interfaces/default/js/tables/history_table_modal.js +++ b/data/interfaces/default/js/tables/history_table_modal.js @@ -107,7 +107,7 @@ history_table_modal_options = { thumb_popover = '' + cellData + parent_info + '' $(td).html('
' + media_type + ' ' + thumb_popover + '
'); } else if (rowData['media_type'] === 'episode') { - if (rowData['parent_media_index'] && rowData['media_index']) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } + if (!isNaN(parseInt(rowData['parent_media_index'])) && !isNaN(parseInt(rowData['media_index']))) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } media_type = ''; thumb_popover = '' + cellData + parent_info + '' $(td).html('
' + media_type + ' ' + thumb_popover + '
'); diff --git a/data/interfaces/default/js/tables/libraries.js b/data/interfaces/default/js/tables/libraries.js index ee53b423..5c2c334d 100644 --- a/data/interfaces/default/js/tables/libraries.js +++ b/data/interfaces/default/js/tables/libraries.js @@ -153,7 +153,7 @@ libraries_list_table_options = { } else if (rowData['media_type'] === 'episode') { media_type = ''; if (rowData['rating_key']) { - if (rowData['parent_media_index'] && rowData['media_index']) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } + if (!isNaN(parseInt(rowData['parent_media_index'])) && !isNaN(parseInt(rowData['media_index']))) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } thumb_popover = '' + cellData + parent_info + '' $(td).html('
' + media_type + ' ' + thumb_popover + '
'); } else { diff --git a/data/interfaces/default/js/tables/user_ips.js b/data/interfaces/default/js/tables/user_ips.js index b1acac2a..046adc65 100644 --- a/data/interfaces/default/js/tables/user_ips.js +++ b/data/interfaces/default/js/tables/user_ips.js @@ -91,7 +91,7 @@ user_ip_table_options = { thumb_popover = '' + cellData + parent_info + '' $(td).html('
' + media_type + ' ' + thumb_popover + '
'); } else if (rowData['media_type'] === 'episode') { - if (rowData['parent_media_index'] && rowData['media_index']) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } + if (!isNaN(parseInt(rowData['parent_media_index'])) && !isNaN(parseInt(rowData['media_index']))) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } media_type = ''; thumb_popover = '' + cellData + parent_info + '' $(td).html('
' + media_type + ' ' + thumb_popover + '
'); diff --git a/data/interfaces/default/js/tables/users.js b/data/interfaces/default/js/tables/users.js index a97a78b8..bc9caf5b 100644 --- a/data/interfaces/default/js/tables/users.js +++ b/data/interfaces/default/js/tables/users.js @@ -166,7 +166,7 @@ users_list_table_options = { thumb_popover = '' + cellData + parent_info + '' $(td).html('
' + media_type + ' ' + thumb_popover + '
'); } else if (rowData['media_type'] === 'episode') { - if (rowData['parent_media_index'] && rowData['media_index']) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } + if (!isNaN(parseInt(rowData['parent_media_index'])) && !isNaN(parseInt(rowData['media_index']))) { parent_info = ' (S' + rowData['parent_media_index'] + ' · E' + rowData['media_index'] + ')'; } media_type = ''; thumb_popover = '' + cellData + parent_info + '' $(td).html('
' + media_type + ' ' + thumb_popover + '
'); diff --git a/data/interfaces/newsletters/recently_added.html b/data/interfaces/newsletters/recently_added.html index c6f5fba1..f16e2c15 100644 --- a/data/interfaces/newsletters/recently_added.html +++ b/data/interfaces/newsletters/recently_added.html @@ -694,7 +694,7 @@
${len(recently_added['show'])} show${'s' if len(recently_added['show']) > 1 else ''} /  <% total_episodes = sum(season['episode_count'] for show in recently_added['show'] for season in show['season']) %> - ${total_episodes} episode${'s' if total > 1 else ''} + ${total_episodes} episode${'s' if total_episodes > 1 else ''}
@@ -847,7 +847,7 @@
${len(recently_added['artist'])} artist${'s' if len(recently_added['artist']) > 1 else ''} / <% total_albums = sum(artist['album_count'] for artist in recently_added['artist']) %> - ${total_albums} album${'s' if total > 1 else ''} + ${total_albums} album${'s' if total_albums > 1 else ''}
diff --git a/data/interfaces/newsletters/recently_added.internal.html b/data/interfaces/newsletters/recently_added.internal.html index 198ba49e..96e3e82e 100644 --- a/data/interfaces/newsletters/recently_added.internal.html +++ b/data/interfaces/newsletters/recently_added.internal.html @@ -694,7 +694,7 @@
${len(recently_added['show'])} show${'s' if len(recently_added['show']) > 1 else ''} /  <% total_episodes = sum(season['episode_count'] for show in recently_added['show'] for season in show['season']) %> - ${total_episodes} episode${'s' if total > 1 else ''} + ${total_episodes} episode${'s' if total_episodes > 1 else ''}
@@ -847,7 +847,7 @@
${len(recently_added['artist'])} artist${'s' if len(recently_added['artist']) > 1 else ''} / <% total_albums = sum(artist['album_count'] for artist in recently_added['artist']) %> - ${total_albums} album${'s' if total > 1 else ''} + ${total_albums} album${'s' if total_albums > 1 else ''}
diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 2b2e555c..20bac8bd 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -71,7 +71,7 @@ SYS_LANGUAGE = None SYS_ENCODING = None QUIET = False -VERBOSE = True +VERBOSE = False DAEMON = False CREATEPID = False PIDFILE = None @@ -128,6 +128,7 @@ def initialize(config_file): global CONFIG global CONFIG_FILE + global VERBOSE global _INITIALIZED global CURRENT_VERSION global LATEST_VERSION @@ -157,6 +158,8 @@ def initialize(config_file): if not log_writable and not QUIET: sys.stderr.write("Unable to create the log directory. Logging to screen only.\n") + VERBOSE = VERBOSE or bool(CONFIG.VERBOSE_LOGS) + # Start the logger, disable console if needed logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR if log_writable else None, verbose=VERBOSE) diff --git a/plexpy/config.py b/plexpy/config.py index d5d79c6b..c3673247 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -608,6 +608,7 @@ _CONFIG_DEFINITIONS = { 'UPDATE_LABELS': (int, 'General', 1), 'UPDATE_LIBRARIES_DB_NOTIFY': (int, 'General', 1), 'UPDATE_NOTIFIERS_DB': (int, 'General', 1), + 'VERBOSE_LOGS': (int, 'Advanced', 1), 'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1), 'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1), 'WEBSOCKET_MONITOR_PING_PONG': (int, 'Advanced', 0), diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index d6776bea..d14f8d49 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -3366,7 +3366,7 @@ class TELEGRAM(Notifier): if len(text) > 1024: data['disable_notification'] = True else: - data['caption'] = text + data['caption'] = text.encode('utf-8') r = self.make_request('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']), data=data, files=files) @@ -3374,7 +3374,7 @@ class TELEGRAM(Notifier): if not data.pop('disable_notification', None): return r - data['text'] = text + data['text'] = (text[:4093] + (text[4093:] and '...')).encode('utf-8') if self.config['disable_web_preview']: data['disable_web_page_preview'] = True diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 36722e31..e1cd8de3 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -2678,8 +2678,11 @@ class WebInterface(object): @requireAuth(member_of("admin")) def toggleVerbose(self, **kwargs): plexpy.VERBOSE = not plexpy.VERBOSE - logger.initLogger(console=not plexpy.QUIET, - log_dir=plexpy.CONFIG.LOG_DIR, verbose=plexpy.VERBOSE) + + plexpy.CONFIG.__setattr__('VERBOSE_LOGS', plexpy.VERBOSE) + plexpy.CONFIG.write() + + logger.initLogger(console=not plexpy.QUIET, log_dir=plexpy.CONFIG.LOG_DIR, verbose=plexpy.VERBOSE) logger.info("Verbose toggled, set to %s", plexpy.VERBOSE) logger.debug("If you read this message, debug logging is available") raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "logs")