From 5a4ee2179a2491ec6637827fb0efcef03e8c9902 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Thu, 1 Jul 2021 10:41:33 -0700 Subject: [PATCH] Fix guest session user ID in history query * Fixes #1454 --- plexpy/datafactory.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 36ca711c..d413499d 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -71,16 +71,15 @@ class DataFactory(object): for c_where in custom_where: if 'user_id' in c_where[0]: - # This currently only works if c_where[1] is not a list or tuple - if str(c_where[1]) == session_user_id: - added = True - break - else: - c_where[1] = (c_where[1], session_user_id) - added = True + if isinstance(c_where[1], list) and session_user_id not in c_where[1]: + c_where[1].append(session_user_id) + elif isinstance(c_where[1], str) and c_where[1] != session_user_id: + c_where[1] = [c_where[1], session_user_id] + added = True + break if not added: - custom_where.append(['session_history.user_id', session.get_session_user_id()]) + custom_where.append(['session_history.user_id', [session.get_session_user_id()]]) group_by = ['session_history.reference_id'] if grouping else ['session_history.id']