Fix plexivity_import.py

This commit is contained in:
JonnyWong16 2023-04-21 16:20:15 -07:00
commit 8f19a48d03
No known key found for this signature in database
GPG key ID: B1F1F9807184697A

View file

@ -304,27 +304,27 @@ def import_from_plexivity(database_file=None, table_name=None, import_ignore_int
logger.debug("Tautulli Importer :: Unable to refresh the users list. Aborting import.") logger.debug("Tautulli Importer :: Unable to refresh the users list. Aborting import.")
return None return None
query = 'SELECT id AS id, ' \ query = "SELECT id AS id, " \
'time AS started, ' \ "time AS started, " \
'stopped, ' \ "stopped, " \
'null AS user_id, ' \ "null AS user_id, " \
'user, ' \ "user, " \
'ip_address, ' \ "ip_address, " \
'paused_counter, ' \ "paused_counter, " \
'platform AS player, ' \ "platform AS player, " \
'null AS platform, ' \ "null AS platform, " \
'null as machine_id, ' \ "null as machine_id, " \
'null AS media_type, ' \ "null AS media_type, " \
'null AS view_offset, ' \ "null AS view_offset, " \
'xml, ' \ "xml, " \
'rating as content_rating,' \ "rating as content_rating," \
'summary,' \ "summary," \
'title AS full_title,' \ "title AS full_title," \
'(case when orig_title_ep = "n/a" then orig_title else ' \ "(case when orig_title_ep = 'n/a' then orig_title else " \
'orig_title_ep end) as title,' \ "orig_title_ep end) as title," \
'(case when orig_title_ep != "n/a" then orig_title else ' \ "(case when orig_title_ep != 'n/a' then orig_title else " \
'null end) as grandparent_title ' \ "null end) as grandparent_title " \
'FROM ' + table_name + ' ORDER BY id' "FROM " + table_name + " ORDER BY id"
result = connection.execute(query) result = connection.execute(query)
@ -456,9 +456,9 @@ def import_users():
logger.debug("Tautulli Importer :: Importing Plexivity Users...") logger.debug("Tautulli Importer :: Importing Plexivity Users...")
monitor_db = database.MonitorDatabase() monitor_db = database.MonitorDatabase()
query = 'INSERT OR IGNORE INTO users (user_id, username) ' \ query = "INSERT OR IGNORE INTO users (user_id, username) " \
'SELECT user_id, user ' \ "SELECT user_id, user " \
'FROM session_history WHERE user_id != 1 GROUP BY user_id' "FROM session_history WHERE user_id != 1 GROUP BY user_id"
try: try:
monitor_db.action(query) monitor_db.action(query)