Skip to content

Commit 391a7d3

Browse files
committed
Log add
1 parent 6a2e220 commit 391a7d3

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

custom_components/plex_recently_added/plex_api.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from .parser import parse_data, parse_library
88

99

10+
import logging
11+
_LOGGER = logging.getLogger(__name__)
12+
1013
class 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

Comments
 (0)