Skip to content

Commit 77b1d0e

Browse files
authored
Merge pull request #651 from JonnyWong16/feature/collection_thumb_art
Add thumbUrl and artUrl properties to Collections
2 parents a263f49 + 688bca9 commit 77b1d0e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

plexapi/library.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,17 @@ def _loadData(self, data):
15951595
@deprecated('use "items" instead')
15961596
def children(self):
15971597
return self.fetchItems(self.key)
1598-
1598+
1599+
@property
1600+
def thumbUrl(self):
1601+
""" Return the thumbnail url for the collection."""
1602+
return self._server.url(self.thumb, includeToken=True) if self.thumb else None
1603+
1604+
@property
1605+
def artUrl(self):
1606+
""" Return the art url for the collection."""
1607+
return self._server.url(self.art, includeToken=True) if self.art else None
1608+
15991609
def item(self, title):
16001610
""" Returns the item in the collection that matches the specified title.
16011611

tests/test_library.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ def test_library_Collection_items(collection):
313313
assert len(items) == 1
314314

315315

316+
def test_library_Collection_thumbUrl(collection):
317+
assert utils.SERVER_BASEURL in collection.thumbUrl
318+
assert "/library/collections/" in collection.thumbUrl
319+
assert "/composite/" in collection.thumbUrl
320+
321+
322+
def test_library_Collection_artUrl(collection):
323+
assert collection.artUrl is None # Collections don't have default art
324+
325+
316326
def test_search_with_weird_a(plex):
317327
ep_title = "Coup de Grâce"
318328
result_root = plex.search(ep_title)

0 commit comments

Comments
 (0)