List sorting setting, intro/outro change

- Disable/enable Tautulli grouping
- Intro/Outro split into titles and subtitles
- Disable sort by plays/duration
- Sort by button removed if just one sorting is enabled
This commit is contained in:
aunefyren 2022-01-20 20:20:26 +01:00
parent 5587681f73
commit 320be2ae31
10 changed files with 609 additions and 174 deletions

View file

@ -5,7 +5,7 @@ A website-based platform and API for collecting user stats within a set timefram
<br>
![alt text](https://raw.githubusercontent.com/aunefyren/wrapperr/main/assets/img/example_01.PNG?raw=true)
![Image showing the introduction section of Wrapperr.](https://raw.githubusercontent.com/aunefyren/wrapperr/main/assets/img/example_01.PNG?raw=true)
<br>
@ -22,7 +22,7 @@ A website-based platform and API for collecting user stats within a set timefram
<br>
![alt text](https://raw.githubusercontent.com/aunefyren/wrapperr/main/assets/img/example_02.PNG?raw=true)
![Image showing the show section of Wrapperr.](https://raw.githubusercontent.com/aunefyren/wrapperr/main/assets/img/example_02.PNG?raw=true)
<br>
@ -34,7 +34,7 @@ A website-based platform and API for collecting user stats within a set timefram
<br>
![alt text](https://raw.githubusercontent.com/aunefyren/wrapperr/main/assets/img/example_03.PNG?raw=true)
![Image showing the server-wide section of Wrapperr.](https://raw.githubusercontent.com/aunefyren/wrapperr/main/assets/img/example_03.PNG?raw=true)
<br>
@ -158,7 +158,20 @@ In your ```php.ini``` file you may have to change:
<br>
<br>
## Frequently asked questions
### Q: Why are the plays different on Wrapperr compared to Tautulli
A: Data is retrieved from the Tautulli API, but not necasserly proccessed in the same manner. The difference could for example be that you have history entries for the same media (movie for example) split over different Tautulli items. For example you could have two items for the movie 'Black Widow' from potentially updating the file on Plex, leading Tautulli to interperet it as a new item/media. The easiest way to test this is by going to the 'History' tab and searching for the title. This might display more entries than clicking into the movie item, which displays all history items for that particular item.
There is an option to merge different Tautulli items if this is your case.
What also could cause confusion is related to Tautulli grouping feature. When you have grouping enabled, different plays are grouped on an API call basis. Meaning that when you display all history items for a movie on Tautulli, six different plays spanning three days might be placed into one group. Wrapperr calls the Tautulli API on a day basis, meaning grouping never spans multiple days, potentially leading to an increase in plays.
<br>
<br>
## Need help?
If you have any issues feel free to contact me. I am always trying to improve the project. If I can't, many people on several forums (including [/r/plex](https://www.reddit.com/r/plex)) might be able to assist you.
Have fun.
Have fun.

View file

@ -386,6 +386,9 @@ function set_tautulli_settings() {
html += '</div>';
html += '<div class="form-group newline">';
html += '</div>';
html += '<div class="form-group">';
html += '<label for="https" title="Enable if your connection uses HTTPS.">Use HTTPS:</label>';
html += '<input type="checkbox" class="form-control" id="https" ';
if(https) {
@ -394,6 +397,15 @@ function set_tautulli_settings() {
html += '/><br>';
html += '</div>';
html += '<div class="form-group">';
html += '<label for="tautulli_grouping" title="If Tautulli should group related plays into one entry.">Use Tautulli grouping:</label>';
html += '<input type="checkbox" class="form-control" id="tautulli_grouping" ';
if(tautulli_grouping) {
html += 'checked="' + tautulli_grouping + '" ';
}
html += '/><br>';
html += '</div>';
html += '<div class="form-group newline">';
html += '<button style="background-color: lightgrey;" type="button" class="form-control btn" id="test_connection" onclick="test_tautulli_connection()"><img src="../assets/synchronize.svg" class="btn_logo"><p2 id="test_tautulli_text">Test Tautulli connection</p2></button>';
html += '</div>';
@ -418,6 +430,7 @@ function set_tautulli_settings_call() {
tautulli_length = document.getElementById('tautulli_length').value;
tautulli_root = document.getElementById('tautulli_root').value;
tautulli_libraries = document.getElementById('tautulli_libraries').value;
tautulli_grouping = document.getElementById('tautulli_grouping').checked;
https = document.getElementById('https').checked;
if(tautulli_apikey === '') {
@ -455,6 +468,7 @@ function set_tautulli_settings_call() {
"tautulli_length" : tautulli_length,
"tautulli_root" : tautulli_root,
"tautulli_libraries" : tautulli_libraries,
"tautulli_grouping" : tautulli_grouping,
"https" : https
}
};
@ -705,9 +719,36 @@ function set_wrapperr_customization() {
html += '<hr>';
html += '</div>';
html += '<div class="form-group">';
html += '<label for="stats_order_by_plays" title="Whether top lists can be ordered by plays.">Order lists by plays:<br>';
html += '<input type="checkbox" class="form-control" id="stats_order_by_plays" ';
if(stats_order_by_plays) {
html += 'checked="' + stats_order_by_plays + '" ';
}
html += '/><br>';
html += '</div>';
html += '<div class="form-group">';
html += '<label for="stats_order_by_duration" title="Whether top lists can be ordered by duration. Automatically enabled if Wrapperr can\'t order by plays.">Order lists by duration:<br>';
html += '<input type="checkbox" class="form-control" id="stats_order_by_duration" ';
if(stats_order_by_duration) {
html += 'checked="' + stats_order_by_duration + '" ';
}
html += '/><br>';
html += '</div>';
html += '<div class="form-group newline">';
html += '<label for="stats_intro" title="Introduction text that is shown when the statistics are done loading. Could be used to inform about chosen timeframe. HTML allowed.">Introduction for statistics page:<br>';
html += '<textarea cols="40" rows="5" class="form-control" style="overflow-x: hidden;resize:vertical;min-height: 5em;" id="stats_intro" name="stats_intro" value="" autocomplete="off"></textarea></label>';
html += '<hr>';
html += '</div>';
html += '<div class="form-group">';
html += '<label for="stats_intro_title" title="Introduction title that is shown when the statistics are done loading.">Introduction title for statistics page:<br>';
html += '<textarea cols="40" rows="5" class="form-control" style="overflow-x: hidden;resize:vertical;min-height: 5em;" id="stats_intro_title" name="stats_intro_title" value="" autocomplete="off"></textarea></label>';
html += '</div>';
html += '<div class="form-group">';
html += '<label for="stats_intro_subtitle" title="Introduction subtitle text that is shown when the statistics are done loading. Could be used to inform about chosen timeframe.">Introduction subtitle for statistics page:<br>';
html += '<textarea cols="40" rows="5" class="form-control" style="overflow-x: hidden;resize:vertical;min-height: 5em;" id="stats_intro_subtitle" name="stats_intro_subtitle" value="" autocomplete="off"></textarea></label>';
html += '</div>';
html += '<div class="form-group newline">';
@ -1283,9 +1324,14 @@ function set_wrapperr_customization() {
html += '<hr>';
html += '</div>';
html += '<div class="form-group newline">';
html += '<label for="stats_outro" title="Text that is shown at the bottom, when the statistics are done. HTML allowed.">Outro for statistics page:<br>';
html += '<textarea cols="40" rows="5" class="form-control" style="overflow-x: hidden;resize:vertical;min-height: 5em;" id="stats_outro" name="stats_outro" value="" autocomplete="off"></textarea></label>';
html += '<div class="form-group">';
html += '<label for="stats_outro_title" title="Title that is shown at the bottom, when the statistics are done.">Outro title for statistics page:<br>';
html += '<textarea cols="40" rows="5" class="form-control" style="overflow-x: hidden;resize:vertical;min-height: 5em;" id="stats_outro_title" name="stats_outro_title" value="" autocomplete="off"></textarea></label>';
html += '</div>';
html += '<div class="form-group">';
html += '<label for="stats_outro_subtitle" title="Subtitle that is shown at the bottom, when the statistics are done.">Outro subtitle for statistics page:<br>';
html += '<textarea cols="40" rows="5" class="form-control" style="overflow-x: hidden;resize:vertical;min-height: 5em;" id="stats_outro_subtitle" name="stats_outro_subtitle" value="" autocomplete="off"></textarea></label>';
html += '</div>';
html += '<div class="form-group newline">';
@ -1411,8 +1457,10 @@ function set_wrapperr_customization() {
// Place content from config
document.getElementById("setup").innerHTML = html;
document.getElementById("stats_intro").value = stats_intro;
document.getElementById("stats_outro").value = stats_outro;
document.getElementById("stats_intro_title").value = stats_intro_title;
document.getElementById("stats_intro_subtitle").value = stats_intro_subtitle;
document.getElementById("stats_outro_title").value = stats_outro_title;
document.getElementById("stats_outro_subtitle").value = stats_outro_subtitle;
document.getElementById("get_user_movie_stats_title").value = get_user_movie_stats_title;
document.getElementById("get_user_movie_stats_subtitle").value = get_user_movie_stats_subtitle;
@ -1492,8 +1540,12 @@ function set_wrapperr_customization_call() {
wrapped_start = new Date(document.getElementById('wrapped_start').value);
wrapped_end = new Date(document.getElementById('wrapped_end').value);
stats_intro = document.getElementById('stats_intro').value;
stats_outro = document.getElementById('stats_outro').value;
stats_intro_title = document.getElementById('stats_intro_title').value;
stats_intro_subtitle = document.getElementById('stats_intro_subtitle').value;
stats_outro_title = document.getElementById('stats_outro_title').value;
stats_outro_subtitle = document.getElementById('stats_outro_subtitle').value;
stats_order_by_plays = document.getElementById('stats_order_by_plays').checked;
stats_order_by_duration = document.getElementById('stats_order_by_duration').checked;
get_user_movie_stats = document.getElementById('get_user_movie_stats').checked;
get_user_movie_stats_title = document.getElementById('get_user_movie_stats_title').value;
@ -1619,8 +1671,12 @@ function set_wrapperr_customization_call() {
"data" : {
"wrapped_start" : Math.round(wrapped_start.getTime() / 1000),
"wrapped_end" : Math.round(wrapped_end.getTime() / 1000),
"stats_intro" : stats_intro,
"stats_outro" : stats_outro,
"stats_intro_title" : stats_intro_title,
"stats_intro_subtitle" : stats_intro_subtitle,
"stats_outro_title" : stats_outro_title,
"stats_outro_subtitle" : stats_outro_subtitle,
"stats_order_by_plays" : stats_order_by_plays,
"stats_order_by_duration" : stats_order_by_duration,
"get_user_movie_stats" : get_user_movie_stats,
"get_user_movie_stats_title" : get_user_movie_stats_title,
"get_user_movie_stats_subtitle" : get_user_movie_stats_subtitle,
@ -2086,11 +2142,16 @@ function get_config(cookie) {
tautulli_length = result.data.tautulli_length;
tautulli_root = result.data.tautulli_root;
tautulli_libraries = result.data.tautulli_libraries;
tautulli_grouping = result.data.tautulli_grouping;
https = result.data.https;
timezone = result.data.timezone;
stats_intro = result.data.stats_intro;
stats_outro = result.data.stats_outro;
stats_intro_title = result.data.stats_intro_title;
stats_intro_subtitle = result.data.stats_intro_subtitle;
stats_outro_title = result.data.stats_outro_title;
stats_outro_subtitle = result.data.stats_outro_subtitle;
stats_order_by_plays = result.data.stats_order_by_plays;
stats_order_by_duration = result.data.stats_order_by_duration;
create_share_links = result.data.create_share_links;
use_plex_auth = result.data.use_plex_auth;
use_cache = result.data.use_cache;

View file

@ -55,6 +55,7 @@ var tautulli_port = '';
var tautulli_length = '';
var tautulli_root = '';
var tautulli_libraries = '';
var tautulli_grouping = '';
var https = '';
var password = '';
@ -64,8 +65,12 @@ var timezone = '';
var use_plex_auth = '';
var use_cache = '';
var use_logs = '';
var stats_intro = '';
var stats_outro = '';
var stats_intro_title = '';
var stats_intro_subtitle = '';
var stats_outro_title = '';
var stats_outro_subtitle = '';
var stats_order_by_plays = '';
var stats_order_by_duration = '';
var client_id = '';
var wrapperr_root = '';
var application_name_str = '';

View file

@ -94,8 +94,12 @@ $functions_json = array("wrapperr_version" => $config->wrapperr_version,
"get_year_stats_leaderboard" => $config->get_year_stats_leaderboard,
"get_year_stats_leaderboard_title" => $config->get_year_stats_leaderboard_title,
"get_year_stats_duration_sum_title" => $config->get_year_stats_duration_sum_title,
"stats_intro" => $config->stats_intro,
"stats_outro" => $config->stats_outro,
"stats_intro_title" => $config->stats_intro_title,
"stats_intro_subtitle" => $config->stats_intro_subtitle,
"stats_outro_title" => $config->stats_outro_title,
"stats_outro_subtitle" => $config->stats_outro_subtitle,
"stats_order_by_plays" => $config->stats_order_by_plays,
"stats_order_by_duration" => $config->stats_order_by_duration,
"create_share_links" => $config->create_share_links,
"wrapperr_and" => $config->wrapperr_and,
"wrapperr_play" => $config->wrapperr_play,

View file

@ -292,11 +292,17 @@ if($config->get_user_movie_stats || $config->get_user_show_stats || $config->get
}
// Get show buddy if enabled, shows are not empty, and shows is enabled.
if($config->get_year_stats_shows && $config->get_user_show_stats_buddy && count($user_shows["data"]["shows_duration"]) > 0) {
if($config->get_year_stats_shows && $config->get_user_show_stats_buddy && (@count($user_shows["data"]["shows_duration"]) > 0 || @count($user_shows["data"]["shows_plays"]) > 0)) {
// Log show-buddy action
$log->log_activity('get_stats.php', $id, 'Getting show-buddy.');
$user_shows["data"] = $user_shows["data"] + array("show_buddy" => data_get_user_show_buddy($id, $user_shows["data"]["shows_duration"][0]["title"], $tautulli_data));
if($user_shows["data"]["shows_duration"] !== false) {
$show_title = $user_shows["data"]["shows_duration"][0]["title"];
} else {
$show_title = $user_shows["data"]["shows_plays"][0]["title"];
}
$user_shows["data"] = $user_shows["data"] + array("show_buddy" => data_get_user_show_buddy($id, $show_title, $tautulli_data));
} else {
// Log show-buddy action
$log->log_activity('get_stats.php', $id, 'Show-buddy disabled.');
@ -611,7 +617,8 @@ function tautulli_get_wrapped_dates($id, $array, $loop_interval) {
global $log;
global $arrContextOptions;
$end_loop_date = $config->wrapped_end;
$end_loop_date = new DateTime("@$config->wrapped_end"); // DateTime object of end of wrapped date
$end_loop_date->setTimezone(new DateTimeZone($config->timezone)); // Set the timezone
if($loop_interval == 0) {
$loop_interval = False;
@ -626,14 +633,16 @@ function tautulli_get_wrapped_dates($id, $array, $loop_interval) {
}
for ($loop_time = $config->wrapped_start; $loop_time <= $end_loop_date; $loop_time += 86400) {
for ($loop_time = new DateTime("@$config->wrapped_start", new DateTimeZone($config->timezone)); $loop_time <= $end_loop_date; $loop_time->modify("+1 days")) {
$current_loop_date = date('Y-m-d', $loop_time);
$loop_time->setTimezone(new DateTimeZone($config->timezone)); // Set the timezone
$current_loop_date = $loop_time->format('Y-m-d');
$now = new DateTime('NOW');
$then = new DateTime($current_loop_date);
$then = clone $loop_time;
// Stop
if($then > $now) {
// Stop if time is now or end loop date
if($then->format('Y-m-d') > $now->format('Y-m-d') || $then->format('Y-m-d') > $end_loop_date->format('Y-m-d')) {
break;
}
@ -664,9 +673,15 @@ function tautulli_get_wrapped_dates($id, $array, $loop_interval) {
} else {
$library_str = '&section_id=' . trim($libraries[$library_loop]);
}
if($config->tautulli_grouping) {
$grouping = '1';
} else {
$grouping = '0';
}
// Create URL for API call
$url = $connection . "/api/v2?apikey=" . $config->tautulli_apikey . "&cmd=get_history" . $library_str . "&order_column=date&order_dir=desc&include_activity=0&length=" . $config->tautulli_length . "&start_date=" . $current_loop_date;
$url = $connection . "/api/v2?apikey=" . $config->tautulli_apikey . "&cmd=get_history" . $library_str . "&order_column=date&order_dir=desc&include_activity=0&grouping=" . $grouping . "&length=" . $config->tautulli_length . "&start_date=" . $current_loop_date;
// Call URL for data
$response = call_tautulli_url($url);
@ -675,7 +690,12 @@ function tautulli_get_wrapped_dates($id, $array, $loop_interval) {
$temp = $response["response"]["data"]["data"];
for($j = 0; $j < count($temp); $j++) {
if($temp[$j]["media_type"] == "movie" || $temp[$j]["media_type"] == "episode" || $temp[$j]["media_type"] == "track") {
$temp2 = array("date" => $temp[$j]["date"], "duration" => $temp[$j]["duration"], "friendly_name" => $temp[$j]["friendly_name"], "full_title" => $temp[$j]["full_title"], "grandparent_rating_key" => $temp[$j]["grandparent_rating_key"], "grandparent_title" => $temp[$j]["grandparent_title"], "original_title" => $temp[$j]["original_title"], "media_type" => $temp[$j]["media_type"], "parent_rating_key" => $temp[$j]["parent_rating_key"], "parent_title" => $temp[$j]["parent_title"], "paused_counter" => $temp[$j]["paused_counter"], "percent_complete" => $temp[$j]["percent_complete"], "rating_key" => $temp[$j]["rating_key"], "title" => $temp[$j]["title"], "user" => $temp[$j]["user"], "user_id" => $temp[$j]["user_id"], "year" => $temp[$j]["year"]);
$temp2 = array("date" => $temp[$j]["date"], "row_id" => $temp[$j]["row_id"], "duration" => $temp[$j]["duration"], "friendly_name" => $temp[$j]["friendly_name"], "full_title" => $temp[$j]["full_title"], "grandparent_rating_key" => $temp[$j]["grandparent_rating_key"], "grandparent_title" => $temp[$j]["grandparent_title"], "original_title" => $temp[$j]["original_title"], "media_type" => $temp[$j]["media_type"], "parent_rating_key" => $temp[$j]["parent_rating_key"], "parent_title" => $temp[$j]["parent_title"], "paused_counter" => $temp[$j]["paused_counter"], "percent_complete" => $temp[$j]["percent_complete"], "rating_key" => $temp[$j]["rating_key"], "title" => $temp[$j]["title"], "user" => $temp[$j]["user"], "user_id" => $temp[$j]["user_id"], "year" => $temp[$j]["year"]);
if($temp[$j]["full_title"] == "Black Widow") {
//echo json_encode($temp[$j]) . ',';
}
array_push($temp_clean, $temp2);
}
}
@ -743,15 +763,14 @@ function data_get_user_stats_loop($id, $array) {
for($d = 0; $d < count($array[$i]["data"]); $d++) {
// Check if entry is correct date-wise
if($array[$i]["data"][$d]["date"] > $config->wrapped_end || $array[$i]["data"][$d]["date"] < $config->wrapped_start) {
continue;
}
// Check if entry is movie and related to user
if($config->get_user_movie_stats && $array[$i]["data"][$d]["media_type"] == "movie" && $array[$i]["data"][$d]["user_id"] == $id) {
if($array[$i]["data"][$d]["date"] > $config->wrapped_end) {
continue;
} else if ($array[$i]["data"][$d]["date"] < $config->wrapped_start) {
break;
}
$duration = $array[$i]["data"][$d]["duration"];
$percent_complete = $array[$i]["data"][$d]["percent_complete"];
$title = $array[$i]["data"][$d]["full_title"];
@ -788,11 +807,6 @@ function data_get_user_stats_loop($id, $array) {
// Check if entry is show and related to user
if($config->get_user_show_stats && $array[$i]["data"][$d]["media_type"] == "episode" && $array[$i]["data"][$d]["user_id"] == $id) {
if($array[$i]["data"][$d]["date"] > $config->wrapped_end) {
continue;
} else if ($array[$i]["data"][$d]["date"] < $config->wrapped_start) {
break;
}
$title = $array[$i]["data"][$d]["grandparent_title"];
$episode_title = $array[$i]["data"][$d]["title"];
@ -832,11 +846,6 @@ function data_get_user_stats_loop($id, $array) {
// Check if entry is music and related to user
if($config->get_user_music_stats && $array[$i]["data"][$d]["media_type"] == "track" && $array[$i]["data"][$d]["user_id"] == $id) {
if($array[$i]["data"][$d]["date"] > $config->wrapped_end) {
continue;
} else if ($array[$i]["data"][$d]["date"] < $config->wrapped_start) {
break;
}
$title = $array[$i]["data"][$d]["title"];
$parent_title = $array[$i]["data"][$d]["parent_title"];
@ -867,11 +876,6 @@ function data_get_user_stats_loop($id, $array) {
// Check if entry is movie for year stats
if($config->get_year_stats_movies && $array[$i]["data"][$d]["media_type"] == "movie") {
if(intval($array[$i]["data"][$d]["date"]) > $config->wrapped_end) {
continue;
} else if(intval($array[$i]["data"][$d]["date"]) < $config->wrapped_start) {
break;
}
$title = $array[$i]["data"][$d]["full_title"];
$duration = $array[$i]["data"][$d]["duration"];
@ -912,11 +916,6 @@ function data_get_user_stats_loop($id, $array) {
// Check if entry is show for year stats
if($config->get_year_stats_shows && $array[$i]["data"][$d]["media_type"] == "episode") {
if(intval($array[$i]["data"][$d]["date"]) > $config->wrapped_end) {
continue;
} else if(intval($array[$i]["data"][$d]["date"]) < $config->wrapped_start) {
break;
}
$title = $array[$i]["data"][$d]["grandparent_title"];
$duration = $array[$i]["data"][$d]["duration"];
@ -958,11 +957,6 @@ function data_get_user_stats_loop($id, $array) {
// Check if entry is music for year stats
if($config->get_year_stats_music && $array[$i]["data"][$d]["media_type"] == "track") {
if($array[$i]["data"][$d]["date"] > $config->wrapped_end) {
continue;
} else if ($array[$i]["data"][$d]["date"] < $config->wrapped_start) {
break;
}
$duration = $array[$i]["data"][$d]["duration"];
$title = $array[$i]["data"][$d]["title"];
@ -1039,25 +1033,45 @@ function data_get_user_stats_loop($id, $array) {
$movie_oldest = array("title" => "No movies watched", "year" => 0, "plays" => 0, "duration" => 0, "paused_counter" => 0, "error" => true);
}
// Clone array for different order
$movies_plays = $movies;
// Sort $movies by longest duration
$duration = array_column($movies, 'duration');
array_multisort($duration, SORT_DESC, $movies);
if($config->stats_order_by_duration) {
$duration = array_column($movies, 'duration');
array_multisort($duration, SORT_DESC, $movies);
} else {
$movies = false;
}
// Sort $movies by plays
$movies_plays = $movies;
$plays = array_column($movies_plays, 'plays');
array_multisort($plays, SORT_DESC, $movies_plays);
if($config->stats_order_by_plays) {
$plays = array_column($movies_plays, 'plays');
array_multisort($plays, SORT_DESC, $movies_plays);
} else {
$movies_plays = false;
}
//Sort $shows by longest duration
$duration = array_column($shows, 'duration');
array_multisort($duration, SORT_DESC, $shows);
//Sort $shows by plays
// Clone array for different order
$shows_plays = $shows;
$plays = array_column($shows_plays, 'plays');
array_multisort($plays, SORT_DESC, $shows_plays);
// Sort $shows by longest duration
if($config->stats_order_by_duration) {
$duration = array_column($shows, 'duration');
array_multisort($duration, SORT_DESC, $shows);
} else {
$shows = false;
}
// Sort $shows by plays
if($config->stats_order_by_plays) {
$plays = array_column($shows_plays, 'plays');
array_multisort($plays, SORT_DESC, $shows_plays);
} else {
$shows_plays = false;
}
//Sort episodes by duration and find longest episode duration
// Sort episodes by duration and find longest episode duration
$duration = array_column($episodes, 'duration');
array_multisort($duration, SORT_DESC, $episodes);
if(count($episodes) > 0) {
@ -1126,68 +1140,138 @@ function data_get_user_stats_loop($id, $array) {
$album_oldest = array("parent_title" => "No albums played", "grandparent_title" => "No albums played", "year" => 0, "plays" => 0, "duration" => 0, "error" => true);
}
// Clone array for different order
$tracks_plays = $tracks;
// Sort $tracks by longest duration
$duration = array_column($tracks, 'duration');
array_multisort($duration, SORT_DESC, $tracks);
if($config->stats_order_by_duration) {
$duration = array_column($tracks, 'duration');
array_multisort($duration, SORT_DESC, $tracks);
} else {
$tracks = false;
}
// Sort $tracks by plays
$tracks_plays = $tracks;
$plays = array_column($tracks_plays, 'plays');
array_multisort($plays, SORT_DESC, $tracks_plays);
if($config->stats_order_by_plays) {
$plays = array_column($tracks_plays, 'plays');
array_multisort($plays, SORT_DESC, $tracks_plays);
} else {
$tracks_plays = false;
}
// Clone array for different order
$albums_plays = $albums;
// Sort $albums by longest duration
$duration = array_column($albums, 'duration');
array_multisort($duration, SORT_DESC, $albums);
if($config->stats_order_by_duration) {
$duration = array_column($albums, 'duration');
array_multisort($duration, SORT_DESC, $albums);
} else {
$albums = false;
}
// Sort $albums by plays
$albums_plays = $albums;
$plays = array_column($albums_plays, 'plays');
array_multisort($plays, SORT_DESC, $albums_plays);
if($config->stats_order_by_plays) {
$plays = array_column($albums_plays, 'plays');
array_multisort($plays, SORT_DESC, $albums_plays);
} else {
$albums_plays = false;
}
// Clone array for different order
$artists_plays = $artists;
// Sort $artists by longest duration
$duration = array_column($artists, 'duration');
array_multisort($duration, SORT_DESC, $artists);
if($config->stats_order_by_duration) {
$duration = array_column($artists, 'duration');
array_multisort($duration, SORT_DESC, $artists);
} else {
$artists = false;
}
// Sort $artists by plays
$artists_plays = $artists;
$plays = array_column($artists_plays, 'plays');
array_multisort($plays, SORT_DESC, $artists_plays);
if($config->stats_order_by_plays) {
$plays = array_column($artists_plays, 'plays');
array_multisort($plays, SORT_DESC, $artists_plays);
} else {
$artists_plays = false;
}
// Clone array for different order
$year_movies_plays = $year_movies;
// Sort $year_movies by duration
$duration = array_column($year_movies, 'duration');
array_multisort($duration, SORT_DESC, $year_movies);
if($config->stats_order_by_duration) {
$duration = array_column($year_movies, 'duration');
array_multisort($duration, SORT_DESC, $year_movies);
} else {
$year_movies = false;
}
// Sort $year_movies by plays
$year_movies_plays = $year_movies;
$plays = array_column($year_movies_plays, 'plays');
array_multisort($plays, SORT_DESC, $year_movies_plays);
if($config->stats_order_by_plays) {
$plays = array_column($year_movies_plays, 'plays');
array_multisort($plays, SORT_DESC, $year_movies_plays);
} else {
$year_movies_plays = false;
}
// Clone array for different order
$year_shows_plays = $year_shows;
// Sort $year_shows by duration
$duration = array_column($year_shows, 'duration');
array_multisort($duration, SORT_DESC, $year_shows);
if($config->stats_order_by_duration) {
$duration = array_column($year_shows, 'duration');
array_multisort($duration, SORT_DESC, $year_shows);
} else {
$year_shows = false;
}
// Sort $year_show by plays
$year_shows_plays = $year_shows;
$plays = array_column($year_shows_plays, 'plays');
array_multisort($plays, SORT_DESC, $year_shows_plays);
if($config->stats_order_by_plays) {
$plays = array_column($year_shows_plays, 'plays');
array_multisort($plays, SORT_DESC, $year_shows_plays);
} else {
$year_shows_plays = false;
}
// Clone array for different order
$year_music_plays = $year_music;
// Sort $year_music by duration
$duration = array_column($year_music, 'duration');
array_multisort($duration, SORT_DESC, $year_music);
if($config->stats_order_by_duration) {
$duration = array_column($year_music, 'duration');
array_multisort($duration, SORT_DESC, $year_music);
} else {
$year_music = false;
}
// Sort $year_music by plays
$year_music_plays = $year_music;
$plays = array_column($year_music_plays, 'plays');
array_multisort($plays, SORT_DESC, $year_music_plays);
if($config->stats_order_by_plays) {
$plays = array_column($year_music_plays, 'plays');
array_multisort($plays, SORT_DESC, $year_music_plays);
} else {
$year_music_plays = false;
}
// Clone array for different order
$year_users_plays = $year_users;
// Sort users by combined duration
$duration = array_column($year_users, 'duration');
array_multisort($duration, SORT_DESC, $year_users);
if($config->stats_order_by_duration) {
$duration = array_column($year_users, 'duration');
array_multisort($duration, SORT_DESC, $year_users);
} else {
$year_users = false;
}
// Sort users by combined plays
$year_users_plays = $year_users;
$plays = array_column($year_users_plays, 'plays');
array_multisort($plays, SORT_DESC, $year_users_plays);
if($config->stats_order_by_plays) {
$plays = array_column($year_users_plays, 'plays');
array_multisort($plays, SORT_DESC, $year_users_plays);
} else {
$year_users_plays = false;
}
// Calculate average movie finishing percentage
$sum = 0;
@ -1200,92 +1284,231 @@ function data_get_user_stats_loop($id, $array) {
$movie_percent_average = 0;
}
// Declare movie original
if($movies !== false) {
$movies_orig = $movies;
} else {
$movies_orig = $movies_plays;
}
// If movie variable is array, slice content
if($movies !== false) {
$movies = array_slice($movies, 0, 10);
}
// If movie_plays variable is array, slice content
if($movies_plays !== false) {
$movies_plays = array_slice($movies_plays, 0, 10);
}
// Choose return value based on if function is enabled
if($config->get_user_movie_stats) {
// Duration values
$return_movies = array("movies_duration" => array_slice($movies, 0, 10), "movies_plays" => array_slice($movies_plays, 0, 10), "user_movie_most_paused" => $movie_most_paused, "user_movie_finishing_percent" => $movie_percent_average, "user_movie_oldest" => $movie_oldest);
$return_movies = array("movies_duration" => $movies, "movies_plays" => $movies_plays, "user_movie_most_paused" => $movie_most_paused, "user_movie_finishing_percent" => $movie_percent_average, "user_movie_oldest" => $movie_oldest);
$duration = 0;
for($i = 0; $i < count($movies); $i++) {
$duration += $movies[$i]["duration"];
for($i = 0; $i < count($movies_orig); $i++) {
$duration += $movies_orig[$i]["duration"];
}
$return_movies["movie_duration"] = $duration;
$return_movies["movie_plays"] = count($movies);
$return_movies["movie_plays"] = count($movies_orig);
} else {
$return_movies = array();
}
// Declare show original
if($shows !== false) {
$shows_orig = $shows;
} else {
$shows_orig = $shows_plays;
}
// If shows variable is array, slice content
if($shows !== false) {
$shows = array_slice($shows, 0, 10);
}
// If shows_plays variable is array, slice content
if($shows_plays !== false) {
$shows_plays = array_slice($shows_plays, 0, 10);
}
// Choose return value based on if function is enabled
if($config->get_user_show_stats) {
$return_shows = array("shows_duration" => array_slice($shows, 0, 10), "shows_plays" => array_slice($shows_plays, 0, 10), "episode_duration_longest" => $episode_duration_longest);
$return_shows = array("shows_duration" => $shows, "shows_plays" => $shows_plays, "episode_duration_longest" => $episode_duration_longest);
$duration = 0;
for($i = 0; $i < count($shows); $i++) {
$duration += $shows[$i]["duration"];
for($i = 0; $i < count($shows_orig); $i++) {
$duration += $shows_orig[$i]["duration"];
}
$return_shows["show_duration"] = $duration;
$return_shows["show_plays"] = count($shows);
$return_shows["show_plays"] = count($shows_orig);
} else {
$return_shows = array();
}
// Declare tracks orignal
if($tracks !== false) {
$tracks_orig = $tracks;
} else {
$tracks_orig = $tracks_plays;
}
// If tracks variable is array, slice content
if($tracks !== false) {
$tracks = array_slice($tracks, 0, 10);
}
// If tracks_plays variable is array, slice content
if($tracks_plays !== false) {
$tracks_plays = array_slice($tracks_plays, 0, 10);
}
// If albums variable is array, slice content
if($albums !== false) {
$albums = array_slice($albums, 0, 10);
}
// If albums_plays variable is array, slice content
if($albums_plays !== false) {
$albums_plays = array_slice($albums_plays, 0, 10);
}
// If artists variable is array, slice content
if($artists !== false) {
$artists = array_slice($artists, 0, 10);
}
// If artists_plays variable is array, slice content
if($artists_plays !== false) {
$artists_plays = array_slice($artists_plays, 0, 10);
}
// Choose return value based on if function is enabled
if($config->get_user_music_stats) {
$return_music = array("tracks_duration" => array_slice($tracks, 0, 10), "tracks_plays" => array_slice($tracks_plays, 0, 10), "albums_duration" => array_slice($albums, 0, 10), "albums_plays" => array_slice($albums_plays, 0, 10), "user_album_oldest" => $album_oldest, "artists_duration" => array_slice($artists, 0, 10), "artists_plays" => array_slice($artists_plays, 0, 10));
$return_music = array("tracks_duration" => $tracks, "tracks_plays" => $tracks_plays, "albums_duration" => $albums, "albums_plays" => $albums_plays, "user_album_oldest" => $album_oldest, "artists_duration" => $artists, "artists_plays" => $artists_plays);
$duration = 0;
for($i = 0; $i < count($tracks); $i++) {
$duration += $tracks[$i]["duration"];
for($i = 0; $i < count($tracks_orig); $i++) {
$duration += $tracks_orig[$i]["duration"];
}
$return_music["track_duration"] = $duration;
$return_music["track_plays"] = count($tracks);
$return_music["track_plays"] = count($tracks_orig);
}else {
$return_music = array();
}
// Declare tracks orignal
if($year_movies !== false) {
$year_movies_orig = $year_movies;
} else {
$year_movies_orig = $year_movies_plays;
}
// If year_movies variable is array, slice content
if($year_movies !== false) {
$year_movies = array_slice($year_movies, 0, 10);
}
// If year_movies_plays variable is array, slice content
if($year_movies_plays !== false) {
$year_movies_plays = array_slice($year_movies_plays, 0, 10);
}
// Choose return value based on if function is enabled
if($config->get_year_stats_movies) {
$return_year_movies["movies_duration"] = array_slice($year_movies, 0, 10);
$return_year_movies["movies_plays"] = array_slice($year_movies_plays, 0, 10);
$return_year_movies["movies_duration"] = $year_movies;
$return_year_movies["movies_plays"] = $year_movies_plays;
$duration = 0;
for($i = 0; $i < count($year_movies); $i++) {
$duration += $year_movies[$i]["duration"];
for($i = 0; $i < count($year_movies_orig); $i++) {
$duration += $year_movies_orig[$i]["duration"];
}
$return_year_movies["movie_duration"] = $duration;
$return_year_movies["movie_plays"] = count($year_movies);
$return_year_movies["movie_plays"] = count($year_movies_orig);
}else {
$return_year_movies = array();
}
// Declare tracks orignal
if($year_shows !== false) {
$year_shows_orig = $year_shows;
} else {
$year_shows_orig = $year_shows_plays;
}
// If year_shows variable is array, slice content
if($year_shows !== false) {
$year_shows = array_slice($year_shows, 0, 10);
}
// If year_shows_plays variable is array, slice content
if($year_shows_plays !== false) {
$year_shows_plays = array_slice($year_shows_plays, 0, 10);
}
// Choose return value based on if function is enabled
if($config->get_year_stats_shows) {
$return_year_shows["shows_duration"] = array_slice($year_shows, 0, 10);
$return_year_shows["shows_plays"] = array_slice($year_shows_plays, 0, 10);
$return_year_shows["shows_duration"] = $year_shows;
$return_year_shows["shows_plays"] = $year_shows_plays;
$duration = 0;
for($i = 0; $i < count($year_shows); $i++) {
$duration += $year_shows[$i]["duration"];
for($i = 0; $i < count($year_shows_orig); $i++) {
$duration += $year_shows_orig[$i]["duration"];
}
$return_year_shows["show_duration"] = $duration;
$return_year_shows["show_plays"] = count($year_shows);
$return_year_shows["show_plays"] = count($year_shows_orig);
}else {
$return_year_shows = array();
}
// Declare year_music orignal
if($year_music !== false) {
$year_music_orig = $year_music;
} else {
$year_music_orig = $year_music_plays;
}
// If year_music variable is array, slice content
if($year_music !== false) {
$year_music = array_slice($year_music, 0, 10);
}
// If year_music_plays variable is array, slice content
if($year_music_plays !== false) {
$year_music_plays = array_slice($year_music_plays, 0, 10);
}
// Choose return value based on if function is enabled
if($config->get_year_stats_music) {
$return_year_music["artists_duration"] = array_slice($year_music, 0, 10);
$return_year_music["artists_plays"] = array_slice($year_music_plays, 0, 10);
$return_year_music["artists_duration"] = $year_music;
$return_year_music["artists_plays"] = $year_music_plays;
$duration = 0;
for($i = 0; $i < count($year_music); $i++) {
$duration += $year_music[$i]["duration"];
for($i = 0; $i < count($year_music_orig); $i++) {
$duration += $year_music_orig[$i]["duration"];
}
$return_year_music["music_duration"] = $duration;
$return_year_music["music_plays"] = count($year_music);
$return_year_music["music_plays"] = count($year_music_orig);
}else {
$return_year_music = array();
}
// Declare year_users orignal
if($year_users !== false) {
$year_users_orig = $year_users;
} else {
$year_users_orig = $year_users_plays;
}
// If year_users variable is array, slice content
if($year_users !== false) {
$year_users = array_slice($year_users, 0, 10);
}
// If year_users_plays variable is array, slice content
if($year_users_plays !== false) {
$year_users_plays = array_slice($year_users_plays, 0, 10);
}
// Choose return value based on if function is enabled
if(($config->get_year_stats_movies || $config->get_year_stats_shows || $config->get_year_stats_music) && $config->get_year_stats_leaderboard) {
$return_year_users["users_duration"] = array_slice($year_users, 0, 10);
$return_year_users["users_plays"] = array_slice($year_users_plays, 0, 10);
$return_year_users["users_duration"] = $year_users;
$return_year_users["users_plays"] = $year_users_plays;
} else {
$return_year_users["users_duration"] = array();
$return_year_users["users_plays"] = array();

View file

@ -12,10 +12,11 @@ class Config {
public $tautulli_length;
public $tautulli_root;
public $tautulli_libraries;
public $tautulli_grouping;
public $https;
// Wrapperr config
public $wrapperr_version = 'v2.2.3';
public $wrapperr_version = 'v2.2.4';
public $timezone;
public $application_name;
public $application_url;
@ -30,7 +31,12 @@ class Config {
// Wrapperr custom
public $wrapped_start;
public $wrapped_end;
public $stats_intro;
public $stats_intro_title;
public $stats_intro_subtitle;
public $stats_outro_title;
public $stats_outro_subtitle;
public $stats_order_by_plays;
public $stats_order_by_duration;
// Wrapperr custom movies
public $get_user_movie_stats;
@ -184,6 +190,12 @@ class Config {
} else {
$this->tautulli_libraries = '';
}
if(isset($json->tautulli_grouping)) {
$this->tautulli_grouping = $json->tautulli_grouping;
} else {
$this->tautulli_grouping = true;
}
if(isset($json->https)) {
$this->https = $json->https;
@ -257,16 +269,40 @@ class Config {
$this->wrapped_end = 1640991540;
}
if(isset($json->stats_intro)) {
$this->stats_intro = $json->stats_intro;
if(isset($json->stats_intro_title)) {
$this->stats_intro_title = $json->stats_intro_title;
} else {
$this->stats_intro = '<h1>Hey there, {user}!</h1><h2>New year, new page of statistics...</h2>';
$this->stats_intro_title = 'Hey there, {user}!';
}
if(isset($json->stats_outro)) {
$this->stats_outro = $json->stats_outro;
if(isset($json->stats_intro_subtitle)) {
$this->stats_intro_subtitle = $json->stats_intro_subtitle;
} else {
$this->stats_outro = '<h1>Hope you are staying safe!</h1><h2>Goodbye.</h2>';
$this->stats_intro_subtitle = 'New year, new page of statistics...';
}
if(isset($json->stats_outro_title)) {
$this->stats_outro_title = $json->stats_outro_title;
} else {
$this->stats_outro_title = 'Hope you are staying safe!';
}
if(isset($json->stats_outro_subtitle)) {
$this->stats_outro_subtitle = $json->stats_outro_subtitle;
} else {
$this->stats_outro_subtitle = 'Goodbye.';
}
if(isset($json->stats_order_by_plays)) {
$this->stats_order_by_plays = $json->stats_order_by_plays;
} else {
$this->stats_order_by_plays = true;
}
if(isset($json->stats_order_by_duration) && $this->stats_order_by_plays) {
$this->stats_order_by_duration = $json->stats_order_by_duration;
} else {
$this->stats_order_by_duration = true;
}
if(isset($json->create_share_links)) {

View file

@ -76,6 +76,7 @@ function save_config($data, $data_type, $clear_cache) {
$config->tautulli_length = $data->tautulli_length;
$config->tautulli_root = $data->tautulli_root;
$config->tautulli_libraries = $data->tautulli_libraries;
$config->tautulli_grouping = $data->tautulli_grouping;
$config->https = $data->https;
} catch (Exception $e) {
$fail = true;
@ -119,8 +120,12 @@ function save_config($data, $data_type, $clear_cache) {
try {
$config->wrapped_start = $data->wrapped_start;
$config->wrapped_end = $data->wrapped_end;
$config->stats_intro = $data->stats_intro;
$config->stats_outro = $data->stats_outro;
$config->stats_intro_title = $data->stats_intro_title;
$config->stats_intro_subtitle = $data->stats_intro_subtitle;
$config->stats_outro_title = $data->stats_outro_title;
$config->stats_outro_subtitle = $data->stats_outro_subtitle;
$config->stats_order_by_plays = $data->stats_order_by_plays;
$config->stats_order_by_duration = $data->stats_order_by_duration;
$config->get_user_movie_stats = $data->get_user_movie_stats;
$config->get_user_movie_stats_title = $data->get_user_movie_stats_title;
$config->get_user_movie_stats_subtitle = $data->get_user_movie_stats_subtitle;

View file

@ -3,5 +3,5 @@ LABEL maintainer="Wrapperr https://github.com/aunefyren/wrapperr"
RUN apt-get update && apt-get install -y \
git
RUN rm -d -r /var/www/html
RUN git clone https://github.com/aunefyren/wrapperr --branch v2.2.3 /var/www/html
RUN git clone https://github.com/aunefyren/wrapperr --branch v2.2.4 /var/www/html
RUN chmod -R 0777 /var/www/html/config

View file

@ -179,6 +179,11 @@ function seconds_to_seconds(seconds, function_setting) {
}
function number_with_spaces(number) {
if(isNaN(number)) {
return number;
}
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}

View file

@ -120,7 +120,8 @@ function load_introduction() {
text += "</div>";
text += "<div class='boks2' style='margin: auto 0;'>";
text += functions.stats_intro.replaceAll('{user}', results.user.name)
text += "<h1>" + functions.stats_intro_title.replaceAll('{user}', results.user.name) + "</h1>";
text += "<h2>" + functions.stats_intro_subtitle + "</h2>";
text += "</div>";
text += "</div>";
@ -164,7 +165,7 @@ function load_movies() {
// Replace custom string with movie plays
text += "<div class='boks3'>";
text += "<h2>" + functions.get_user_movie_stats_subtitle.replaceAll('{movie_count}', results.user.user_movies.data.movie_plays) + "</h2>";
text += "<h2>" + functions.get_user_movie_stats_subtitle.replaceAll('{movie_count}', number_with_spaces(results.user.user_movies.data.movie_plays)) + "</h2>";
text += "</div>";
text += "<div class='boks3'>";
@ -175,8 +176,17 @@ function load_movies() {
text += "<div class='boks3'>";
text += "<div class='boks2'>";
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_movies_data_movies_button" id="user_movies_data_movies_button" onclick="top_list_sort_by(results.user.user_movies.data.movies_plays, functions.get_user_movie_stats_top_movie_plural, false, true, \'user_movies_data_movies\', \'user_movies_data_movies_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_movies_data_movies_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
text += top_list(results.user.user_movies.data.movies_duration, functions.get_user_movie_stats_top_movie_plural, false, true, 'user_movies_data_movies');
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_movies_data_movies_button" id="user_movies_data_movies_button" onclick="top_list_sort_by(results.user.user_movies.data.movies_plays, functions.get_user_movie_stats_top_movie_plural, false, true, \'user_movies_data_movies\', \'user_movies_data_movies_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_movies_data_movies_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
}
if(functions.stats_order_by_plays == false) {
text += top_list(results.user.user_movies.data.movies_duration, functions.get_user_movie_stats_top_movie_plural, false, true, 'user_movies_data_movies');
} else {
text += top_list(results.user.user_movies.data.movies_plays, functions.get_user_movie_stats_top_movie_plural, false, true, 'user_movies_data_movies');
}
text += "</div>";
text += "<div class='boks2' style='padding: 0;'>";
@ -273,7 +283,7 @@ function load_shows() {
text += "</div>";
text += "<div class='boks3'>";
text += "<h2>" + functions.get_user_show_stats_subtitle.replaceAll('{show_count}', results.user.user_shows.data.show_plays) + "</h2>";
text += "<h2>" + functions.get_user_show_stats_subtitle.replaceAll('{show_count}', number_with_spaces(results.user.user_shows.data.show_plays)) + "</h2>";
text += "</div>";
text += "<div class='boks3'>";
@ -283,8 +293,17 @@ function load_shows() {
text += "<div class='boks3'>";
text += "<div class='boks2'>";
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_shows_data_shows_button" id="user_shows_data_shows_button" onclick="top_list_sort_by(results.user.user_shows.data.shows_plays, functions.get_user_show_stats_top_show_plural, false, true, \'user_shows_data_shows\', \'user_shows_data_shows_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_shows_data_shows_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
text += top_list(results.user.user_shows.data.shows_duration, functions.get_user_show_stats_top_show_plural, false, true, 'user_shows_data_shows');
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_shows_data_shows_button" id="user_shows_data_shows_button" onclick="top_list_sort_by(results.user.user_shows.data.shows_plays, functions.get_user_show_stats_top_show_plural, false, true, \'user_shows_data_shows\', \'user_shows_data_shows_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_shows_data_shows_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
}
if(functions.stats_order_by_plays == false) {
text += top_list(results.user.user_shows.data.shows_duration, functions.get_user_show_stats_top_show_plural, false, true, 'user_shows_data_shows');
} else {
text += top_list(results.user.user_shows.data.shows_plays, functions.get_user_show_stats_top_show_plural, false, true, 'user_shows_data_shows');
}
text += "</div>";
text += "<div class='boks2' style='padding: 0;'>";
@ -380,7 +399,7 @@ function load_music() {
text += "</div>";
text += "<div class='boks3'>";
text += "<h2>" + functions.get_user_music_stats_subtitle.replaceAll('{track_count}', results.user.user_music.data.track_plays) + "</h2>";
text += "<h2>" + functions.get_user_music_stats_subtitle.replaceAll('{track_count}', number_with_spaces(results.user.user_music.data.track_plays)) + "</h2>";
text += "</div>";
text += "<div class='boks3'>";
@ -390,18 +409,45 @@ function load_music() {
text += "<div class='boks3'>";
text += "<div class='boks2'>";
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_music_data_tracks_button" id="user_music_data_tracks_button" onclick="top_list_sort_by(results.user.user_music.data.tracks_plays, functions.get_user_music_stats_top_track_plural, \'track\', false, \'user_music_data_tracks\', \'user_music_data_tracks_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_music_data_tracks_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
text += top_list(results.user.user_music.data.tracks_duration, functions.get_user_music_stats_top_track_plural, "track", false, 'user_music_data_tracks');
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_music_data_tracks_button" id="user_music_data_tracks_button" onclick="top_list_sort_by(results.user.user_music.data.tracks_plays, functions.get_user_music_stats_top_track_plural, \'track\', false, \'user_music_data_tracks\', \'user_music_data_tracks_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_music_data_tracks_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
}
if(functions.stats_order_by_plays == false) {
text += top_list(results.user.user_music.data.tracks_duration, functions.get_user_music_stats_top_track_plural, "track", false, 'user_music_data_tracks');
} else {
text += top_list(results.user.user_music.data.tracks_plays, functions.get_user_music_stats_top_track_plural, "track", false, 'user_music_data_tracks');
}
text += "</div>";
text += "<div class='boks2'>";
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_music_data_albums_button" id="user_music_data_albums_button" onclick="top_list_sort_by(results.user.user_music.data.albums_plays, functions.get_user_music_stats_top_album_plural, \'album\', false, \'user_music_data_albums\', \'user_music_data_albums_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_music_data_albums_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
text += top_list(results.user.user_music.data.albums_duration, functions.get_user_music_stats_top_album_plural, "album", false, 'user_music_data_albums');
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_music_data_albums_button" id="user_music_data_albums_button" onclick="top_list_sort_by(results.user.user_music.data.albums_plays, functions.get_user_music_stats_top_album_plural, \'album\', false, \'user_music_data_albums\', \'user_music_data_albums_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_music_data_albums_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
}
if(functions.stats_order_by_plays == false) {
text += top_list(results.user.user_music.data.albums_duration, functions.get_user_music_stats_top_album_plural, "album", false, 'user_music_data_albums');
} else {
text += top_list(results.user.user_music.data.albums_plays, functions.get_user_music_stats_top_album_plural, "album", false, 'user_music_data_albums');
}
text += "</div>";
text += "<div class='boks2'>";
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_music_data_artists_button" id="user_music_data_artists_button" onclick="top_list_sort_by(results.user.user_music.data.artists_plays, functions.get_user_music_stats_top_artist_plural, \'artist\', false, \'user_music_data_artists\', \'user_music_data_artists_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_music_data_artists_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
text += top_list(results.user.user_music.data.artists_duration, functions.get_user_music_stats_top_artist_plural, "artist", false, 'user_music_data_artists');
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="user_music_data_artists_button" id="user_music_data_artists_button" onclick="top_list_sort_by(results.user.user_music.data.artists_plays, functions.get_user_music_stats_top_artist_plural, \'artist\', false, \'user_music_data_artists\', \'user_music_data_artists_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="user_music_data_artists_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
}
if(functions.stats_order_by_plays == false) {
text += top_list(results.user.user_music.data.artists_duration, functions.get_user_music_stats_top_artist_plural, "artist", false, 'user_music_data_artists');
} else {
text += top_list(results.user.user_music.data.artists_plays, functions.get_user_music_stats_top_artist_plural, "artist", false, 'user_music_data_artists');
}
text += "</div>";
text += "</div>";
@ -780,8 +826,17 @@ function load_users() {
if(functions.get_year_stats_leaderboard) {
text += "<div class='boks2'>";
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="year_stats_year_users_button" id="year_stats_year_users_button" onclick="top_list_names_sort_by(results.year_stats.year_users.data.users_plays, \'Top users\', \'year_stats_year_users\', \'year_stats_year_users_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="year_stats_year_users_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
text += top_list_names(results.year_stats.year_users.data.users_duration, functions.get_year_stats_leaderboard_title, 'year_stats_year_users');
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="year_stats_year_users_button" id="year_stats_year_users_button" onclick="top_list_names_sort_by(results.year_stats.year_users.data.users_plays, \'Top users\', \'year_stats_year_users\', \'year_stats_year_users_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="year_stats_year_users_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
}
if(functions.stats_order_by_plays == false) {
text += top_list_names(results.year_stats.year_users.data.users_duration, functions.get_year_stats_leaderboard_title, 'year_stats_year_users');
} else {
text += top_list_names(results.year_stats.year_users.data.users_plays, functions.get_year_stats_leaderboard_title, 'year_stats_year_users');
}
text += "</div>";
var time_movies = seconds_to_time(results.year_stats.year_movies.data.movie_duration, false);
@ -833,22 +888,49 @@ function load_users() {
if(functions.get_year_stats_movies && results.year_stats.year_movies.data.movie_plays > 0) {
text += "<div class='boks2'>";
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="year_stats_year_movies_button" id="year_stats_year_movies_button" onclick="top_list_sort_by(results.year_stats.year_movies.data.movies_plays, \'Top movies\', false, true, \'year_stats_year_movies\', \'year_stats_year_movies_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="year_stats_year_movies_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
text += top_list(results.year_stats.year_movies.data.movies_duration, functions.get_year_stats_movies_title, false, true, 'year_stats_year_movies');
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="year_stats_year_movies_button" id="year_stats_year_movies_button" onclick="top_list_sort_by(results.year_stats.year_movies.data.movies_plays, \'Top movies\', false, true, \'year_stats_year_movies\', \'year_stats_year_movies_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="year_stats_year_movies_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
}
if(functions.stats_order_by_plays == false) {
text += top_list(results.year_stats.year_movies.data.movies_duration, functions.get_year_stats_movies_title, false, true, 'year_stats_year_movies');
} else {
text += top_list(results.year_stats.year_movies.data.movies_plays, functions.get_year_stats_movies_title, false, true, 'year_stats_year_movies');
}
text += "</div>";
}
if(functions.get_year_stats_shows && results.year_stats.year_shows.data.show_plays > 0) {
text += "<div class='boks2'>";
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="year_stats_year_shows_button" id="year_stats_year_shows_button" onclick="top_list_sort_by(results.year_stats.year_shows.data.shows_plays, \'Top shows\', false, false, \'year_stats_year_shows\', \'year_stats_year_shows_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="year_stats_year_shows_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
text += top_list(results.year_stats.year_shows.data.shows_duration, functions.get_year_stats_shows_title, false, false, 'year_stats_year_shows');
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="year_stats_year_shows_button" id="year_stats_year_shows_button" onclick="top_list_sort_by(results.year_stats.year_shows.data.shows_plays, \'Top shows\', false, false, \'year_stats_year_shows\', \'year_stats_year_shows_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="year_stats_year_shows_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
}
if(functions.stats_order_by_plays == false) {
text += top_list(results.year_stats.year_shows.data.shows_duration, functions.get_year_stats_shows_title, false, false, 'year_stats_year_shows');
} else {
text += top_list(results.year_stats.year_shows.data.shows_plays, functions.get_year_stats_shows_title, false, false, 'year_stats_year_shows');
}
text += "</div>";
}
if(functions.get_year_stats_music && results.year_stats.year_music.data.music_plays > 0) {
text += "<div class='boks2'>";
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="year_stats_year_music_button" id="year_stats_year_music_button" onclick="top_list_sort_by(results.year_stats.year_music.data.artists_plays, \'Top artists\', \'artist\', false, \'year_stats_year_music\', \'year_stats_year_music_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="year_stats_year_music_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
text += top_list(results.year_stats.year_music.data.artists_duration, functions.get_year_stats_music_title, "artist", false, 'year_stats_year_music');
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '<button class="form-control btn" style="margin: 0.5em auto; width: fit-content;" name="year_stats_year_music_button" id="year_stats_year_music_button" onclick="top_list_sort_by(results.year_stats.year_music.data.artists_plays, \'Top artists\', \'artist\', false, \'year_stats_year_music\', \'year_stats_year_music_button\', functions);"><img src="assets/tweak.svg" class="btn_logo"><p2 id="year_stats_year_music_button_text">' + functions.wrapperr_sort_plays + '</p2></button>';
}
if(functions.stats_order_by_plays == false) {
text += top_list(results.year_stats.year_music.data.artists_duration, functions.get_year_stats_music_title, "artist", false, 'year_stats_year_music');
} else {
text += top_list(results.year_stats.year_music.data.artists_plays, functions.get_year_stats_music_title, "artist", false, 'year_stats_year_music');
}
text += "</div>";
}
@ -869,8 +951,9 @@ function load_outro() {
text += '<img src="assets/img/new-years.svg" style="width:100%; ">';
text += "</div>";
text += "<div class='boks2' style='margin-top:5em;'>";
text += functions.stats_outro;
text += "<div class='boks2' style='margin: auto 0;'>";
text += "<h1>" + functions.stats_outro_title + "</h1>";
text += "<h2>" + functions.stats_outro_subtitle + "</h2>";
text += "</div>";
text += "</div>";