diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..965acab
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,8 @@
+RewriteEngine on
+
+
+RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
+RewriteRule ^ /%1 [NC,L,R]
+
+RewriteCond %{REQUEST_FILENAME}.html -f
+RewriteRule ^ %{REQUEST_URI}.html [NC,L]
\ No newline at end of file
diff --git a/README.md b/README.md
index 50d1614..afd737f 100644
--- a/README.md
+++ b/README.md
@@ -1,50 +1,21 @@
# Plex Wrapped
-A website and API for collecting Plex user stats within a set timeframe using Tautulli.
-
-## Warning
-I made this for fun, and I am currently working on perfecting it. All feedback and tips are welcome.
-
+## Introduction
+A website and API for collecting Plex user stats within a set timeframe using [Tautulli](https://github.com/Tautulli/Tautulli). Yes, you need Tautulli to have been running beforehand and currently for this to work.
## Instructions
-There are multiple settings you must configure! They are all located in config.json.
-
-Tautulli API key
-API key generated by Tautulli.
+There are multiple settings you must configure! They will be stored in config/config.json, but can be configured easily at you-domain-or-ip.com/admin.
-Tautulli IP
-The IP address of the Tautulli server.
-Tautulli Port
-The port for the Tautulli server. Can be left as "".
+PHP will have issues with this API based on the results you want. If you have a large time frame for your wrapped period and there is a huge amount of Tautulli entries you can have multiple issues.
+In your php.ini file you may have to change:
+- max_execution_time=enough seconds for the script to finish
+- memory_limit=enough M for the script to handle JSON data
+- max_input_time=enough seconds for the script to parse JSON data
-SSL
-This is supposed to enable HTTPS support, but it does not function at this time. Leave as false.
+The cache is stored at config/cache.json, but can be cleared using the admin menu.
-Tautulli Root
-If using reverse proxy with a set root, add it here. Do not add "/" before or after.
-
-Library ID Movies
-The ID of your movie library in Tautulli. You can find it in the URL when visiting the library on the Tautulli website.
-
-Library ID Shows
-The ID of your show library in Tautulli. You can find it in the URL when visiting the library on the Tautulli website.
-
-Wrapped Start
-The beginning of the wrapped time period. Written in Epoch. Conversion can be done here https://www.epochconverter.com/.
-
-Wrapped End
-The end of the wrapped time period. Written in Epoch. Conversion can be done here https://www.epochconverter.com/.
-
-Get_... Settings
-Disables or enables different methods in the API. Will probably break the website without reconfiguration.
-
-Tautulli Length
-The number of items in your Tautulli database. Needed so API knows amount of data to load.
-
-
-
-You may need to give your PHP processing more memory, depending on how much data is in your Tautulli database.
+If you visit you-domain-or-ip.com/caching you can do a pre-caching of a set of users. This is very useful if you want to prepare for a lot of traffic.
## Need help?
-If you contact me I might have time to help you. Or maybe not. If not, many people on several forums (including /r/plex) might be able to assist you.
+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) might be able to assist you.
Goodybye.
\ No newline at end of file
diff --git a/admin.html b/admin.html
new file mode 100644
index 0000000..84ac859
--- /dev/null
+++ b/admin.html
@@ -0,0 +1,94 @@
+
+
+
";
- var str = JSON.stringify(results.user.user_movies.data.user_movie_most_paused.paused_counter / 60);
- var minutes = str.split('.');
- text += " It was paused for " + minutes[0] + " minutes...";
- text += "
";
+ var str = JSON.stringify(results.user.user_movies.data.user_movie_finishing_percent);
+ var percent = str.split('.');
+ text += "Your average movie finishing percentage was " + percent[0] + "%";
+ if(percent[0] > 89) {
+ text += '
';
+ }
+ text += "
You're not watching the credits like a nerd, are you?";
+ text += "
";
+ text += "
";
+ text += "
";
+
+ text += "
";
+ text += "
";
+
+ var str = JSON.stringify(results.user.user_movies.data.user_movie_most_paused.paused_counter / 60);
+ var minutes = str.split('.');
+
+ if(minutes[0] > 0) {
+ text += "
";
+ text += "Your longest movie pause was watching " + results.user.user_movies.data.user_movie_most_paused.title + " (" + results.user.user_movies.data.user_movie_most_paused.year + ")";
+
+ text += "
It was paused for " + minutes[0] + " minutes...";
+ text += "
";
+ } else {
+ text += "
";
+ text += "Bladder of steel";
+ text += '
';
+ text += " You never paused a single movie.";
text += "
";
}
text += "
";
text += "
";
- text += "
";
- if(results.user.user_shows.data.shows.length > 0) {
text += "
";
text += "
";
text += "
";
- text += "
Your top show was " + results.user.user_shows.data.shows[0].title + "
";
- var buddy_error = JSON.stringify(results.user.user_shows.data.show_buddy.error);
- if(buddy_error == "true") {
- text += " That means you're a hipster, because you're the only viewer of that show in 2020 😎";
+ text += "The oldest movie you watched was " + results.user.user_movies.data.user_movie_oldest.title + " (" + results.user.user_movies.data.user_movie_oldest.year + ") ";
+ if(results.user.user_movies.data.user_movie_oldest.year < 1950) {
+ text += " I didn't even know they made movies back then.";
+ text += '
';
+ } else if(results.user.user_movies.data.user_movie_oldest.year < 1975) {
+ text += " Did it even have color?";
+ text += '
';
+ } else if(results.user.user_movies.data.user_movie_oldest.year < 2000) {
+ text += " Was it a 4K, UHD, 3D, Dolby Atmos remaster?";
} else {
- text += "And you're not alone! Your " + results.user.user_shows.data.shows[0].title + "-buddy is ";
- text += "" + results.user.user_shows.data.show_buddy.user.user + "!
";
- var combined = results.user.user_shows.data.show_buddy.user.duration + parseInt(results.user.user_shows.data.shows[0].duration);
- var combined_2 = time_hours(combined);
- text += "Your combined efforts resulted in " + combined_2[0] + " hours and " + combined_2[1] + " minutes of " + results.user.user_shows.data.shows[0].title + "!
😎";
+ text += " Enjoying the classics, huh?";
}
text += "
";
text += "
";
text += "
";
- }
- var sum = 0;
- for(i = 0; (i < results.user.user_shows.data.shows.length); i++) {
- sum += results.user.user_shows.data.shows[i].duration;
- }
- var sum_split = time_hours(sum);
- text += "
You watched " + results.user.user_shows.data.shows.length + " shows. I get it, it's not for everyone!
(might wanna try it out)
"
+ text += '';
+ text += "
";
+ text += "
";
+
+ text += "
";
+ }
+
+ document.getElementById("search_results").innerHTML += text;
+}
+
+function load_showbuddy() {
+ var html = "";
+ html += "
";
+ html += "
";
+ html += "Your show was " + results.user.user_shows.data.shows[0].title + " ";
+ if(!results.user.user_shows.data.show_buddy.error) {
+ if(!results.user.user_shows.data.show_buddy.user.found) {
+ html += ' ';
+ html += " That means you dared to explore where no one else would, because you're the only viewer of that show";
+ } else {
+ html += "And you're not alone! Your " + results.user.user_shows.data.shows[0].title + "-buddy is ";
+ html += "" + results.user.user_shows.data.show_buddy.user.user + "!
";
+ var combined = results.user.user_shows.data.show_buddy.user.duration + parseInt(results.user.user_shows.data.shows[0].duration);
+ var combined_2 = time_hours(combined);
+ html += '';
+ html += " Your combined efforts resulted in " + combined_2[0] + " hours and " + combined_2[1] + " minutes of " + results.user.user_shows.data.shows[0].title + "!";
+ }
+ }
+ html += "
";
+ html += "
";
+ return html;
+}
+
+//TOP USERS
+function load_users() {
+ var text = "";
+
+ text += "
";
+ text += "
Finally, let's look at the top users, movies and shows!
";
+ text += "
It's okay to feel shame if you are on the list.
(or missing from it...)
"
text += "
";
text += "
";
@@ -197,18 +451,34 @@ function load_page(data){
text += "
";
text += "
";
text += "
";
- text += "
Top users from the past year
";
+ text += "
Top users
";
+ text += "
";
for(i = 0; i < 10 && i < results.year_stats.data.users.length; i++) {
- text += "
";
+ if(i == 0) {
+ text += "
";
+ } else if(i == 1) {
+ text += "
";
+ } else if(i == 2) {
+ text += "
";
+ } else {
+ text += "
";
+ }
text += "
";
text += i+1 + ". ";
text += "
";
- text += "
";
- text += results.year_stats.data.users[i].user;
- text += "
";
+ if(results.year_stats.data.users[i].user == results.user.name) {
+ text += "
";
+ text += results.year_stats.data.users[i].user;
+ text += "
";
+ }else {
+ text += "
";
+ text += results.year_stats.data.users[i].user;
+ text += "
";
+ }
text += "
";
}
+ text += "
";
text += "
";
text += "
";
text += "
";
@@ -227,11 +497,12 @@ function load_page(data){
text += "
";
text += "
";
text += "
";
- text += "The users spent
" + sum_movies_split[0] + " days and " + sum_movies_split[1] + " hours
";
- text += " watching movies";
- text += "
And, the users spent
" + sum_shows_split[0] + " days and " + sum_shows_split[1] + " hours
";
- text += " watching shows";
- text += "
That is
" + Number(sum_shows_split[0] + sum_movies_split[0]) + " days and " + Number(sum_shows_split[1] + sum_movies_split[1]) + " hours
of content!";
+ text += "All the different users combined spent " + sum_movies_split[0] + " days and " + sum_movies_split[1] + " hours";
+ text += " watching movies.";
+ text += "
And, the users spent " + sum_shows_split[0] + " days and " + sum_shows_split[1] + " hours";
+ text += " watching shows.";
+ text += "
That is " + Number(sum_shows_split[0] + sum_movies_split[0]) + " days and " + Number(sum_shows_split[1] + sum_movies_split[1]) + " hours of content!";
+ text += '';
text += "
";
text += "
";
text += "
";
@@ -242,7 +513,8 @@ function load_page(data){
text += "
";
text += "
";
text += "
";
- text += "
Top movies from the past year
";
+ text += "
Top movies
";
+ text += "
";
for(i = 0; i < 10 && i < results.year_stats.data.top_movies.length; i++) {
text += "
";
text += "
";
@@ -256,6 +528,7 @@ function load_page(data){
text += "
";
text += "
";
}
+ text += '
';
text += "
";
text += "
";
text += "
";
@@ -263,7 +536,8 @@ function load_page(data){
text += "
";
text += "
";
text += "
";
- text += "
Top shows from the past year
";
+ text += "
Top shows
";
+ text += "
";
for(i = 0; i < 10 && i < results.year_stats.data.top_shows.length; i++) {
text += "
";
text += "
";
@@ -277,6 +551,7 @@ function load_page(data){
text += "
";
text += "
";
}
+ text += '
';
text += "
";
text += "
";
text += "
";
@@ -284,12 +559,23 @@ function load_page(data){
text += "