Add watch time and user stats to info pages (#1471)

* watch time stats for show

* watch time stats for movie

* User Stats for movies and shows

* implementation for missing media types

* cleanup

* no data + rescrict guest access implementation

Co-authored-by: herby2212 <jannes.nagel@gmx.de>
This commit is contained in:
herby2212 2021-10-22 02:33:29 +02:00 committed by GitHub
parent 22f4b33087
commit c6ff8940b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 322 additions and 1 deletions

View file

@ -539,6 +539,34 @@ DOCUMENTATION :: END
</div>
</div>
% endif
% if data['media_type'] in ('movie', 'show', 'season', 'episode', 'artist', 'album', 'track'):
<div class="col-md-12">
<div class="table-card-header">
<div class="header-bar">
<span><i class="fa fa-line-chart"></i> Global Stats</span>
</div>
</div>
<div class="table-card-back">
<div id="watch-time-stats" class="user-overview-stats-wrapper">
<div class='muted'><i class="fa fa-refresh fa-spin"></i> Loading data...</div>
<br>
</div>
</div>
</div>
<div class="col-md-12">
<div class="table-card-header">
<div class="header-bar">
<span><i class="fa fa-group"></i> User Stats</span>
</div>
</div>
<div class="table-card-back">
<div id="user-stats" class="user-player">
<div class='muted'><i class="fa fa-refresh fa-spin"></i> Loading data...</div>
<br>
</div>
</div>
</div>
% endif
<%
history_type = data['media_type'] in ('movie', 'show', 'season', 'episode', 'artist', 'album', 'track')
history_active = 'active' if history_type else ''
@ -894,6 +922,28 @@ DOCUMENTATION :: END
});
</script>
% endif
% if data['media_type'] in ('movie', 'show', 'season', 'episode', 'artist', 'album', 'track'):
<script>
// Populate watch time stats
$.ajax({
url: 'item_watch_time_stats',
async: true,
data: { rating_key: "${data['rating_key']}", media_type: "${data['media_type']}" },
complete: function(xhr, status) {
$("#watch-time-stats").html(xhr.responseText);
}
});
// Populate user stats
$.ajax({
url: 'item_user_stats',
async: true,
data: { rating_key: "${data['rating_key']}", media_type: "${data['media_type']}" },
complete: function(xhr, status) {
$("#user-stats").html(xhr.responseText);
}
});
</script>
% endif
% if data['media_type'] == 'collection':
<script>
$.ajax({