From 2a85e11ad909db91f0415653111ef25a94209c20 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Wed, 6 Jan 2016 22:29:27 -0800 Subject: [PATCH] Add library recently added --- data/interfaces/default/library.html | 43 +++++++++ .../default/library_recently_added.html | 92 +++++++++++++++++++ data/interfaces/default/recently_added.html | 19 ++-- .../default/user_recently_watched.html | 28 +++--- plexpy/libraries.py | 2 +- plexpy/pmsconnect.py | 73 ++++++++++----- plexpy/users.py | 2 +- plexpy/webserve.py | 14 ++- 8 files changed, 224 insertions(+), 49 deletions(-) create mode 100644 data/interfaces/default/library_recently_added.html diff --git a/data/interfaces/default/library.html b/data/interfaces/default/library.html index 34092ec8..fc159c40 100644 --- a/data/interfaces/default/library.html +++ b/data/interfaces/default/library.html @@ -128,6 +128,23 @@ DOCUMENTATION :: END +
+
+
+
+
+ Recently Added +
+
+
+
+
Loading data...
+
+
+
+
+
+
@@ -366,9 +383,35 @@ DOCUMENTATION :: END }); } + function recentlyAdded() { + var widthVal = $('body').find("#library-recently-added").width(); + var tmp = (widthVal-32) / 180; + + if (tmp > 0) { + containerSize = parseInt(tmp); + } else { + containerSize = 1; + } + + // Populate recently added + $.ajax({ + url: 'get_library_recently_added', + async: true, + data: { + library_id: section_id, + limit: containerSize + }, + complete: function(xhr, status) { + $("#library-recently-added").html(xhr.responseText); + } + }); + } + recentlyWatched(); + recentlyAdded(); $(window).resize(function() { recentlyWatched(); + recentlyAdded(); }); }); $('div.art-face').animate({ opacity: 0.2 }, { duration: 1000 }); diff --git a/data/interfaces/default/library_recently_added.html b/data/interfaces/default/library_recently_added.html new file mode 100644 index 00000000..774166e7 --- /dev/null +++ b/data/interfaces/default/library_recently_added.html @@ -0,0 +1,92 @@ +<%doc> +USAGE DOCUMENTATION :: PLEASE LEAVE THIS AT THE TOP OF THIS FILE + +For Mako templating syntax documentation please visit: http://docs.makotemplates.org/en/latest/ + +Filename: library_recently_added.html +Version: 0.1 +Variable names: data [array] + +data[array_index] :: Usable parameters + +== Global keys == +media_type Returns the type of media. Either 'movie' or 'episode' or 'album'. +rating_key Returns the unique identifier for the media item. +parent_rating_key Returns the unique identifier for the season or artist. +grandparent_rating_key Returns the unique identifier for the show. +title Returns the name of the movie, episode, album. +parent_title Returns the name of the artist. +grandparent_title Returns the name of the show. +media_index Returns the index number of the episode. +parent_media_index Returns the index number of the season. +library_id Returns the library section number of the media item. +library_name Returns the library section name of the media item. +year Returns the release year of the movie, episode, or album. +thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. +parent_thumb Returns the location of the artist's thumbnail. Use with pms_image_proxy. +grandparent_thumb Returns the location of the show's thumbnail. Use with pms_image_proxy. +added_at Returns the time when the media was added to the library. + +DOCUMENTATION :: END + + +% if data: + +% else: +
Unable to retrieve data from database. +

+% endif \ No newline at end of file diff --git a/data/interfaces/default/recently_added.html b/data/interfaces/default/recently_added.html index 48dcf4cc..a8fe0042 100644 --- a/data/interfaces/default/recently_added.html +++ b/data/interfaces/default/recently_added.html @@ -10,15 +10,22 @@ Variable names: data [array] data[array_index] :: Usable parameters == Global keys == +media_type Returns the type of media. Either 'movie' or 'episode' or 'album'. rating_key Returns the unique identifier for the media item. -media_type Returns the media type of media. Either 'movie' or 'season' or 'album'. +parent_rating_key Returns the unique identifier for the season or artist. +grandparent_rating_key Returns the unique identifier for the show. +title Returns the name of the movie, episode, album. +parent_title Returns the name of the artist. +grandparent_title Returns the name of the show. +media_index Returns the index number of the episode. +parent_media_index Returns the index number of the season. +library_id Returns the library section number of the media item. +library_name Returns the library section name of the media item. +year Returns the release year of the movie, episode, or album. thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. +parent_thumb Returns the location of the artist's thumbnail. Use with pms_image_proxy. +grandparent_thumb Returns the location of the show's thumbnail. Use with pms_image_proxy. added_at Returns the time when the media was added to the library. -title Returns the name of the movie or season. -parent_title Returns the name of the TV Show a season belongs too. - -== Only if 'media_type' is 'movie' == -year Returns the movie release year. DOCUMENTATION :: END diff --git a/data/interfaces/default/user_recently_watched.html b/data/interfaces/default/user_recently_watched.html index df0d9e4f..d5dc936d 100644 --- a/data/interfaces/default/user_recently_watched.html +++ b/data/interfaces/default/user_recently_watched.html @@ -12,18 +12,16 @@ data[array_index] :: Usable parameters == Global keys == rating_key Returns the unique identifier for the media item. row_id Returns the unique row id for the media item in the database. -type Returns the type of media. Either 'movie' or 'episode'. +media_type Returns the type of media. Either 'movie' or 'episode' or 'album'. thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. time Returns the last watched time of the media. -title Returns the name of the movie or episode. - -== Only if 'type' is 'episode == -parent_title Returns the name of the TV Show a season belongs too. -parent_index Returns the season number. -index Returns the episode number. - -== Only if 'type' is 'movie' == -year Returns the movie release year. +user Returns the name of the user that watched the item. +title Returns the name of the movie, episode, album. +parent_title Returns the name of the artist. +grandparent_title Returns the name of the show. +media_index Returns the index number of the episode. +parent_media_index Returns the index number of the season. +year Returns the release year of the movie, episode, or album. DOCUMENTATION :: END @@ -33,7 +31,7 @@ DOCUMENTATION :: END