Skip to content

Commit aac9346

Browse files
authored
Add some error catching around metadata fields
Just a try and except to allow things to succeed if there is a missing metadata field... this is a hack, and honestly a .get() is a better case here, but this seems to work for me.
1 parent b4c9e4c commit aac9346

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

custom_components/sensor/plex_recently_added.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,12 @@ def update(self):
206206
for library in sections:
207207
sub_sec = plex.get(recently_added.format(
208208
library, self.max_items * 2), headers=headers, timeout=10)
209-
self.api_json += sub_sec.json()['MediaContainer']['Metadata']
209+
try:
210+
_LOGGER.debug(sub_sec.json()['MediaContainer'])
211+
self.api_json += sub_sec.json()['MediaContainer']['Metadata']
212+
except:
213+
_LOGGER.warning('No Metadata field in this library')
214+
pass
210215
self.api_json = sorted(self.api_json, key=lambda i: i['addedAt'],
211216
reverse=True)[:self.max_items]
212217

0 commit comments

Comments
 (0)