Skip to content

Commit fe7b02c

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 9f6dc42 + 94fcc53 commit fe7b02c

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
@@ -36,6 +36,7 @@ Read through these two resources before posting issues to GitHub or the forums.
3636
| 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 `/`.
3737
| ssl_cert | false | no | If you provide your own SSL certificate in Plex's network settings set this to true.
3838
| section_types | movie, show | no | Allows you to specify which section types to consider [movie, show].
39+
| section_libraries | | no | Allows you to specify which libraries name to consider (if None, all libraries will be considered), for example ['Movies'].
3940
| 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.
4041
| exclude_keywords | | no | Allows you to specify a list of keywords to be exclude from the sensor if in the title.
4142

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:
@@ -245,8 +249,9 @@ async def async_update(self):
245249
self._state = '%s cannot be reached' % self.server_ip
246250
return
247251
libraries = json.loads(libraries)
252+
248253
for lib_section in libraries['MediaContainer']['Directory']:
249-
if lib_section['type'] in self.sections:
254+
if lib_section['type'] in self.sections and (self.libraries is None or lib_section['title'] in self.libraries):
250255
sections.append(lib_section['key'])
251256
except OSError:
252257
_LOGGER.warning("Host %s is not available", self.server_ip)

0 commit comments

Comments
 (0)