77from .parser import parse_data , parse_library
88
99
10+ import logging
11+ _LOGGER = logging .getLogger (__name__ )
12+
1013class PlexApi ():
1114 def __init__ (
1215 self ,
@@ -52,7 +55,11 @@ def update(self):
5255 info_res = requests .get (info_url + "/" , headers = {
5356 "X-Plex-Token" : self ._token
5457 }, timeout = 10 )
55- root = ElementTree .fromstring (info_res .text )
58+ try :
59+ root = ElementTree .fromstring (info_res .text )
60+ except :
61+ _LOGGER .error (info_res .text )
62+ raise ElementTree .ParseError
5663 identifier = root .get ("machineIdentifier" )
5764 except OSError as e :
5865 raise FailedToLogin
@@ -69,7 +76,11 @@ def update(self):
6976 libraries = requests .get (all_libraries , headers = {
7077 "X-Plex-Token" : self ._token
7178 }, timeout = 10 )
72- root = ElementTree .fromstring (libraries .text )
79+ try :
80+ root = ElementTree .fromstring (libraries .text )
81+ except :
82+ _LOGGER .error (libraries .text )
83+ raise ElementTree .ParseError
7384 for lib in root .findall ("Directory" ):
7485 libs .append (lib .get ("title" ))
7586 if lib .get ("type" ) in self ._section_types and (len (self ._section_libraries ) == 0 or lib .get ("title" ) in self ._section_libraries ):
@@ -84,7 +95,11 @@ def update(self):
8495 sub_sec = requests .get (recent_or_deck .format (library , self ._max * 2 ), headers = {
8596 "X-Plex-Token" : self ._token
8697 }, timeout = 10 )
87- root = ElementTree .fromstring (sub_sec .text )
98+ try :
99+ root = ElementTree .fromstring (sub_sec .text )
100+ except :
101+ _LOGGER .error (sub_sec .text )
102+ raise ElementTree .ParseError
88103 data += parse_library (root )
89104
90105 return {
0 commit comments