Allow fetch_item to return None on not found error
import datetime
import re
-from typing import List, Optional, Union
+from typing import List, Optional, Union, Any
from plexapi import X_PLEX_CONTAINER_SIZE
from plexapi.exceptions import BadRequest, NotFound, Unauthorized
@@ -448,8 +448,12 @@ def show_sections(self, library=None):
@memoize
@nocache
- def fetch_item(self, key: Union[int, str]):
+ def fetch_item(self, key: Union[int, str]) -> Optional[PlexLibraryItem]:
+ try:
media = self.plex.library.fetchItem(key)
+ except NotFound:
+ return None
+
return PlexLibraryItem(media)
def reload_item(self, pm: PlexLibraryItem):
