mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Fix some log table styling.
Refresh user list on start-up and schedule refresh every 12 hours. Handle malformed lines when reading Plex logs slightly more gracefully. Send back empty list instead of None on some plex.tv requests.
This commit is contained in:
parent
0810584b46
commit
b4f1bddc02
6 changed files with 63 additions and 30 deletions
|
@ -13,7 +13,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from plexpy import logger, helpers, plexwatch
|
||||
from plexpy import logger, helpers, plexwatch, db
|
||||
|
||||
from xml.dom import minidom
|
||||
from httplib import HTTPSConnection
|
||||
|
@ -21,6 +21,29 @@ from httplib import HTTPSConnection
|
|||
import base64
|
||||
import plexpy
|
||||
|
||||
def refresh_users():
|
||||
logger.info("Requesting users list refresh...")
|
||||
result = PlexTV().get_full_users_list()
|
||||
pw_db = db.DBConnection()
|
||||
|
||||
if len(result) > 0:
|
||||
for item in result:
|
||||
control_value_dict = {"username": item['username']}
|
||||
new_value_dict = {"user_id": item['user_id'],
|
||||
"username": item['username'],
|
||||
"thumb": item['thumb'],
|
||||
"email": item['email'],
|
||||
"is_home_user": item['is_home_user'],
|
||||
"is_allow_sync": item['is_allow_sync'],
|
||||
"is_restricted": item['is_restricted']
|
||||
}
|
||||
|
||||
pw_db.upsert('plexpy_users', new_value_dict, control_value_dict)
|
||||
|
||||
logger.info("Users list refreshed.")
|
||||
else:
|
||||
logger.warn("Unable to refresh users list.")
|
||||
|
||||
|
||||
class PlexTV(object):
|
||||
"""
|
||||
|
@ -232,8 +255,10 @@ class PlexTV(object):
|
|||
xml_parse = minidom.parseString(own_account)
|
||||
except Exception, e:
|
||||
logger.warn("Error parsing XML for Plex account details: %s" % e)
|
||||
return []
|
||||
except:
|
||||
logger.warn("Error parsing XML for Plex account details.")
|
||||
return []
|
||||
|
||||
xml_head = xml_parse.getElementsByTagName('user')
|
||||
if not xml_head:
|
||||
|
@ -286,8 +311,10 @@ class PlexTV(object):
|
|||
xml_parse = minidom.parseString(sync_list)
|
||||
except Exception, e:
|
||||
logger.warn("Error parsing XML for Plex sync lists: %s" % e)
|
||||
return []
|
||||
except:
|
||||
logger.warn("Error parsing XML for Plex sync lists.")
|
||||
return []
|
||||
|
||||
xml_head = xml_parse.getElementsByTagName('SyncList')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue