mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Change type to media_type
This commit is contained in:
parent
c70cc535e5
commit
77460f7617
5 changed files with 32 additions and 22 deletions
4
API.md
4
API.md
|
@ -1775,7 +1775,7 @@ Returns:
|
|||
|
||||
|
||||
### get_recently_added
|
||||
Get all items that where recelty added to plex.
|
||||
Get all items that where recently added to plex.
|
||||
|
||||
```
|
||||
Required parameters:
|
||||
|
@ -1783,7 +1783,7 @@ Required parameters:
|
|||
|
||||
Optional parameters:
|
||||
start (str): The item number to start at
|
||||
type (str): The media type: movie, show, artist
|
||||
media_type (str): The media type: movie, show, artist
|
||||
section_id (str): The id of the Plex library section
|
||||
|
||||
Returns:
|
||||
|
|
|
@ -771,7 +771,7 @@
|
|||
async: true,
|
||||
data: {
|
||||
count: recently_added_count,
|
||||
type: recently_added_type
|
||||
media_type: recently_added_type
|
||||
},
|
||||
complete: function (xhr, status) {
|
||||
$("#recentlyAdded").html(xhr.responseText);
|
||||
|
|
|
@ -683,7 +683,7 @@ class RecentlyAdded(Newsletter):
|
|||
start = 0
|
||||
|
||||
while not done:
|
||||
recent_items = pms_connect.get_recently_added_details(start=str(start), count='10', type=media_type)
|
||||
recent_items = pms_connect.get_recently_added_details(start=str(start), count='10', media_type=media_type)
|
||||
filtered_items = [i for i in recent_items['recently_added']
|
||||
if self.start_time < helpers.cast_to_int(i['added_at']) < self.end_time]
|
||||
if len(filtered_items) < 10:
|
||||
|
|
|
@ -418,25 +418,27 @@ class PmsConnect(object):
|
|||
|
||||
return request
|
||||
|
||||
def get_hub_recently_added(self, start='0', count='0', type='', output_format=''):
|
||||
def get_hub_recently_added(self, start='0', count='0', media_type='', other_video=False, output_format=''):
|
||||
"""
|
||||
Return Plex hub recently added.
|
||||
|
||||
Parameters required: start { item number to start from }
|
||||
count { number of results to return }
|
||||
type { str }
|
||||
media_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)
|
||||
personal = '&personal=1' if other_video else ''
|
||||
uri = '/hubs/home/recentlyAdded?X-Plex-Container-Start=%s&X-Plex-Container-Size=%s&type=%s%s' \
|
||||
% (start, count, media_type, personal)
|
||||
request = self.request_handler.make_request(uri=uri,
|
||||
request_type='GET',
|
||||
output_format=output_format)
|
||||
|
||||
return request
|
||||
|
||||
def get_recently_added_details(self, start='0', count='0', type='', section_id=''):
|
||||
def get_recently_added_details(self, start='0', count='0', media_type='', section_id=''):
|
||||
"""
|
||||
Return processed and validated list of recently added items.
|
||||
|
||||
|
@ -444,14 +446,18 @@ class PmsConnect(object):
|
|||
|
||||
Output: array
|
||||
"""
|
||||
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')
|
||||
if media_type in ('movie', 'show', 'artist', 'other_video'):
|
||||
other_video = False
|
||||
if media_type == 'movie':
|
||||
media_type = '1'
|
||||
elif media_type == 'show':
|
||||
media_type = '2'
|
||||
elif media_type == 'artist':
|
||||
media_type = '8'
|
||||
elif media_type == 'other_video':
|
||||
media_type = '1'
|
||||
other_video = True
|
||||
recent = self.get_hub_recently_added(start, count, media_type, other_video, output_format='xml')
|
||||
elif section_id:
|
||||
recent = self.get_library_recently_added(section_id, start, count, output_format='xml')
|
||||
else:
|
||||
|
|
|
@ -332,11 +332,11 @@ class WebInterface(object):
|
|||
|
||||
@cherrypy.expose
|
||||
@requireAuth()
|
||||
def get_recently_added(self, count='0', type='', **kwargs):
|
||||
def get_recently_added(self, count='0', media_type='', **kwargs):
|
||||
|
||||
try:
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_recently_added_details(count=count, type=type)
|
||||
result = pms_connect.get_recently_added_details(count=count, media_type=media_type)
|
||||
except IOError as e:
|
||||
return serve_template(templatename="recently_added.html", data=None)
|
||||
|
||||
|
@ -4701,8 +4701,8 @@ 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', type='', section_id='', **kwargs):
|
||||
""" Get all items that where recelty added to plex.
|
||||
def get_recently_added_details(self, start='0', count='0', media_type='', section_id='', **kwargs):
|
||||
""" Get all items that where recently added to plex.
|
||||
|
||||
```
|
||||
Required parameters:
|
||||
|
@ -4710,7 +4710,7 @@ class WebInterface(object):
|
|||
|
||||
Optional parameters:
|
||||
start (str): The item number to start at
|
||||
type (str): The media type: movie, show, artist
|
||||
media_type (str): The media type: movie, show, artist
|
||||
section_id (str): The id of the Plex library section
|
||||
|
||||
Returns:
|
||||
|
@ -4740,8 +4740,12 @@ class WebInterface(object):
|
|||
}
|
||||
```
|
||||
"""
|
||||
# For backwards compatibility
|
||||
if 'type' in kwargs:
|
||||
media_type = kwargs['type']
|
||||
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_recently_added_details(start=start, count=count, type=type, section_id=section_id)
|
||||
result = pms_connect.get_recently_added_details(start=start, count=count, media_type=media_type, section_id=section_id)
|
||||
|
||||
if result:
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue