From 41d09066fee10f95bea6030e2efe7e4a0d4f023d Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 25 Jul 2015 12:48:15 +0200 Subject: [PATCH] Users recently watched should also use the history db for metadata. --- .../default/user_recently_watched.html | 3 +- plexpy/datafactory.py | 35 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/data/interfaces/default/user_recently_watched.html b/data/interfaces/default/user_recently_watched.html index 76ed681f..812a93ff 100644 --- a/data/interfaces/default/user_recently_watched.html +++ b/data/interfaces/default/user_recently_watched.html @@ -11,6 +11,7 @@ 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'. thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. time Returns the last watched time of the media. @@ -34,7 +35,7 @@ DOCUMENTATION :: END
  • diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 8cd090e1..b7a9e61a 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -593,22 +593,22 @@ class DataFactory(object): try: if user_id: - query = 'SELECT session_history.media_type, session_history.rating_key, title, thumb, parent_thumb, ' \ - 'media_index, parent_media_index, year, started, user ' \ + query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, ' \ + 'thumb, parent_thumb, media_index, parent_media_index, year, started, user ' \ 'FROM session_history_metadata ' \ 'JOIN session_history ON session_history_metadata.id = session_history.id ' \ 'WHERE user_id = ? ORDER BY started DESC LIMIT ?' result = monitor_db.select(query, args=[user_id, limit]) elif user: - query = 'SELECT session_history.media_type, session_history.rating_key, title, thumb, parent_thumb, ' \ - 'media_index, parent_media_index, year, started, user ' \ + query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, ' \ + 'thumb, parent_thumb, media_index, parent_media_index, year, started, user ' \ 'FROM session_history_metadata ' \ 'JOIN session_history ON session_history_metadata.id = session_history.id ' \ 'WHERE user = ? ORDER BY started DESC LIMIT ?' result = monitor_db.select(query, args=[user, limit]) else: - query = 'SELECT session_history.media_type, session_history.rating_key, title, thumb, parent_thumb, ' \ - 'media_index, parent_media_index, year, started, user ' \ + query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, ' \ + 'thumb, parent_thumb, media_index, parent_media_index, year, started, user ' \ 'FROM session_history_metadata ' \ 'JOIN session_history ON session_history_metadata.id = session_history.id ' \ 'ORDER BY started DESC LIMIT ?' @@ -618,20 +618,21 @@ class DataFactory(object): return None for row in result: - if row[0] == 'episode': - thumb = row[4] + if row[1] == 'episode': + thumb = row[5] else: - thumb = row[3] + thumb = row[4] - recent_output = {'type': row[0], - 'rating_key': row[1], - 'title': row[2], + recent_output = {'row_id': row[0], + 'type': row[1], + 'rating_key': row[2], + 'title': row[3], 'thumb': thumb, - 'index': row[5], - 'parentIndex': row[6], - 'year': row[7], - 'time': row[8], - 'user': row[9] + 'index': row[6], + 'parentIndex': row[7], + 'year': row[8], + 'time': row[9], + 'user': row[10] } recently_watched.append(recent_output)