mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Fix bugs with media info table
This commit is contained in:
parent
002cb93187
commit
6152a1e913
10 changed files with 55 additions and 60 deletions
|
@ -242,8 +242,9 @@ class Libraries(object):
|
|||
rows = json.load(inFile)
|
||||
library_count = len(rows)
|
||||
except IOError as e:
|
||||
logger.debug(u"PlexPy Libraries :: No JSON file for rating_key %s." % rating_key)
|
||||
logger.debug(u"PlexPy Libraries :: Refreshing data and creating new JSON file for rating_key %s." % rating_key)
|
||||
#logger.debug(u"PlexPy Libraries :: No JSON file for rating_key %s." % rating_key)
|
||||
#logger.debug(u"PlexPy Libraries :: Refreshing data and creating new JSON file for rating_key %s." % rating_key)
|
||||
pass
|
||||
elif section_id:
|
||||
try:
|
||||
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s.json' % section_id)
|
||||
|
@ -251,8 +252,9 @@ class Libraries(object):
|
|||
rows = json.load(inFile)
|
||||
library_count = len(rows)
|
||||
except IOError as e:
|
||||
logger.debug(u"PlexPy Libraries :: No JSON file for library section_id %s." % section_id)
|
||||
logger.debug(u"PlexPy Libraries :: Refreshing data and creating new JSON file for section_id %s." % section_id)
|
||||
#logger.debug(u"PlexPy Libraries :: No JSON file for library section_id %s." % section_id)
|
||||
#logger.debug(u"PlexPy Libraries :: Refreshing data and creating new JSON file for section_id %s." % section_id)
|
||||
pass
|
||||
|
||||
if not rows:
|
||||
# Get the library details
|
||||
|
@ -312,13 +314,6 @@ class Libraries(object):
|
|||
|
||||
rows = []
|
||||
for item in children_list:
|
||||
thumb = item['thumb']
|
||||
|
||||
if item['media_type'] == 'episode' or item['media_type'] == 'track':
|
||||
full_title = 'E%s - %s' % (item['media_index'], item['title'])
|
||||
else:
|
||||
full_title = item['title']
|
||||
|
||||
watched_item = watched_list.get(item['rating_key'], None)
|
||||
if watched_item:
|
||||
last_watched = watched_item['last_watched']
|
||||
|
@ -329,18 +324,16 @@ class Libraries(object):
|
|||
|
||||
row = {'section_id': library_details['section_id'],
|
||||
'section_type': library_details['section_type'],
|
||||
'last_watched': last_watched,
|
||||
'added_at': item['added_at'],
|
||||
'media_type': item['media_type'],
|
||||
'rating_key': item['rating_key'],
|
||||
'parent_rating_key': item['parent_rating_key'],
|
||||
'grandparent_rating_key': item['grandparent_rating_key'],
|
||||
'full_title': full_title,
|
||||
'title': item['title'],
|
||||
'year': item['year'],
|
||||
'media_index': item['media_index'],
|
||||
'parent_media_index': item['parent_media_index'],
|
||||
'thumb': thumb,
|
||||
'thumb': item['thumb'],
|
||||
'container': item.get('container', ''),
|
||||
'bitrate': item.get('bitrate', ''),
|
||||
'video_codec': item.get('video_codec', ''),
|
||||
|
@ -349,6 +342,7 @@ class Libraries(object):
|
|||
'audio_codec': item.get('audio_codec', ''),
|
||||
'audio_channels': item.get('audio_channels', ''),
|
||||
'file_size': item.get('file_size', ''),
|
||||
'last_watched': last_watched,
|
||||
'play_count': play_count
|
||||
}
|
||||
rows.append(row)
|
||||
|
@ -384,25 +378,29 @@ class Libraries(object):
|
|||
filtered_count = len(results)
|
||||
|
||||
# Sort results
|
||||
results = sorted(results, key=lambda k: k['title'])
|
||||
sort_order = json_data['order']
|
||||
for order in reversed(sort_order):
|
||||
sort_key = json_data['columns'][int(order['column'])]['data']
|
||||
reverse = True if order['dir'] == 'desc' else False
|
||||
if rating_key and sort_key == 'title':
|
||||
results = sorted(results, key=lambda k: int(k['media_index']), reverse=reverse)
|
||||
elif sort_key == 'file_size' or sort_key == 'bitrate':
|
||||
results = sorted(results, key=lambda k: int(k[sort_key]), reverse=reverse)
|
||||
else:
|
||||
results = sorted(results, key=lambda k: k[sort_key], reverse=reverse)
|
||||
|
||||
# Paginate results
|
||||
results = results[json_data['start']:(json_data['start'] + json_data['length'])]
|
||||
|
||||
## Find some way to add total disk space used?
|
||||
|
||||
dict = {'recordsFiltered': filtered_count,
|
||||
'recordsTotal': library_count,
|
||||
'data': results,
|
||||
'draw': int(json_data['draw'])
|
||||
}
|
||||
|
||||
## Add total disk space used
|
||||
return dict
|
||||
|
||||
def set_config(self, section_id=None, custom_thumb='', do_notify=1, keep_history=1, do_notify_created=1):
|
||||
|
|
|
@ -292,8 +292,8 @@ class PlexTV(object):
|
|||
for device in sync_device:
|
||||
device_user_id = helpers.get_xml_attr(device, 'userID')
|
||||
try:
|
||||
device_username = user_data.get_user_details(user_id=device_user_id)['username']
|
||||
device_friendly_name = user_data.get_user_details(user_id=device_user_id)['friendly_name']
|
||||
device_username = user_data.get_details(user_id=device_user_id)['username']
|
||||
device_friendly_name = user_data.get_details(user_id=device_user_id)['friendly_name']
|
||||
except:
|
||||
device_username = ''
|
||||
device_friendly_name = ''
|
||||
|
|
|
@ -1632,21 +1632,20 @@ class PmsConnect(object):
|
|||
item_main = []
|
||||
|
||||
for item in item_main:
|
||||
item_info = {'section_id': helpers.get_xml_attr(item, 'key'),
|
||||
'section_type': helpers.get_xml_attr(item, 'type'),
|
||||
item_info = {'section_id': helpers.get_xml_attr(a, 'librarySectionID'),
|
||||
'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'),
|
||||
'grandparent_rating_key': helpers.get_xml_attr(a, 'grandparentRatingKey'),
|
||||
'title': helpers.get_xml_attr(item, 'title'),
|
||||
'parent_title': helpers.get_xml_attr(item, 'parentTitle'),
|
||||
'grandparent_title': helpers.get_xml_attr(item, 'grandparentTitle'),
|
||||
'parent_title': helpers.get_xml_attr(a, 'parentTitle'),
|
||||
'grandparent_title': helpers.get_xml_attr(a, 'grandparentTitle'),
|
||||
'media_index': helpers.get_xml_attr(item, 'index'),
|
||||
'parent_media_index': helpers.get_xml_attr(item, 'parentIndex'),
|
||||
'parent_media_index': helpers.get_xml_attr(a, 'parentIndex'),
|
||||
'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'),
|
||||
'parent_thumb': helpers.get_xml_attr(a, 'thumb'),
|
||||
'grandparent_thumb': helpers.get_xml_attr(a, 'grandparentThumb'),
|
||||
'added_at': helpers.get_xml_attr(item, 'addedAt')
|
||||
}
|
||||
|
||||
|
|
|
@ -883,14 +883,11 @@ class WebInterface(object):
|
|||
@cherrypy.expose
|
||||
def get_sync(self, machine_id=None, user_id=None, **kwargs):
|
||||
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
server_id = pms_connect.get_server_identity()
|
||||
if not machine_id:
|
||||
machine_id = plexpy.CONFIG.PMS_IDENTIFIER
|
||||
|
||||
plex_tv = plextv.PlexTV()
|
||||
if not machine_id:
|
||||
result = plex_tv.get_synced_items(machine_id=server_id['machine_identifier'], user_id=user_id)
|
||||
else:
|
||||
result = plex_tv.get_synced_items(machine_id=machine_id, user_id=user_id)
|
||||
result = plex_tv.get_synced_items(machine_id=machine_id, user_id=user_id)
|
||||
|
||||
if result:
|
||||
output = {"data": result}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue