Improve calculation for transcode progress bar

This commit is contained in:
JonnyWong16 2022-02-13 11:59:06 -08:00
parent cfd1bf445f
commit 6d84d1b4c9
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 13 additions and 4 deletions

View file

@ -62,7 +62,7 @@ DOCUMENTATION :: END
% if session is not None:
<%
from collections import defaultdict
from plexpy.helpers import cast_to_int, page, short_season
from plexpy.helpers import cast_to_int, get_percent, page, short_season
from plexpy.common import VIDEO_RESOLUTION_OVERRIDES, AUDIO_CODEC_OVERRIDES, EXTRA_TYPES
import plexpy
%>
@ -392,7 +392,8 @@ DOCUMENTATION :: END
% if data['live']:
<div id="progress-bar-${sk}" class="progress-bar" style="width: 100%" data-state="live" data-toggle="tooltip" title="Stream Progress Live">Live</div>
% else:
<div id="buffer-bar-${sk}" class="buffer-bar" style="width: ${data['transcode_progress']}%" data-toggle="tooltip" title="Transcoder Progress ${data['transcode_progress']}%">${data['transcode_progress']}%</div>
<% transcode_progress = get_percent(data['transcode_max_offset_available'] * 1000, data['duration']) or data['transcode_progress'] %>
<div id="buffer-bar-${sk}" class="buffer-bar" style="width: ${transcode_progress}%" data-toggle="tooltip" title="Transcoder Progress ${transcode_progress}%">${transcode_progress}%</div>
<div id="progress-bar-${sk}" class="progress-bar" style="width: ${data['progress_percent']}%" data-last_view_offset="${data['view_offset']}" data-view_offset="${data['view_offset']}" data-stream_duration="${data['stream_duration']}" data-state="${data['state']}" data-toggle="tooltip" title="Stream Progress ${data['progress_percent']}%">${data['progress_percent']}%</div>
% endif
</div>

View file

@ -590,8 +590,10 @@
}
// Update the progress bars
$('#buffer-bar-' + key).css({width: parseInt(s.transcode_progress) + '%'}).html(s.transcode_progress + '%')
.attr('data-original-title', 'Transcoder Progress ' + s.transcode_progress + '%');
var duration = parseInt(s.duration);
var transcode_progress = duration ? Math.round(s.transcode_max_offset_available * 1000 / duration * 100) : s.transcode_progress;
$('#buffer-bar-' + key).css({width: parseInt(transcode_progress) + '%'}).html(transcode_progress + '%')
.attr('data-original-title', 'Transcoder Progress ' + transcode_progress + '%');
if (s.live !== 1) {
var progress_bar = $('#progress-bar-' + key);
progress_bar.data('state', s.state);