Compare commits

..

9 Commits

Author SHA1 Message Date
JonnyWong16
8902b93a26 Merge branch 'dev' 2016-01-26 00:14:38 -08:00
JonnyWong16
ae36af807d v1.3.3 2016-01-26 00:13:58 -08:00
JonnyWong16
fd256625c6 Fix Plays by Month graph not loading 2016-01-25 18:43:51 -08:00
JonnyWong16
bee543a25a Disable datatables caching 2016-01-25 18:30:30 -08:00
JonnyWong16
55eb79cb52 Even faster library updating 2016-01-25 12:01:59 -08:00
JonnyWong16
35965a8320 Merge branch 'dev' 2016-01-24 22:52:47 -08:00
JonnyWong16
8a902ae3e6 v1.3.2 2016-01-24 22:51:36 -08:00
JonnyWong16
52bed5bf98 Attempt at improved library updating 2016-01-24 22:19:48 -08:00
JonnyWong16
9e83f6d779 Another fix for 'datestamp' and 'timestamp' 2016-01-24 09:52:20 -08:00
14 changed files with 84 additions and 51 deletions

View File

@@ -1,5 +1,18 @@
# Changelog # Changelog
## v1.3.3 (2016-01-26)
* Fix: Plays by Month graph not loading.
* Change: Disable caching for datatables.
* Change: Improved updating library data in the database again.
## v1.3.2 (2016-01-24)
* Fix: 'datestamp' and 'timestamp' for server notifications.
* Change: New method for updating library data in database.
## v1.3.1 (2016-01-23) ## v1.3.1 (2016-01-23)
* Fix: Notifiers authorization popups for reverse proxies. * Fix: Notifiers authorization popups for reverse proxies.
@@ -7,8 +20,8 @@
* Fix: Star rating overlapping text. * Fix: Star rating overlapping text.
* Fix: Unable to startup when library refresh fails. * Fix: Unable to startup when library refresh fails.
* Fix: Unable to parse 'datestamp' and 'timestamp' format. * Fix: Unable to parse 'datestamp' and 'timestamp' format.
* Change: Rename "Last Watched" to "Last Played" * Change: Rename "Last Watched" to "Last Played".
* Change: More descriptive libraries updating message * Change: More descriptive libraries updating message.
## v1.3.0 (2016-01-23) ## v1.3.0 (2016-01-23)

View File

@@ -22,7 +22,7 @@ history_table_options = {
"emptyTable": "No data in table" "emptyTable": "No data in table"
}, },
"pagingType": "bootstrap", "pagingType": "bootstrap",
"stateSave": true, "stateSave": false,
"processing": false, "processing": false,
"serverSide": true, "serverSide": true,
"pageLength": 25, "pageLength": 25,

View File

@@ -16,7 +16,7 @@ libraries_list_table_options = {
"pageLength": 10, "pageLength": 10,
"order": [ 2, 'asc'], "order": [ 2, 'asc'],
"autoWidth": true, "autoWidth": true,
"stateSave": true, "stateSave": false,
"pagingType": "bootstrap", "pagingType": "bootstrap",
"columnDefs": [ "columnDefs": [
{ {

View File

@@ -5,7 +5,7 @@ var log_table_options = {
"pagingType": "bootstrap", "pagingType": "bootstrap",
"order": [ 0, 'desc'], "order": [ 0, 'desc'],
"pageLength": 50, "pageLength": 50,
"stateSave": true, "stateSave": false,
"language": { "language": {
"search":"Search: ", "search":"Search: ",
"lengthMenu":"Show _MENU_ lines per page", "lengthMenu":"Show _MENU_ lines per page",

View File

@@ -5,7 +5,7 @@ var plex_log_table_options = {
"pagingType": "bootstrap", "pagingType": "bootstrap",
"order": [ 0, 'desc'], "order": [ 0, 'desc'],
"pageLength": 50, "pageLength": 50,
"stateSave": true, "stateSave": false,
"language": { "language": {
"search":"Search: ", "search":"Search: ",
"lengthMenu":"Show _MENU_ lines per page", "lengthMenu":"Show _MENU_ lines per page",

View File

@@ -4,7 +4,7 @@ sync_table_options = {
"pagingType": "bootstrap", "pagingType": "bootstrap",
"order": [ [ 0, 'desc'], [ 1, 'asc'], [2, 'asc'] ], "order": [ [ 0, 'desc'], [ 1, 'asc'], [2, 'asc'] ],
"pageLength": 25, "pageLength": 25,
"stateSave": true, "stateSave": false,
"language": { "language": {
"search":"Search: ", "search":"Search: ",
"lengthMenu":"Show _MENU_ lines per page", "lengthMenu":"Show _MENU_ lines per page",

View File

@@ -8,7 +8,7 @@ user_ip_table_options = {
"infoFiltered":"(filtered from _MAX_ total entries)", "infoFiltered":"(filtered from _MAX_ total entries)",
"emptyTable": "No data in table", "emptyTable": "No data in table",
}, },
"stateSave": true, "stateSave": false,
"pagingType": "bootstrap", "pagingType": "bootstrap",
"processing": false, "processing": false,
"serverSide": true, "serverSide": true,

View File

@@ -16,7 +16,7 @@ users_list_table_options = {
"pageLength": 10, "pageLength": 10,
"order": [ 2, 'asc'], "order": [ 2, 'asc'],
"autoWidth": true, "autoWidth": true,
"stateSave": true, "stateSave": false,
"pagingType": "bootstrap", "pagingType": "bootstrap",
"columnDefs": [ "columnDefs": [
{ {

View File

@@ -15,7 +15,7 @@
<div id="update_section_ids_message" style="text-align: center; margin-top: 20px;"> <div id="update_section_ids_message" style="text-align: center; margin-top: 20px;">
<i class="fa fa-refresh fa-spin"></i> PlexPy is updating library IDs in the database. This could take a few minutes to hours depending on the size of your database. <i class="fa fa-refresh fa-spin"></i> PlexPy is updating library IDs in the database. This could take a few minutes to hours depending on the size of your database.
<br /> <br />
You may leave this page and come back later. Note: All monitoring has been disabled while this update is in progress. You may leave this page and come back later.
</div> </div>
% endif % endif
<div class='table-card-header'> <div class='table-card-header'>
@@ -177,7 +177,7 @@
$("#refresh-libraries-list").click(function () { $("#refresh-libraries-list").click(function () {
if ("${config['update_section_ids']}" == "1") { if ("${config['update_section_ids']}" == "1") {
$('#update_section_ids_message').html( $('#update_section_ids_message').html(
'<i class="fa fa-refresh fa-spin"></i> PlexPy is updating library IDs in the database. This could take a few minutes depending on the size of your database.' + '<i class="fa fa-refresh fa-spin"></i> PlexPy is updating library IDs in the database. This could take a few minutes to hours depending on the size of your database.' +
'<br />' + '<br />' +
'You may leave this page and come back later.'); 'You may leave this page and come back later.');
$(this).prop('disabled', true); $(this).prop('disabled', true);

View File

@@ -14,9 +14,9 @@
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>. # along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
from plexpy import logger, database, helpers, common from plexpy import logger, database, helpers, common
import plexpy
import datetime import datetime
import locale
class Graphs(object): class Graphs(object):
@@ -321,7 +321,7 @@ class Graphs(object):
dt = datetime.datetime(*month_item[:6]) dt = datetime.datetime(*month_item[:6])
date_string = dt.strftime('%Y-%m') date_string = dt.strftime('%Y-%m')
categories.append(dt.strftime('%b %Y').decode(locale.getlocale()[1])) categories.append(dt.strftime('%b %Y').decode(plexpy.SYS_ENCODING, 'replace'))
series_1_value = 0 series_1_value = 0
series_2_value = 0 series_2_value = 0
series_3_value = 0 series_3_value = 0

View File

@@ -18,25 +18,28 @@ import plexpy
def update_section_ids(): def update_section_ids():
from plexpy import pmsconnect, activity_pinger from plexpy import pmsconnect, activity_pinger
import threading #import threading
plexpy.CONFIG.UPDATE_SECTION_IDS = -1 plexpy.CONFIG.UPDATE_SECTION_IDS = -1
logger.info(u"PlexPy Libraries :: Updating section_id's in database.") logger.info(u"PlexPy Libraries :: Updating section_id's in database.")
logger.debug(u"PlexPy Libraries :: Disabling monitoring while update in progress.") #logger.debug(u"PlexPy Libraries :: Disabling monitoring while update in progress.")
plexpy.schedule_job(activity_pinger.check_active_sessions, 'Check for active sessions', #plexpy.schedule_job(activity_pinger.check_active_sessions, 'Check for active sessions',
hours=0, minutes=0, seconds=0) # hours=0, minutes=0, seconds=0)
plexpy.schedule_job(activity_pinger.check_recently_added, 'Check for recently added items', #plexpy.schedule_job(activity_pinger.check_recently_added, 'Check for recently added items',
hours=0, minutes=0, seconds=0) # hours=0, minutes=0, seconds=0)
plexpy.schedule_job(activity_pinger.check_server_response, 'Check for server response', #plexpy.schedule_job(activity_pinger.check_server_response, 'Check for server response',
hours=0, minutes=0, seconds=0) # hours=0, minutes=0, seconds=0)
monitor_db = database.MonitorDatabase() monitor_db = database.MonitorDatabase()
try: try:
query = 'SELECT id, rating_key FROM session_history_metadata WHERE section_id IS NULL' query = 'SELECT id, rating_key, grandparent_rating_key, media_type ' \
result = monitor_db.select(query=query) 'FROM session_history_metadata WHERE section_id IS NULL'
history_results = monitor_db.select(query=query)
query = 'SELECT section_id, section_type FROM library_sections'
library_results = monitor_db.select(query=query)
except Exception as e: except Exception as e:
logger.warn(u"PlexPy Libraries :: Unable to execute database query for update_section_ids: %s." % e) logger.warn(u"PlexPy Libraries :: Unable to execute database query for update_section_ids: %s." % e)
@@ -44,36 +47,52 @@ def update_section_ids():
plexpy.CONFIG.__setattr__('UPDATE_SECTION_IDS', 1) plexpy.CONFIG.__setattr__('UPDATE_SECTION_IDS', 1)
plexpy.CONFIG.write() plexpy.CONFIG.write()
logger.debug(u"PlexPy Libraries :: Re-enabling monitoring.") #logger.debug(u"PlexPy Libraries :: Re-enabling monitoring.")
plexpy.initialize_scheduler() #plexpy.initialize_scheduler()
return None return None
# Add thread filter to the logger # Add thread filter to the logger
logger.debug(u"PlexPy Libraries :: Disabling logging in the current thread while update in progress.") #logger.debug(u"PlexPy Libraries :: Disabling logging in the current thread while update in progress.")
thread_filter = logger.NoThreadFilter(threading.current_thread().name) #thread_filter = logger.NoThreadFilter(threading.current_thread().name)
for handler in logger.logger.handlers: #for handler in logger.logger.handlers:
handler.addFilter(thread_filter) # handler.addFilter(thread_filter)
# Get rating_key: section_id mapping pairs
key_mappings = {}
pms_connect = pmsconnect.PmsConnect() pms_connect = pmsconnect.PmsConnect()
for library in library_results:
section_id = library['section_id']
section_type = library['section_type']
if section_type != 'photo':
library_children = pms_connect.get_library_children_details(section_id=section_id,
section_type=section_type)
if library_children:
children_list = library_children['childern_list']
key_mappings.update({child['rating_key']:child['section_id'] for child in children_list})
else:
logger.warn(u"PlexPy Libraries :: Unable to get a list of library items for section_id %s." % section_id)
error_keys = set() error_keys = set()
for item in result: for item in history_results:
id = item['id'] rating_key = item['grandparent_rating_key'] if item['media_type'] != 'movie' else item['rating_key']
rating_key = item['rating_key'] section_id = key_mappings.get(str(rating_key), None)
metadata = pms_connect.get_metadata_details(rating_key=rating_key)
if section_id:
if metadata: try:
metadata = metadata['metadata'] section_keys = {'id': item['id']}
section_keys = {'id': id} section_values = {'section_id': section_id}
section_values = {'section_id': metadata['section_id']} monitor_db.upsert('session_history_metadata', key_dict=section_keys, value_dict=section_values)
monitor_db.upsert('session_history_metadata', key_dict=section_keys, value_dict=section_values) except:
error_keys.add(item['rating_key'])
else: else:
error_keys.add(rating_key) error_keys.add(item['rating_key'])
# Remove thread filter from the logger # Remove thread filter from the logger
for handler in logger.logger.handlers: #for handler in logger.logger.handlers:
handler.removeFilter(thread_filter) # handler.removeFilter(thread_filter)
logger.debug(u"PlexPy Libraries :: Re-enabling logging in the current thread.") #logger.debug(u"PlexPy Libraries :: Re-enabling logging in the current thread.")
if error_keys: if error_keys:
logger.info(u"PlexPy Libraries :: Updated all section_id's in database except for rating_keys: %s." % logger.info(u"PlexPy Libraries :: Updated all section_id's in database except for rating_keys: %s." %
@@ -84,8 +103,8 @@ def update_section_ids():
plexpy.CONFIG.__setattr__('UPDATE_SECTION_IDS', 0) plexpy.CONFIG.__setattr__('UPDATE_SECTION_IDS', 0)
plexpy.CONFIG.write() plexpy.CONFIG.write()
logger.debug(u"PlexPy Libraries :: Re-enabling monitoring.") #logger.debug(u"PlexPy Libraries :: Re-enabling monitoring.")
plexpy.initialize_scheduler() #plexpy.initialize_scheduler()
return True return True

View File

@@ -795,8 +795,8 @@ def build_server_notify_text(state=None):
available_params = {'server_name': server_name, available_params = {'server_name': server_name,
'server_uptime': server_uptime, 'server_uptime': server_uptime,
'action': state, 'action': state,
'datestamp': time.strftime(helpers.parse_js_date(plexpy.CONFIG.DATE_FORMAT)), 'datestamp': arrow.now().format(plexpy.CONFIG.DATE_FORMAT.replace('Do','').replace('zz','')),
'timestamp': time.strftime(helpers.parse_js_date(plexpy.CONFIG.TIME_FORMAT))} 'timestamp': arrow.now().format(plexpy.CONFIG.TIME_FORMAT.replace('Do','').replace('zz',''))}
# Default text # Default text
subject_text = 'PlexPy (%s)' % server_name subject_text = 'PlexPy (%s)' % server_name

View File

@@ -72,10 +72,11 @@ def refresh_libraries():
plexpy.CONFIG.__setattr__('HOME_LIBRARY_CARDS', library_keys) plexpy.CONFIG.__setattr__('HOME_LIBRARY_CARDS', library_keys)
plexpy.CONFIG.write() plexpy.CONFIG.write()
if plexpy.CONFIG.UPDATE_SECTION_IDS == 1: if plexpy.CONFIG.UPDATE_SECTION_IDS == 1 or plexpy.CONFIG.UPDATE_SECTION_IDS == -1:
from plexpy import libraries from plexpy import libraries
import threading import threading
# Start library section_id update on it's own thread
threading.Thread(target=libraries.update_section_ids).start() threading.Thread(target=libraries.update_section_ids).start()
logger.info(u"PlexPy Pmsconnect :: Libraries list refreshed.") logger.info(u"PlexPy Pmsconnect :: Libraries list refreshed.")
@@ -1588,9 +1589,9 @@ class PmsConnect(object):
sort_type = '' sort_type = ''
if str(section_id).isdigit(): if str(section_id).isdigit():
library_data = self.get_library_list(section_id, list_type, count, sort_type, output_format='xml') library_data = self.get_library_list(str(section_id), list_type, count, sort_type, output_format='xml')
elif str(rating_key).isdigit(): elif str(rating_key).isdigit():
library_data = self.get_children_list(rating_key, output_format='xml') library_data = self.get_children_list(str(rating_key), output_format='xml')
else: else:
logger.warn(u"PlexPy Pmsconnect :: get_library_children called by invalid section_id or rating_key provided.") logger.warn(u"PlexPy Pmsconnect :: get_library_children called by invalid section_id or rating_key provided.")
return [] return []

View File

@@ -1,2 +1,2 @@
PLEXPY_VERSION = "master" PLEXPY_VERSION = "master"
PLEXPY_RELEASE_VERSION = "1.3.1" PLEXPY_RELEASE_VERSION = "1.3.3"