Fix bug on recently added when item wasn't a video item.

Change variable names to fixed standard.
This commit is contained in:
Tim 2015-07-07 21:47:47 +02:00
parent 857e9e9d1c
commit a5d6b8ec0f
2 changed files with 12 additions and 14 deletions

View file

@ -10,10 +10,10 @@ Variable names: data [array]
data[array_index] :: Usable parameters data[array_index] :: Usable parameters
== Global keys == == Global keys ==
ratingKey Returns the unique identifier for the media item. rating_key Returns the unique identifier for the media item.
type Returns the type of media. Either 'movie' or 'season'. type Returns the type of media. Either 'movie' or 'season'.
thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. thumb Returns the location of the item's thumbnail. Use with pms_image_proxy.
addedAt Returns the time when the media was added to the library. added_at Returns the time when the media was added to the library.
title Returns the name of the movie or season. title Returns the name of the movie or season.
== Only if 'type' is 'movie' == == Only if 'type' is 'movie' ==
@ -30,7 +30,7 @@ DOCUMENTATION :: END
<li> <li>
<div class="poster"> <div class="poster">
<div class="poster-face"> <div class="poster-face">
<a href="info?rating_key=${item['ratingKey']}"> <a href="info?rating_key=${item['rating_key']}">
% if item['thumb'] != '': % if item['thumb'] != '':
<img src="pms_image_proxy?img=${item['thumb']}&width=153&height=225" class="poster-face"> <img src="pms_image_proxy?img=${item['thumb']}&width=153&height=225" class="poster-face">
% else: % else:
@ -45,12 +45,12 @@ DOCUMENTATION :: END
% elif item['type'] == 'movie': % elif item['type'] == 'movie':
<h3>${item['title']} (${item['year']})</h3> <h3>${item['title']} (${item['year']})</h3>
% endif % endif
<div class="muted" id="addedAt-${item['ratingKey']}">${item['addedAt']}</div> <div class="muted" id="added_at-${item['rating_key']}">${item['added_at']}</div>
</div> </div>
</li> </li>
</div> </div>
<script> <script>
$('#addedAt-${item['ratingKey']}').html('Added ' + moment(${item['addedAt']}, "X").fromNow()) $('#added_at-${item['rating_key']}').html('Added ' + moment(${item['added_at']}, "X").fromNow())
</script> </script>

View file

@ -208,15 +208,14 @@ class PmsConnect(object):
if recent_type == 'season': if recent_type == 'season':
recent_items = {'type': recent_type, recent_items = {'type': recent_type,
'ratingKey': helpers.get_xml_attr(item, 'ratingKey'), 'rating_key': helpers.get_xml_attr(item, 'ratingKey'),
'title': helpers.get_xml_attr(item, 'title'), 'title': helpers.get_xml_attr(item, 'title'),
'thumb': helpers.get_xml_attr(item, 'thumb'), 'thumb': helpers.get_xml_attr(item, 'thumb'),
'addedAt': helpers.get_xml_attr(item, 'addedAt') 'added_at': helpers.get_xml_attr(item, 'addedAt')
} }
recents_list.append(recent_items) recents_list.append(recent_items)
else: else:
recent_items = {} pass
recents_list.append(recent_items)
if a.getElementsByTagName('Video'): if a.getElementsByTagName('Video'):
recents_main = a.getElementsByTagName('Video') recents_main = a.getElementsByTagName('Video')
for item in recents_main: for item in recents_main:
@ -224,18 +223,17 @@ class PmsConnect(object):
if recent_type == 'movie': if recent_type == 'movie':
recent_items = {'type': recent_type, recent_items = {'type': recent_type,
'ratingKey': helpers.get_xml_attr(item, 'ratingKey'), 'rating_key': helpers.get_xml_attr(item, 'ratingKey'),
'title': helpers.get_xml_attr(item, 'title'), 'title': helpers.get_xml_attr(item, 'title'),
'year': helpers.get_xml_attr(item, 'year'), 'year': helpers.get_xml_attr(item, 'year'),
'thumb': helpers.get_xml_attr(item, 'thumb'), 'thumb': helpers.get_xml_attr(item, 'thumb'),
'addedAt': helpers.get_xml_attr(item, 'addedAt') 'added_at': helpers.get_xml_attr(item, 'addedAt')
} }
recents_list.append(recent_items) recents_list.append(recent_items)
else: else:
recent_items = {} pass
recents_list.append(recent_items)
output = {'recently_added': sorted(recents_list, key=lambda k: k['addedAt'], reverse=True)} output = {'recently_added': sorted(recents_list, key=lambda k: k['added_at'], reverse=True)}
return output return output
""" """