|
4 | 4 |
|
5 | 5 | from plexapi import media, utils |
6 | 6 | from plexapi.base import Playable, PlexPartialObject, PlexSession |
7 | | -from plexapi.exceptions import BadRequest |
| 7 | +from plexapi.exceptions import BadRequest, NotFound |
8 | 8 | from plexapi.mixins import ( |
9 | 9 | AdvancedSettingsMixin, SplitMergeMixin, UnmatchMatchMixin, ExtrasMixin, HubsMixin, PlayedUnplayedMixin, RatingMixin, |
10 | 10 | ArtUrlMixin, ArtMixin, PosterUrlMixin, PosterMixin, ThemeMixin, ThemeUrlMixin, |
@@ -181,13 +181,14 @@ def album(self, title): |
181 | 181 | Parameters: |
182 | 182 | title (str): Title of the album to return. |
183 | 183 | """ |
184 | | - key = f"/library/sections/{self.librarySectionID}/all?artist.id={self.ratingKey}&type=9" |
185 | | - return self.fetchItem(key, Album, title__iexact=title) |
| 184 | + try: |
| 185 | + return self.section().search(title, libtype='album', filters={'artist.id': self.ratingKey})[0] |
| 186 | + except IndexError: |
| 187 | + raise NotFound(f"Unable to find album '{title}'") from None |
186 | 188 |
|
187 | 189 | def albums(self, **kwargs): |
188 | 190 | """ Returns a list of :class:`~plexapi.audio.Album` objects by the artist. """ |
189 | | - key = f"/library/sections/{self.librarySectionID}/all?artist.id={self.ratingKey}&type=9" |
190 | | - return self.fetchItems(key, Album, **kwargs) |
| 191 | + return self.section().search(libtype='album', filters={'artist.id': self.ratingKey}, **kwargs) |
191 | 192 |
|
192 | 193 | def track(self, title=None, album=None, track=None): |
193 | 194 | """ Returns the :class:`~plexapi.audio.Track` that matches the specified title. |
|
0 commit comments