initial release for movie media type

This commit is contained in:
herby2212 2023-10-28 17:38:34 +02:00
parent 32cf26884b
commit 0fb362d4ee
4 changed files with 47 additions and 6 deletions

View file

@ -2940,6 +2940,12 @@ a .home-platforms-list-cover-face:hover
max-width: 1750px; max-width: 1750px;
display: flow-root; display: flow-root;
} }
.table-card-header.spaced {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
align-content: center;
}
.table-card-back td { .table-card-back td {
font-size: 12px; font-size: 12px;
} }
@ -2951,6 +2957,18 @@ a .home-platforms-list-cover-face:hover
font-weight: bold; font-weight: bold;
line-height: 34px; line-height: 34px;
} }
.info-bar {
display: inline;
}
.info-element {
display: inline-block;
border-radius: 1rem;
border: 0.2rem solid #242424;
padding: 0.7rem;
background-color: #3B3B3B;
font-style: italic;
color: #676767;
}
.button-bar { .button-bar {
float: right; float: right;
} }

View file

@ -271,7 +271,7 @@ DOCUMENTATION :: END
You may leave this page and check back later. You may leave this page and check back later.
</div> </div>
% endif % endif
<div class='table-card-header'> <div class='table-card-header spaced'>
<div class="header-bar"> <div class="header-bar">
<span> <span>
<i class="fa fa-info-circle"></i> Media Info for <strong> <i class="fa fa-info-circle"></i> Media Info for <strong>
@ -279,6 +279,16 @@ DOCUMENTATION :: END
</strong> </strong>
</span> </span>
</div> </div>
% if config['get_file_sizes'] and not data['section_id'] in config['get_file_sizes_hold']['section_ids']:
<div class="info-bar">
<div class="info-element">
<span>Total File Size: <strong><span id="info-element-total-file-size" /></strong></span>
</div>
<div class="info-element">
<span>Total Media Runtime: <strong><span id="info-element-total-media-runtime" /></strong></span>
</div>
</div>
% endif
<div class="button-bar"> <div class="button-bar">
% if _session['user_group'] == 'admin': % if _session['user_group'] == 'admin':
<div class="btn-group"> <div class="btn-group">
@ -842,6 +852,10 @@ DOCUMENTATION :: END
section_id: section_id, section_id: section_id,
refresh: refresh_table refresh: refresh_table
}; };
},
complete: function(xhr, status) {
$("#info-element-total-media-runtime").html(humanDuration(xhr.responseJSON.total_duration));
$("#info-element-total-file-size").html(humanFileSize(xhr.responseJSON.total_file_size));
} }
}; };
media_info_table = $('#media_info_table-SID-${data["section_id"]}').DataTable(media_info_table_options); media_info_table = $('#media_info_table-SID-${data["section_id"]}').DataTable(media_info_table_options);

View file

@ -517,8 +517,11 @@ class Libraries(object):
# Import media info cache from json file # Import media info cache from json file
cache_time, rows, library_count = self._load_media_info_cache(section_id=section_id, rating_key=rating_key) cache_time, rows, library_count = self._load_media_info_cache(section_id=section_id, rating_key=rating_key)
# Check if duration is also included in cache else refresh cache to prevent update issues
refresh = refresh if None not in {d.get('duration') for d in rows} else True
# If no cache was imported, get all library children items # If no cache was imported, get all library children items
cached_items = {d['rating_key']: d['file_size'] for d in rows} if not refresh else {} cached_items = {d['rating_key']: [d['file_size'], d['duration']] for d in rows} if not refresh else {}
if refresh or not rows: if refresh or not rows:
pms_connect = pmsconnect.PmsConnect() pms_connect = pmsconnect.PmsConnect()
@ -543,8 +546,10 @@ class Libraries(object):
for item in children_list: for item in children_list:
## TODO: Check list of media info items, currently only grabs first item ## TODO: Check list of media info items, currently only grabs first item
cached_file_size = cached_items.get(item['rating_key'], None) cached_item_data = cached_items.get(item['rating_key'], None)
file_size = cached_file_size if cached_file_size else item.get('file_size', '')
file_size = cached_item_data['file_size'] if cached_item_data else item.get('file_size', '')
duration = cached_item_data['duration'] if cached_item_data else item['duration']
row = {'section_id': library_details['section_id'], row = {'section_id': library_details['section_id'],
'section_type': library_details['section_type'], 'section_type': library_details['section_type'],
@ -566,7 +571,8 @@ class Libraries(object):
'video_framerate': item.get('video_framerate', ''), 'video_framerate': item.get('video_framerate', ''),
'audio_codec': item.get('audio_codec', ''), 'audio_codec': item.get('audio_codec', ''),
'audio_channels': item.get('audio_channels', ''), 'audio_channels': item.get('audio_channels', ''),
'file_size': file_size 'file_size': file_size,
'duration': duration
} }
new_rows.append(row) new_rows.append(row)
@ -624,6 +630,7 @@ class Libraries(object):
results = sorted(results, key=lambda k: k[sort_key].lower(), reverse=reverse) results = sorted(results, key=lambda k: k[sort_key].lower(), reverse=reverse)
total_file_size = sum([helpers.cast_to_int(d['file_size']) for d in results]) total_file_size = sum([helpers.cast_to_int(d['file_size']) for d in results])
total_duration = sum([helpers.cast_to_int(d['duration']) for d in results])
# Paginate results # Paginate results
results = results[json_data['start']:(json_data['start'] + json_data['length'])] results = results[json_data['start']:(json_data['start'] + json_data['length'])]
@ -637,6 +644,7 @@ class Libraries(object):
'draw': int(json_data['draw']), 'draw': int(json_data['draw']),
'filtered_file_size': filtered_file_size, 'filtered_file_size': filtered_file_size,
'total_file_size': total_file_size, 'total_file_size': total_file_size,
'total_duration': total_duration,
'last_refreshed': cache_time 'last_refreshed': cache_time
} }

View file

@ -2805,7 +2805,8 @@ class PmsConnect(object):
'thumb': helpers.get_xml_attr(item, 'thumb'), 'thumb': helpers.get_xml_attr(item, 'thumb'),
'parent_thumb': helpers.get_xml_attr(item, 'thumb'), 'parent_thumb': helpers.get_xml_attr(item, 'thumb'),
'grandparent_thumb': helpers.get_xml_attr(item, 'grandparentThumb'), 'grandparent_thumb': helpers.get_xml_attr(item, 'grandparentThumb'),
'added_at': helpers.get_xml_attr(item, 'addedAt') 'added_at': helpers.get_xml_attr(item, 'addedAt'),
'duration': helpers.get_xml_attr(item, 'duration')
} }
if get_media_info: if get_media_info: