mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Add setting to enable calculating total file sizes
* Setting is disabled by default
This commit is contained in:
parent
0d7e261bd1
commit
1809b95e2d
9 changed files with 71 additions and 43 deletions
BIN
data/interfaces/default/images/media_info/576.png
Normal file
BIN
data/interfaces/default/images/media_info/576.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
data/interfaces/default/images/media_info/8ch.png
Normal file
BIN
data/interfaces/default/images/media_info/8ch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
|
@ -10,7 +10,6 @@ $.ajax({
|
|||
}
|
||||
});
|
||||
|
||||
var get_file_sizes = false;
|
||||
var refresh_child_tables = false;
|
||||
|
||||
media_info_table_options = {
|
||||
|
@ -24,7 +23,7 @@ media_info_table_options = {
|
|||
"emptyTable": "No data in table"
|
||||
},
|
||||
"pagingType": "bootstrap",
|
||||
"stateSave": true,
|
||||
"stateSave": false,
|
||||
"processing": false,
|
||||
"serverSide": true,
|
||||
"pageLength": 25,
|
||||
|
@ -102,7 +101,7 @@ media_info_table_options = {
|
|||
}
|
||||
}
|
||||
},
|
||||
"width": "24%"
|
||||
"width": "20%"
|
||||
},
|
||||
{
|
||||
"targets": [2],
|
||||
|
@ -112,7 +111,7 @@ media_info_table_options = {
|
|||
$(td).html(cellData);
|
||||
}
|
||||
},
|
||||
"width": "5%",
|
||||
"width": "6%",
|
||||
"className": "no-wrap hidden-sm hidden-xs"
|
||||
},
|
||||
{
|
||||
|
@ -123,7 +122,7 @@ media_info_table_options = {
|
|||
$(td).html(cellData + ' kbps');
|
||||
}
|
||||
},
|
||||
"width": "5%",
|
||||
"width": "6%",
|
||||
"className": "no-wrap hidden-md hidden-sm hidden-xs",
|
||||
"searchable": false
|
||||
},
|
||||
|
@ -189,7 +188,9 @@ media_info_table_options = {
|
|||
if (cellData !== null && cellData !== '') {
|
||||
$(td).html(Math.round(cellData / Math.pow(1024, 2)).toString() + ' MiB');
|
||||
} else {
|
||||
if (rowData['section_type'] != 'photo') { get_file_sizes = true; }
|
||||
if (rowData['section_type'] != 'photo' && get_file_sizes != null) {
|
||||
get_file_sizes = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
"width": "7%",
|
||||
|
@ -375,6 +376,7 @@ function childTableOptionsMedia(rowData) {
|
|||
createChildTableMedia(this, childrowData)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (get_file_sizes) {
|
||||
$('#refresh-media-info-table').prop('disabled', true);
|
||||
|
@ -395,7 +397,6 @@ function childTableOptionsMedia(rowData) {
|
|||
});
|
||||
get_file_sizes = false;
|
||||
}
|
||||
}
|
||||
|
||||
$(this).closest('div.slider').slideDown();
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ DOCUMENTATION :: END
|
|||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
% if data['section_id'] in config['get_file_sizes']['section_ids']:
|
||||
% if config['get_file_sizes'] and data['section_id'] in config['get_file_sizes_hold']['section_ids']:
|
||||
<div id="get_file_sizes_message" style="text-align: center; margin-top: 20px;">
|
||||
% else:
|
||||
<div id="get_file_sizes_message" style="text-align: center; margin-top: 20px; display: none;">
|
||||
|
@ -214,7 +214,7 @@ DOCUMENTATION :: END
|
|||
</span>
|
||||
</div>
|
||||
<div class="button-bar">
|
||||
% if data['section_id'] in config['get_file_sizes']['section_ids']:
|
||||
% if config['get_file_sizes'] and data['section_id'] in config['get_file_sizes_hold']['section_ids']:
|
||||
<button class="btn btn-dark refresh-media-info-table-button" id="refresh-media-info-table" style="margin-right: 5px;" disabled>
|
||||
<i class="fa fa-refresh"></i> Refresh media info
|
||||
</button>
|
||||
|
@ -316,6 +316,12 @@ DOCUMENTATION :: END
|
|||
% endif
|
||||
var section_name = '${data['section_name'].replace("'", "\\'")}';
|
||||
var refresh_table = false;
|
||||
|
||||
% if config['get_file_sizes']:
|
||||
var get_file_sizes = false;
|
||||
% else:
|
||||
var get_file_sizes = null;
|
||||
% endif
|
||||
</script>
|
||||
<script src="interfaces/default/js/moment-with-locale.js"></script>
|
||||
<script src="interfaces/default/js/tables/history_table.js"></script>
|
||||
|
|
|
@ -89,5 +89,5 @@ DOCUMENTATION :: END
|
|||
% endfor
|
||||
</ul>
|
||||
% else:
|
||||
<div class="text-muted">No stats to show for the selected period.</div><br>
|
||||
<div class="text-muted">No stats to show.</div><br>
|
||||
% endif
|
|
@ -453,6 +453,13 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
</label>
|
||||
<p class="help-block">If you have media indexing enabled on your server, use these on the activity pane.</p>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="get_file_sizes" name="get_file_sizes" value="1" ${config['get_file_sizes']}> Calculate Total File Sizes [experimental]
|
||||
</label>
|
||||
<p class="help-block">Enable if you want PlexPy to calculate the total file size for TV Shows/Seasons and Artists/Albums on the media info tables.<br />
|
||||
This is currently experimental.</p>
|
||||
</div>
|
||||
|
||||
<div class="padded-header">
|
||||
<h3>PlexWatch Import Tool</h3>
|
||||
|
@ -478,9 +485,10 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" class="monitor-settings" id="monitoring_use_websocket" name="monitoring_use_websocket" value="1" ${config['monitoring_use_websocket']}> Use Websocket (requires restart)
|
||||
<input type="checkbox" class="monitor-settings" id="monitoring_use_websocket" name="monitoring_use_websocket" value="1" ${config['monitoring_use_websocket']}> Use Websocket (requires restart) [experimental]
|
||||
</label>
|
||||
<p class="help-block">Instead of polling the server at regular intervals let the server tell us when something happens. This is currently experimental. Encrypted websocket is not currently supported.</p>
|
||||
<p class="help-block">Instead of polling the server at regular intervals let the server tell us when something happens.<br />
|
||||
This is currently experimental. Encrypted websocket is not currently supported.</p>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
|
|
|
@ -97,7 +97,8 @@ _CONFIG_DEFINITIONS = {
|
|||
'FACEBOOK_ON_INTUP': (int, 'Facebook', 0),
|
||||
'FIRST_RUN_COMPLETE': (int, 'General', 0),
|
||||
'FREEZE_DB': (int, 'General', 0),
|
||||
'GET_FILE_SIZES': (dict, 'General', {'section_ids': [], 'rating_keys': []}),
|
||||
'GET_FILE_SIZES': (int, 'General', 0),
|
||||
'GET_FILE_SIZES_HOLD': (dict, 'General', {'section_ids': [], 'rating_keys': []}),
|
||||
'GIT_BRANCH': (str, 'General', 'master'),
|
||||
'GIT_PATH': (str, 'General', ''),
|
||||
'GIT_USER': (str, 'General', 'drzoidberg33'),
|
||||
|
|
|
@ -242,7 +242,7 @@ class Libraries(object):
|
|||
# Import media info cache from json file
|
||||
if rating_key:
|
||||
try:
|
||||
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s_%s.json' % (section_id, rating_key))
|
||||
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info_%s-%s.json' % (section_id, rating_key))
|
||||
with open(inFilePath, 'r') as inFile:
|
||||
rows = json.load(inFile)
|
||||
library_count = len(rows)
|
||||
|
@ -252,7 +252,7 @@ class Libraries(object):
|
|||
pass
|
||||
elif section_id:
|
||||
try:
|
||||
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s.json' % section_id)
|
||||
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info_%s.json' % section_id)
|
||||
with open(inFilePath, 'r') as inFile:
|
||||
rows = json.load(inFile)
|
||||
library_count = len(rows)
|
||||
|
@ -314,13 +314,19 @@ class Libraries(object):
|
|||
|
||||
# Cache the media info to a json file
|
||||
if rating_key:
|
||||
outFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s_%s.json' % (section_id, rating_key))
|
||||
try:
|
||||
outFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info_%s-%s.json' % (section_id, rating_key))
|
||||
with open(outFilePath, 'w') as outFile:
|
||||
json.dump(rows, outFile)
|
||||
except IOError as e:
|
||||
logger.debug(u"PlexPy Libraries :: Unable to create cache file for rating_key %s." % rating_key)
|
||||
elif section_id:
|
||||
outFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s.json' % section_id)
|
||||
try:
|
||||
outFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info_%s.json' % section_id)
|
||||
with open(outFilePath, 'w') as outFile:
|
||||
json.dump(rows, outFile)
|
||||
except IOError as e:
|
||||
logger.debug(u"PlexPy Libraries :: Unable to create cache file for section_id %s." % section_id)
|
||||
|
||||
# Update the last_watched and play_count
|
||||
for item in rows:
|
||||
|
@ -407,7 +413,7 @@ class Libraries(object):
|
|||
if rating_key:
|
||||
#logger.debug(u"PlexPy Libraries :: Getting file sizes for rating_key %s." % rating_key)
|
||||
try:
|
||||
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s_%s.json' % (section_id, rating_key))
|
||||
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info_%s-%s.json' % (section_id, rating_key))
|
||||
with open(inFilePath, 'r') as inFile:
|
||||
rows = json.load(inFile)
|
||||
except IOError as e:
|
||||
|
@ -417,7 +423,7 @@ class Libraries(object):
|
|||
elif section_id:
|
||||
logger.debug(u"PlexPy Libraries :: Getting file sizes for section_id %s." % section_id)
|
||||
try:
|
||||
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s.json' % section_id)
|
||||
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info_%s.json' % section_id)
|
||||
with open(inFilePath, 'r') as inFile:
|
||||
rows = json.load(inFile)
|
||||
except IOError as e:
|
||||
|
@ -426,32 +432,37 @@ class Libraries(object):
|
|||
pass
|
||||
|
||||
# Get the total file size for each item
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
|
||||
for item in rows:
|
||||
if item['rating_key'] and not item['file_size']:
|
||||
file_size = 0
|
||||
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
child_metadata = pms_connect.get_metadata_children_details(rating_key=item['rating_key'],
|
||||
get_children=True,
|
||||
get_media_info=True)
|
||||
metadata_list = child_metadata['metadata']
|
||||
|
||||
for child_metadata in metadata_list:
|
||||
child_file_size = helpers.cast_to_int(child_metadata.get('file_size', 0))
|
||||
if child_file_size > 0:
|
||||
file_size += child_file_size
|
||||
file_size += helpers.cast_to_int(child_metadata.get('file_size', 0))
|
||||
|
||||
item['file_size'] = file_size
|
||||
|
||||
# Cache the media info to a json file
|
||||
if rating_key:
|
||||
outFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s_%s.json' % (section_id, rating_key))
|
||||
try:
|
||||
outFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info_%s-%s.json' % (section_id, rating_key))
|
||||
with open(outFilePath, 'w') as outFile:
|
||||
json.dump(rows, outFile)
|
||||
except IOError as e:
|
||||
logger.debug(u"PlexPy Libraries :: Unable to create cache file with file sizes for rating_key %s." % rating_key)
|
||||
elif section_id:
|
||||
outFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s.json' % section_id)
|
||||
try:
|
||||
outFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info_%s.json' % section_id)
|
||||
with open(outFilePath, 'w') as outFile:
|
||||
json.dump(rows, outFile)
|
||||
except IOError as e:
|
||||
logger.debug(u"PlexPy Libraries :: Unable to create cache file with file sizes for section_id %s." % section_id)
|
||||
|
||||
if rating_key:
|
||||
#logger.debug(u"PlexPy Libraries :: File sizes updated for rating_key %s." % rating_key)
|
||||
|
@ -461,7 +472,6 @@ class Libraries(object):
|
|||
|
||||
return True
|
||||
|
||||
|
||||
def set_config(self, section_id=None, custom_thumb='', do_notify=1, keep_history=1, do_notify_created=1):
|
||||
if section_id:
|
||||
monitor_db = database.MonitorDatabase()
|
||||
|
|
|
@ -258,7 +258,8 @@ class WebInterface(object):
|
|||
@cherrypy.expose
|
||||
def library(self, section_id=None):
|
||||
config = {
|
||||
"get_file_sizes": plexpy.CONFIG.GET_FILE_SIZES
|
||||
"get_file_sizes": plexpy.CONFIG.GET_FILE_SIZES,
|
||||
"get_file_sizes_hold": plexpy.CONFIG.GET_FILE_SIZES_HOLD
|
||||
}
|
||||
|
||||
library_data = libraries.Libraries()
|
||||
|
@ -376,16 +377,16 @@ class WebInterface(object):
|
|||
|
||||
@cherrypy.expose
|
||||
def get_media_info_file_sizes(self, section_id=None, rating_key=None):
|
||||
get_file_sizes = plexpy.CONFIG.GET_FILE_SIZES
|
||||
section_ids = set(get_file_sizes['section_ids'])
|
||||
rating_keys = set(get_file_sizes['rating_keys'])
|
||||
get_file_sizes_hold = plexpy.CONFIG.GET_FILE_SIZES_HOLD
|
||||
section_ids = set(get_file_sizes_hold['section_ids'])
|
||||
rating_keys = set(get_file_sizes_hold['rating_keys'])
|
||||
|
||||
if (section_id and section_id not in section_ids) or (rating_key and rating_key not in rating_keys):
|
||||
if section_id:
|
||||
section_ids.add(section_id)
|
||||
elif rating_key:
|
||||
rating_keys.add(rating_key)
|
||||
plexpy.CONFIG.GET_FILE_SIZES = {'section_ids': list(section_ids), 'rating_keys': list(rating_keys)}
|
||||
plexpy.CONFIG.GET_FILE_SIZES_HOLD = {'section_ids': list(section_ids), 'rating_keys': list(rating_keys)}
|
||||
|
||||
library_data = libraries.Libraries()
|
||||
result = library_data.get_media_info_file_sizes(section_id=section_id,
|
||||
|
@ -395,7 +396,7 @@ class WebInterface(object):
|
|||
section_ids.remove(section_id)
|
||||
elif rating_key:
|
||||
rating_keys.remove(rating_key)
|
||||
plexpy.CONFIG.GET_FILE_SIZES = {'section_ids': list(section_ids), 'rating_keys': list(rating_keys)}
|
||||
plexpy.CONFIG.GET_FILE_SIZES_HOLD = {'section_ids': list(section_ids), 'rating_keys': list(rating_keys)}
|
||||
else:
|
||||
result = False
|
||||
|
||||
|
@ -476,8 +477,8 @@ class WebInterface(object):
|
|||
|
||||
@cherrypy.expose
|
||||
def delete_datatable_media_info_cache(self, section_id, **kwargs):
|
||||
get_file_sizes = plexpy.CONFIG.GET_FILE_SIZES
|
||||
section_ids = set(get_file_sizes['section_ids'])
|
||||
get_file_sizes_hold = plexpy.CONFIG.GET_FILE_SIZES_HOLD
|
||||
section_ids = set(get_file_sizes_hold['section_ids'])
|
||||
|
||||
if section_id not in section_ids:
|
||||
if section_id:
|
||||
|
@ -1049,6 +1050,7 @@ class WebInterface(object):
|
|||
"pms_uuid": plexpy.CONFIG.PMS_UUID,
|
||||
"date_format": plexpy.CONFIG.DATE_FORMAT,
|
||||
"time_format": plexpy.CONFIG.TIME_FORMAT,
|
||||
"get_file_sizes": checked(plexpy.CONFIG.GET_FILE_SIZES),
|
||||
"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),
|
||||
|
@ -1122,7 +1124,7 @@ class WebInterface(object):
|
|||
# Handle the variable config options. Note - keys with False values aren't getting passed
|
||||
|
||||
checked_configs = [
|
||||
"launch_browser", "enable_https", "api_enabled", "freeze_db", "check_github",
|
||||
"launch_browser", "enable_https", "api_enabled", "freeze_db", "check_github", "get_file_sizes",
|
||||
"grouping_global_history", "grouping_user_history", "grouping_charts", "pms_use_bif", "pms_ssl",
|
||||
"movie_notify_enable", "tv_notify_enable", "music_notify_enable", "monitoring_use_websocket",
|
||||
"tv_notify_on_start", "movie_notify_on_start", "music_notify_on_start",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue