VERY EXPERIMENTAL CHANGES!

History logging is now under the hood. Disabled by default.
Write new database tables and upgrade old ones.
Provide more detail to get_activity.
This commit is contained in:
Tim 2015-07-11 22:10:45 +02:00
commit 9152fa01af
9 changed files with 596 additions and 89 deletions

View file

@ -233,7 +233,7 @@
<label for="monitoring_interval">Monitoring Interval</label>
<input type="text" data-parsley-type="integer" id="monitoring_interval" name="monitoring_interval" value="${config['monitoring_interval']}" size="5" data-parsley-min="30" data-parsley-trigger="change" required>
<p class="help-block">The interval (in seconds) PlexPy will ping your Plex Server. Min 30 seconds, Recommended 60 seconds. 0 to disable.</p>
<p><strong>Disabling monitoring will disable ALL notifications.</strong></p>
<p><strong>Disabling monitoring will disable ALL notifications and history logging.</strong></p>
</div>
</fieldset>
<div class="wellheader">
@ -252,13 +252,33 @@
</fieldset>
</div>
<div class="span4">
<div class="wellheader">
<h3>History Logging</h3>
</div>
<fieldset>
<div class="checkbox">
<input type="checkbox" id="video_logging_enable" name="video_logging_enable" value="1" ${config['video_logging_enable']}> Log Movies and TV
<p class="help-block">Keep records of all video items played from your Plex Media Server.</p>
</div>
<div class="form-group">
<label for="monitoring_interval">Ignore Interval</label>
<input type="text" data-parsley-type="integer" id="logging_ignore_interval" name="logging_ignore_interval" value="${config['logging_ignore_interval']}" size="5" data-parsley-min="30" data-parsley-trigger="change" required>
<p class="help-block">The interval (in seconds) PlexPy will wait for a video item to be active before logging it. 0 to disable.</p>
</div>
<div class="checkbox">
<input type="checkbox" id="music_logging_enable" name="music_logging_enable" value="1" ${config['music_logging_enable']}> Log Music
<p class="help-block">Keep records of all audio items played from your Plex Media Server. Experimental.</p>
</div>
</fieldset>
<div class="wellheader">
<h3>IP Logging</h3>
</div>
<fieldset>
<div class="checkbox">
<input type="checkbox" id="ip_logging_enable" name="ip_logging_enable" value="1" ${config['ip_logging_enable']}> Enable IP Logging
<p class="help-block">Enable this to attempt to log the IP address of the user. This currently does nothing useful.</p>
<p class="help-block">
Enable this to attempt to log the IP address of the user. Debug logging must be enabled and your log folder must be set in the PlexPy settings.
</p>
</div>
</fieldset>
</div>

View file

@ -15,30 +15,43 @@ data['sessions'] Returns an array containing session data
data[sessions] :: Usable parameters
== Global keys ==
session_key Returns a unique session id for the active stream
rating_key Returns the unique identifier for the media item.
type Returns the type of session. Either 'track', 'episode' or 'movie'.
thumb Returns the location of the item's thumbnail. Use with pms_image_proxy.
art Returns the location of the item's artwork
progress_percent Returns the current progress of the item. 0 to 100.
user Returns the name of the user owning the session.
user_id Returns the Plex user id if available.
machine_id Returns the machine id of the players being used.
friendly_name Returns the friendlly name of the user owning the session.
state Returns the state of the current session. Either 'playing', 'paused' or 'buffering'.
title Returns the name of the episode, movie or music track.
player Returns the name of the platform used to play the stream.
platform Returns the type of platform used to play the stream.
audio_decision Returns the audio transcode decision. Either 'transcode', 'copy' or 'direct play'.
audio_codec Returns the name of the audio codec.
audio_channels Returns the number of audio channels.
grandparent_title Returns the title of the item's grandparent.
parent_title Returns the title of the item's parent.
video_decision Returns the video transcode decision. Either 'transcode', 'copy' or 'direct play'.
video_codec Returns the name of the video codec.
height Returns the value of the video height.
width Returns the value of the video width.
indexes Returns true if the media has media indexes and are enabled
session_key Returns a unique session id for the active stream
rating_key Returns the unique identifier for the media item.
type Returns the type of session. Either 'track', 'episode' or 'movie'.
thumb Returns the location of the item's thumbnail. Use with pms_image_proxy.
bif_thumb Returns the location of the item's bif thumbnail. Use with pms_image_proxy.
art Returns the location of the item's artwork
progress_percent Returns the current progress of the item. 0 to 100.
user Returns the name of the user owning the session.
user_id Returns the Plex user id if available.
machine_id Returns the machine id of the players being used.
friendly_name Returns the friendlly name of the user owning the session.
state Returns the state of the current session. Either 'playing', 'paused' or 'buffering'.
title Returns the name of the episode, movie or music track.
player Returns the name of the platform used to play the stream.
platform Returns the type of platform used to play the stream.
audio_decision Returns the audio transcode decision. Either 'transcode', 'copy' or 'direct play'.
audio_codec Returns the name of the audio codec.
audio_channels Returns the number of audio channels.
grandparent_title Returns the title of the item's grandparent.
parent_title Returns the title of the item's parent.
video_decision Returns the video transcode decision. Either 'transcode', 'copy' or 'direct play'.
video_codec Returns the name of the video codec.
height Returns the value of the video height.
width Returns the value of the video width.
container Returns the value of the media container.
bitrate Returns the value of the media bitrate.
video_resolution Returns the value of the video resolution.
video_framerate Returns the value of the video framerate.
video_aspect_ratio Returns the value of the video aspect ratio.
transcode_audio_channels Returns the amount of audio channels if there is a transcode session.
transcode_audio_codec Returns the name of the audio codec if there is a transcode session.
transcode_video_codec Returns the name of the video codec if there is a transcode session.
transcode_width Returns the video width if there is a transcode session.
transcode_height Returns the video height if there is a transcode session.
transcode_container Returns the value of media container if there is a transcode session.
transcode_protocol Returns the value of media protocol if there is a transcode session.
indexes Returns true if the media has media indexes and are enabled
DOCUMENTATION :: END
</%doc>
@ -54,7 +67,7 @@ DOCUMENTATION :: END
</div>
% elif a['indexes']:
<div class="dashboard-activity-poster-face">
<img onload="fadeIn(this)" src="pms_image_proxy?img=${a['thumb']}&width=300&height=169" style="display: none;"/>
<img onload="fadeIn(this)" src="pms_image_proxy?img=${a['bif_thumb']}&width=300&height=169" style="display: none;"/>
</div>
% else:
<div class="dashboard-activity-poster-face">
@ -114,7 +127,11 @@ DOCUMENTATION :: END
Stream: <strong>Transcoding</strong>
% endif
<br/>
Audio: <strong>${a['audio_codec']} (${a['audio_channels']}ch)</strong>
% if a['audio_decision'] != 'direct play':
Audio: <strong>${a['transcode_audio_codec']} (${a['transcode_audio_channels']}ch)</strong>
% elif a['audio_decision'] == 'direct play':
Audio: <strong>${a['audio_codec']} (${a['audio_channels']}ch)</strong>
% endif
% elif a['type'] == 'episode' or a['type'] == 'movie' or a['type'] == 'clip':
% if a['video_decision'] == 'direct play':
Stream: <strong>Direct Play</strong>
@ -122,10 +139,19 @@ DOCUMENTATION :: END
Stream: <strong>Transcoding</strong>
% endif
<br/>
Video: <strong>${a['video_decision']} (${a['video_codec']})
(${a['width']}x${a['height']})</strong>
% if a['video_decision'] != 'direct play':
Video: <strong>${a['video_decision']} (${a['transcode_video_codec']})
(${a['transcode_width']}x${a['transcode_height']})</strong>
% elif a['audio_decision'] == 'direct play':
Video: <strong>${a['video_decision']} (${a['video_codec']})
(${a['width']}x${a['height']})</strong>
% endif
<br/>
Audio: <strong>${a['audio_decision']} (${a['audio_codec']}) (${a['audio_channels']}ch)</strong>
% if a['audio_decision'] != 'direct play':
Audio: <strong>${a['audio_decision']} ${a['transcode_audio_codec']} (${a['transcode_audio_channels']}ch)</strong>
% elif a['audio_decision'] == 'direct play':
Audio: <strong>${a['audio_codec']} (${a['audio_channels']}ch)</strong>
% endif
% endif
<br>
</div>

View file

@ -93,7 +93,7 @@ from plexpy import helpers
% endif
</div>
<div class="summary-content-duration">
Runtime <strong> ${data['duration']} mins</strong>
Runtime <strong> <span id="runtime">${data['duration']}</span> mins</strong>
</div>
<div class="summary-content-content-rating">
Rated <strong> ${data['content_rating']} </strong>
@ -287,5 +287,8 @@ from plexpy import helpers
</script>
% endif
<script>
$("#runtime").html(millisecondsToMinutes($("#runtime").html(), true));
</script>
% endif
</%def>

View file

@ -249,4 +249,28 @@ function humanTime(seconds) {
String.prototype.toProperCase = function () {
return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
};
};
function millisecondsToMinutes(ms, roundToMinute) {
console.log("Ms: " + ms)
if (ms > 0) {
seconds = ms / 1000;
minutes = seconds / 60;
if (roundToMinute) {
output = Math.round(minutes, 0)
} else {
minutesFloor = Math.floor(minutes);
secondsReal = Math.round((seconds - (minutesFloor * 60)),0);
if (secondsReal < 10) {
secondsReal = '0' + secondsReal;
}
output = minutesFloor + ':' + secondsReal;
}
return output;
} else {
return '0';
}
}