mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Add library recently added
This commit is contained in:
parent
95b55760ad
commit
2a85e11ad9
8 changed files with 224 additions and 49 deletions
|
@ -128,6 +128,23 @@ DOCUMENTATION :: END
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="table-card-header">
|
||||
<div class="header-bar">
|
||||
<span><i class="fa fa-history"></i> Recently Added</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-card-back">
|
||||
<div id="library-recently-added">
|
||||
<div class='muted'><i class="fa fa-refresh fa-spin"></i> Loading data...</div>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="libraryHistory">
|
||||
<div class="container-fluid">
|
||||
|
@ -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 });
|
||||
|
|
92
data/interfaces/default/library_recently_added.html
Normal file
92
data/interfaces/default/library_recently_added.html
Normal file
|
@ -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
|
||||
</%doc>
|
||||
|
||||
% if data:
|
||||
<div class="dashboard-recent-media-row">
|
||||
<ul class="dashboard-recent-media list-unstyled">
|
||||
% for item in data:
|
||||
<li>
|
||||
% if item['media_type'] == 'episode' or item['media_type'] == 'movie':
|
||||
<a href="info?rating_key=${item['rating_key']}">
|
||||
<div class="dashboard-recent-media-poster">
|
||||
% if item['media_type'] == 'episode':
|
||||
<div class="dashboard-recent-media-poster-face" style="background-image: url(pms_image_proxy?img=${item['parent_thumb']}&width=300&height=450&fallback=poster);">
|
||||
% elif item['media_type'] == 'movie':
|
||||
<div class="dashboard-recent-media-poster-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=450&fallback=poster);">
|
||||
% endif
|
||||
<div class="dashboard-recent-media-overlay">
|
||||
<div class="dashboard-recent-media-overlay-text" id="added_at-${item['rating_key']}">
|
||||
<script>
|
||||
$('#added_at-${item['rating_key']}').text('Added ' + moment(${item['added_at']}, "X").fromNow())
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard-recent-media-metacontainer">
|
||||
% if item['media_type'] == 'episode':
|
||||
<h3 title="${item['grandparent_title']}">${item['grandparent_title']}</h3>
|
||||
<h3 title="${item['title']}">${item['title']}</h3>
|
||||
<h3 class="text-muted">S${item['parent_media_index']} · E${item['media_index']}</h3>
|
||||
% elif item['media_type'] == 'movie':
|
||||
<h3 title="${item['title']}">${item['title']}</h3>
|
||||
<h3 class="text-muted">${item['year']}</h3>
|
||||
% endif
|
||||
</div>
|
||||
</a>
|
||||
% elif item['media_type'] == 'album':
|
||||
<a href="info?rating_key=${item['rating_key']}">
|
||||
<div class="dashboard-recent-media-cover">
|
||||
<div class="dashboard-recent-media-cover-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=300&fallback=cover);">
|
||||
<div class="dashboard-recent-media-overlay">
|
||||
<div class="dashboard-recent-media-overlay-text" id="added_at-${item['rating_key']}">
|
||||
<script>
|
||||
$('#added_at-${item['rating_key']}').text('Added ' + moment(${item['added_at']}, "X").fromNow())
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard-recent-media-metacontainer">
|
||||
<h3 title="${item['parent_title']}">${item['parent_title']}</h3>
|
||||
<h3 class="text-muted">${item['title']}</h3>
|
||||
</div>
|
||||
</a>
|
||||
% endif
|
||||
</li>
|
||||
% endfor
|
||||
</ul>
|
||||
</div>
|
||||
% else:
|
||||
<div class="text-muted">Unable to retrieve data from database.
|
||||
</div><br>
|
||||
% endif
|
|
@ -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
|
||||
</%doc>
|
||||
|
|
|
@ -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
|
||||
</%doc>
|
||||
|
@ -33,7 +31,7 @@ DOCUMENTATION :: END
|
|||
<ul class="dashboard-recent-media list-unstyled">
|
||||
% for item in data:
|
||||
<li>
|
||||
% if item['type'] == 'episode' or item['type'] == 'movie':
|
||||
% if item['media_type'] == 'episode' or item['media_type'] == 'movie':
|
||||
<a href="info?source=history&rating_key=${item['rating_key']}">
|
||||
<div class="dashboard-recent-media-poster">
|
||||
<div class="dashboard-recent-media-poster-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=450&fallback=poster);">
|
||||
|
@ -47,19 +45,17 @@ DOCUMENTATION :: END
|
|||
</div>
|
||||
</div>
|
||||
<div class="dashboard-recent-media-metacontainer">
|
||||
% if item['type'] == 'episode':
|
||||
% if item['media_type'] == 'episode':
|
||||
<h3 title="${item['grandparent_title']}">${item['grandparent_title']}</h3>
|
||||
<h3 title="${item['title']}">${item['title']}</h3>
|
||||
<h3 class="text-muted">S${item['parent_media_index']} · E${item['media_index']}</h3>
|
||||
% elif item['type'] == 'movie':
|
||||
% elif item['media_type'] == 'movie':
|
||||
<h3 title="${item['title']}">${item['title']}</h3>
|
||||
<h3 class="text-muted">${item['year']}</h3>
|
||||
% endif
|
||||
<div class="text-muted" id="time-${item['time']}">
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
% elif item['type'] == 'track':
|
||||
% elif item['media_type'] == 'track':
|
||||
<a href="info?source=history&rating_key=${item['rating_key']}">
|
||||
<div class="dashboard-recent-media-cover">
|
||||
<div class="dashboard-recent-media-cover-face" style="background-image: url(pms_image_proxy?img=${item['thumb']}&width=300&height=300&fallback=cover);">
|
||||
|
|
|
@ -352,7 +352,7 @@ class Libraries(object):
|
|||
thumb = row['thumb']
|
||||
|
||||
recent_output = {'row_id': row['id'],
|
||||
'type': row['media_type'],
|
||||
'media_type': row['media_type'],
|
||||
'rating_key': row['rating_key'],
|
||||
'title': row['title'],
|
||||
'parent_title': row['parent_title'],
|
||||
|
|
|
@ -169,6 +169,23 @@ class PmsConnect(object):
|
|||
|
||||
return request
|
||||
|
||||
def get_library_recently_added(self, section_key='', count='0', output_format=''):
|
||||
"""
|
||||
Return list of recently added items.
|
||||
|
||||
Parameters required: count { number of results to return }
|
||||
Optional parameters: output_format { dict, json }
|
||||
|
||||
Output: array
|
||||
"""
|
||||
uri = '/library/sections/' + section_key + '/recentlyAdded?X-Plex-Container-Start=0&X-Plex-Container-Size=' + count
|
||||
request = self.request_handler.make_request(uri=uri,
|
||||
proto=self.protocol,
|
||||
request_type='GET',
|
||||
output_format=output_format)
|
||||
|
||||
return request
|
||||
|
||||
def get_children_list(self, rating_key='', output_format=''):
|
||||
"""
|
||||
Return list of children in requested library item.
|
||||
|
@ -346,7 +363,7 @@ class PmsConnect(object):
|
|||
|
||||
return request
|
||||
|
||||
def get_recently_added_details(self, count='0'):
|
||||
def get_recently_added_details(self, library_id='', count='0'):
|
||||
"""
|
||||
Return processed and validated list of recently added items.
|
||||
|
||||
|
@ -354,6 +371,9 @@ class PmsConnect(object):
|
|||
|
||||
Output: array
|
||||
"""
|
||||
if library_id:
|
||||
recent = self.get_library_recently_added(library_id, count, output_format='xml')
|
||||
else:
|
||||
recent = self.get_recently_added(count, output_format='xml')
|
||||
|
||||
try:
|
||||
|
@ -373,15 +393,21 @@ class PmsConnect(object):
|
|||
if a.getElementsByTagName('Directory'):
|
||||
recents_main = a.getElementsByTagName('Directory')
|
||||
for item in recents_main:
|
||||
recent_type = helpers.get_xml_attr(item, 'type')
|
||||
recent_items = {'media_type': recent_type,
|
||||
recent_items = {'media_type': helpers.get_xml_attr(item, 'type'),
|
||||
'rating_key': helpers.get_xml_attr(item, 'ratingKey'),
|
||||
'parent_rating_key': helpers.get_xml_attr(item, 'parentRatingKey'),
|
||||
'grandparent_rating_key': helpers.get_xml_attr(item, 'grandparentRatingKey'),
|
||||
'title': helpers.get_xml_attr(item, 'title'),
|
||||
'parent_title': helpers.get_xml_attr(item, 'parentTitle'),
|
||||
'grandparent_title': helpers.get_xml_attr(item, 'grandparentTitle'),
|
||||
'media_index': helpers.get_xml_attr(item, 'index'),
|
||||
'parent_media_index': helpers.get_xml_attr(item, 'parentIndex'),
|
||||
'library_id': helpers.get_xml_attr(item, 'librarySectionID'),
|
||||
'library_name': helpers.get_xml_attr(item, 'librarySectionTitle'),
|
||||
'year': helpers.get_xml_attr(item, 'year'),
|
||||
'thumb': helpers.get_xml_attr(item, 'thumb'),
|
||||
'parent_thumb': helpers.get_xml_attr(item, 'parentThumb'),
|
||||
'grandparent_thumb': helpers.get_xml_attr(item, 'grandparentThumb'),
|
||||
'added_at': helpers.get_xml_attr(item, 'addedAt')
|
||||
}
|
||||
recents_list.append(recent_items)
|
||||
|
@ -389,22 +415,24 @@ class PmsConnect(object):
|
|||
if a.getElementsByTagName('Video'):
|
||||
recents_main = a.getElementsByTagName('Video')
|
||||
for item in recents_main:
|
||||
recent_type = helpers.get_xml_attr(item, 'type')
|
||||
|
||||
if recent_type == 'movie':
|
||||
recent_items = {'media_type': recent_type,
|
||||
recent_items = {'media_type': helpers.get_xml_attr(item, 'type'),
|
||||
'rating_key': helpers.get_xml_attr(item, 'ratingKey'),
|
||||
'parent_rating_key': helpers.get_xml_attr(item, 'parentRatingKey'),
|
||||
'grandparent_rating_key': helpers.get_xml_attr(item, 'grandparentRatingKey'),
|
||||
'title': helpers.get_xml_attr(item, 'title'),
|
||||
'parent_title': helpers.get_xml_attr(item, 'parentTitle'),
|
||||
'grandparent_title': helpers.get_xml_attr(item, 'grandparentTitle'),
|
||||
'media_index': helpers.get_xml_attr(item, 'index'),
|
||||
'parent_media_index': helpers.get_xml_attr(item, 'parentIndex'),
|
||||
'library_id': helpers.get_xml_attr(item, 'librarySectionID'),
|
||||
'library_name': helpers.get_xml_attr(item, 'librarySectionTitle'),
|
||||
'year': helpers.get_xml_attr(item, 'year'),
|
||||
'thumb': helpers.get_xml_attr(item, 'thumb'),
|
||||
'parent_thumb': helpers.get_xml_attr(item, 'parentThumb'),
|
||||
'grandparent_thumb': helpers.get_xml_attr(item, 'grandparentThumb'),
|
||||
'added_at': helpers.get_xml_attr(item, 'addedAt')
|
||||
}
|
||||
recents_list.append(recent_items)
|
||||
else:
|
||||
pass
|
||||
|
||||
output = {'recently_added': sorted(recents_list, key=lambda k: k['added_at'], reverse=True)}
|
||||
return output
|
||||
|
@ -1481,7 +1509,7 @@ class PmsConnect(object):
|
|||
|
||||
return output
|
||||
|
||||
def get_library_children(self, library_type='', section_key='', list_type='all', sort_type = ''):
|
||||
def get_library_children(self, library_type='', section_key='', list_type='all', count='1', sort_type = ''):
|
||||
"""
|
||||
Return processed and validated server library items list.
|
||||
|
||||
|
@ -1491,9 +1519,6 @@ class PmsConnect(object):
|
|||
Output: array
|
||||
"""
|
||||
|
||||
# Currently only grab the library with 1 items so 'size' is not 0
|
||||
count = '1'
|
||||
|
||||
if library_type == 'movie':
|
||||
sort_type = '&type=1'
|
||||
elif library_type == 'show':
|
||||
|
|
|
@ -452,7 +452,7 @@ class Users(object):
|
|||
thumb = row['thumb']
|
||||
|
||||
recent_output = {'row_id': row['id'],
|
||||
'type': row['media_type'],
|
||||
'media_type': row['media_type'],
|
||||
'rating_key': row['rating_key'],
|
||||
'title': row['title'],
|
||||
'parent_title': row['parent_title'],
|
||||
|
|
|
@ -219,7 +219,7 @@ class WebInterface(object):
|
|||
|
||||
try:
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_recently_added_details(count)
|
||||
result = pms_connect.get_recently_added_details(count=count)
|
||||
except IOError, e:
|
||||
return serve_template(templatename="recently_added.html", data=None)
|
||||
|
||||
|
@ -335,6 +335,18 @@ class WebInterface(object):
|
|||
logger.warn(u"Unable to retrieve data for get_library_recently_watched.")
|
||||
return serve_template(templatename="user_recently_watched.html", data=None, title="Recently Watched")
|
||||
|
||||
@cherrypy.expose
|
||||
def get_library_recently_added(self, library_id=None, limit='10', **kwargs):
|
||||
|
||||
library_data = pmsconnect.PmsConnect()
|
||||
result = library_data.get_recently_added_details(library_id=library_id, count=limit)
|
||||
|
||||
if result:
|
||||
return serve_template(templatename="library_recently_added.html", data=result['recently_added'], title="Recently Added")
|
||||
else:
|
||||
logger.warn(u"Unable to retrieve data for get_library_recently_added.")
|
||||
return serve_template(templatename="library_recently_added.html", data=None, title="Recently Added")
|
||||
|
||||
@cherrypy.expose
|
||||
def delete_all_library_history(self, section_id, **kwargs):
|
||||
library_data = libraries.Libraries()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue