mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Add recently added media type toggles to homepage
This commit is contained in:
parent
0c481fc005
commit
e0b78adfee
6 changed files with 131 additions and 79 deletions
|
@ -484,7 +484,26 @@ class PmsConnect(object):
|
|||
|
||||
return request
|
||||
|
||||
def get_recently_added_details(self, section_id='', start='0', count='0'):
|
||||
def get_hub_recently_added(self, start='0', count='0', type='', output_format=''):
|
||||
"""
|
||||
Return Plex hub recently added.
|
||||
|
||||
Parameters required: start { item number to start from }
|
||||
count { number of results to return }
|
||||
type { str }
|
||||
Optional parameters: output_format { dict, json }
|
||||
|
||||
Output: array
|
||||
"""
|
||||
uri = '/hubs/home/recentlyAdded?X-Plex-Container-Start=%s&X-Plex-Container-Size=%s&type=%s' % (start, count, type)
|
||||
request = self.request_handler.make_request(uri=uri,
|
||||
proto=self.protocol,
|
||||
request_type='GET',
|
||||
output_format=output_format)
|
||||
|
||||
return request
|
||||
|
||||
def get_recently_added_details(self, start='0', count='0', type='', section_id=''):
|
||||
"""
|
||||
Return processed and validated list of recently added items.
|
||||
|
||||
|
@ -492,7 +511,15 @@ class PmsConnect(object):
|
|||
|
||||
Output: array
|
||||
"""
|
||||
if section_id:
|
||||
if type in ('movie', 'show', 'artist'):
|
||||
if type == 'movie':
|
||||
type = '1'
|
||||
elif type == 'show':
|
||||
type = '2'
|
||||
elif type == 'artist':
|
||||
type = '8'
|
||||
recent = self.get_hub_recently_added(start, count, type, output_format='xml')
|
||||
elif section_id:
|
||||
recent = self.get_library_recently_added(section_id, start, count, output_format='xml')
|
||||
else:
|
||||
recent = self.get_recently_added(start, count, output_format='xml')
|
||||
|
@ -529,7 +556,8 @@ class PmsConnect(object):
|
|||
'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')
|
||||
'added_at': helpers.get_xml_attr(item, 'addedAt'),
|
||||
'child_count': helpers.get_xml_attr(item, 'childCount')
|
||||
}
|
||||
recents_list.append(recent_items)
|
||||
|
||||
|
@ -551,7 +579,8 @@ class PmsConnect(object):
|
|||
'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')
|
||||
'added_at': helpers.get_xml_attr(item, 'addedAt'),
|
||||
'child_count': helpers.get_xml_attr(item, 'childCount')
|
||||
}
|
||||
recents_list.append(recent_items)
|
||||
|
||||
|
|
|
@ -350,11 +350,11 @@ class WebInterface(object):
|
|||
|
||||
@cherrypy.expose
|
||||
@requireAuth()
|
||||
def get_recently_added(self, count='0', **kwargs):
|
||||
def get_recently_added(self, count='0', type='', **kwargs):
|
||||
|
||||
try:
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_recently_added_details(count=count)
|
||||
result = pms_connect.get_recently_added_details(count=count, type=type)
|
||||
except IOError as e:
|
||||
return serve_template(templatename="recently_added.html", data=None)
|
||||
|
||||
|
@ -4072,7 +4072,7 @@ class WebInterface(object):
|
|||
@cherrypy.tools.json_out()
|
||||
@requireAuth(member_of("admin"))
|
||||
@addtoapi("get_recently_added")
|
||||
def get_recently_added_details(self, start='0', count='0', section_id='', **kwargs):
|
||||
def get_recently_added_details(self, start='0', count='0', type='', section_id='', **kwargs):
|
||||
""" Get all items that where recelty added to plex.
|
||||
|
||||
```
|
||||
|
@ -4081,6 +4081,7 @@ class WebInterface(object):
|
|||
|
||||
Optional parameters:
|
||||
start (str): The item number to start at
|
||||
type (str): The media type: movie, show, artist
|
||||
section_id (str): The id of the Plex library section
|
||||
|
||||
Returns:
|
||||
|
@ -4110,7 +4111,7 @@ class WebInterface(object):
|
|||
```
|
||||
"""
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_recently_added_details(start=start, count=count, section_id=section_id)
|
||||
result = pms_connect.get_recently_added_details(start=start, count=count, type=type, section_id=section_id)
|
||||
|
||||
if result:
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue