Skip to content

Commit 9a2a0c1

Browse files
committed
fix: plex rss startswith error
1 parent 12f4a1a commit 9a2a0c1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/program/content/plex_watchlist.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def run(self) -> Generator[MediaItem, None, None]:
6868
return
6969

7070
plex_items: set[str] = set(watchlist_items) | set(rss_items)
71-
items_to_yield: list[MediaItem] = [MediaItem({"imdb_id": imdb_id, "requested_by": self.key}) for imdb_id in plex_items if imdb_id.startswith("tt")]
71+
items_to_yield: list[MediaItem] = [MediaItem({"imdb_id": imdb_id, "requested_by": self.key}) for imdb_id in plex_items if imdb_id and imdb_id.startswith("tt")]
7272
non_existing_items = _filter_existing_items(items_to_yield)
7373
new_non_recurring_items = [item for item in non_existing_items if item.imdb_id not in self.recurring_items and isinstance(item, MediaItem)]
7474
self.recurring_items.update([item.imdb_id for item in new_non_recurring_items])
@@ -86,7 +86,7 @@ def _get_items_from_rss(self) -> list[str]:
8686
response = self.session.get(rss_url + "?format=json", timeout=60)
8787
for _item in response.json().get("items", []):
8888
imdb_id = self._extract_imdb_ids(_item.get("guids", []))
89-
if imdb_id.startswith("tt"):
89+
if imdb_id and imdb_id.startswith("tt"):
9090
rss_items.append(imdb_id)
9191
else:
9292
logger.log("NOT_FOUND", f"Failed to extract IMDb ID from {_item['title']}")
@@ -102,7 +102,7 @@ def _get_items_from_watchlist(self) -> list[str]:
102102
try:
103103
if hasattr(item, "guids") and item.guids:
104104
imdb_id: str = next((guid.id.split("//")[-1] for guid in item.guids if guid.id.startswith("imdb://")), "")
105-
if imdb_id.startswith("tt"):
105+
if imdb_id and imdb_id.startswith("tt"):
106106
watchlist_items.append(imdb_id)
107107
else:
108108
logger.log("NOT_FOUND", f"Unable to extract IMDb ID from {item.title} ({item.year}) with data id: {imdb_id}")
@@ -115,7 +115,7 @@ def _get_items_from_watchlist(self) -> list[str]:
115115
def _extract_imdb_ids(self, guids: list) -> str | None:
116116
"""Helper method to extract IMDb IDs from guids"""
117117
for guid in guids:
118-
if guid.startswith("imdb://"):
118+
if guid and guid.startswith("imdb://"):
119119
imdb_id = guid.split("//")[-1]
120120
if imdb_id:
121121
return imdb_id

src/program/indexers/trakt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def get_show_aliases(imdb_id: str, item_type: str) -> List[dict]:
196196
for ns in response.data:
197197
country = ns.country
198198
title = ns.title
199-
if title.startswith("Anime-"):
199+
if title and title.startswith("Anime-"):
200200
title = title[len("Anime-"):]
201201
if country not in aliases:
202202
aliases[country] = []

0 commit comments

Comments
 (0)