Skip to content

Commit 4993419

Browse files
committed
feat(configuration): added option to specify libraries name
1 parent 83d0be9 commit 4993419

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Read through these two resources before posting issues to GitHub or the forums.
3737
| img_dir | '/upcoming-media-card-images/plex/' | no | This option allows you to choose a custom directory to store images in if you enable download_images. Directory must start and end with a `/`.
3838
| ssl_cert | false | no | If you provide your own SSL certificate in Plex's network settings set this to true.
3939
| section_types | movie, show | no | Allows you to specify which section types to consider [movie, show].
40+
| section_libraries | | no | Allows you to specify which libraries name to consider (if None, all libraries will be considered), for example ['Movies'].
4041
| image_resolution | 200 | no | Allows you to change the resolution of the generated images (in px), useful to display higher quality images as a background somewhere.
4142
| exclude_keywords | | no | Allows you to specify a list of keywords to be exclude from the sensor if in the title.
4243

custom_components/plex_recently_added/sensor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async def request(url, self, content=False, ssl=False):
5252
CONF_MAX = 'max'
5353
CONF_IMG_CACHE = 'img_dir'
5454
CONF_SECTION_TYPES = 'section_types'
55+
CONF_SECTION_LIBRARIES = 'section_libraries'
5556
CONF_EXCLUDE_KEYWORDS = 'exclude_keywords'
5657
CONF_RESOLUTION = 'image_resolution'
5758
CONF_ON_DECK = 'on_deck'
@@ -69,6 +70,8 @@ async def request(url, self, content=False, ssl=False):
6970
vol.Optional(CONF_PORT, default=32400): cv.port,
7071
vol.Optional(CONF_SECTION_TYPES,
7172
default=['movie', 'show']): vol.All(cv.ensure_list, [cv.string]),
73+
vol.Optional(CONF_SECTION_LIBRARIES):
74+
vol.All(cv.ensure_list, [cv.string]),
7275
vol.Optional(CONF_EXCLUDE_KEYWORDS):
7376
vol.All(cv.ensure_list, [cv.string]),
7477
vol.Optional(CONF_RESOLUTION, default=200): cv.positive_int,
@@ -103,6 +106,7 @@ def __init__(self, hass, conf, name):
103106
self.dl_images = conf.get(CONF_DL_IMAGES)
104107
self.on_deck = conf.get(CONF_ON_DECK)
105108
self.sections = conf.get(CONF_SECTION_TYPES)
109+
self.libraries = conf.get(CONF_SECTION_LIBRARIES)
106110
self.excludes = conf.get(CONF_EXCLUDE_KEYWORDS)
107111
self.resolution = conf.get(CONF_RESOLUTION)
108112
if self.server_name:
@@ -252,8 +256,9 @@ async def async_update(self):
252256
self._state = '%s cannot be reached' % self.server_ip
253257
return
254258
libraries = json.loads(libraries)
259+
255260
for lib_section in libraries['MediaContainer']['Directory']:
256-
if lib_section['type'] in self.sections:
261+
if lib_section['type'] in self.sections and (self.libraries is None or lib_section['title'] in self.libraries):
257262
sections.append(lib_section['key'])
258263
except OSError:
259264
_LOGGER.warning("Host %s is not available", self.server_ip)

0 commit comments

Comments
 (0)