diff --git a/MMM-Wallpaper.js b/MMM-Wallpaper.js index b5de692..2557375 100644 --- a/MMM-Wallpaper.js +++ b/MMM-Wallpaper.js @@ -25,6 +25,8 @@ Module.register("MMM-Wallpaper", { flickrDataCacheTime: 24 * 60 * 60 * 1000, flickrResultsPerPage: 500, // Flickr API is limited to 500 photos per page fadeEdges: false, + recurseLocalDirectories: false, + blacklist: [] }, getStyles: function() { diff --git a/README.md b/README.md index ee43ddf..9a7077b 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ local: |Option|Default|Description| |---|---|---| |`"recurseLocalDirectories"`|`false`|Whether to recurse into subdirectories when looking for images.| +|`"blacklist"`| `[]`| An array of strings. Any path containing an element of this array as a substring will not be considered.| ## Notifications diff --git a/node_helper.js b/node_helper.js index 187e8c2..405d8c4 100644 --- a/node_helper.js +++ b/node_helper.js @@ -184,6 +184,7 @@ module.exports = NodeHelper.create({ const sourcePath = config.source.substring(6).trim(); const urlPath = `/${self.name}/images/${result.key}/`; const fileMatcher = /\.(?:a?png|avif|gif|p?jpe?g|jfif|pjp|svg|webp|bmp)$/; + const blacklist = config.blacklist; if (!(result.key in self.handlers)) { var handler = express.static(sourcePath); @@ -196,8 +197,18 @@ module.exports = NodeHelper.create({ const dirents = await fs.promises.readdir(dir, { withFileTypes: true }); let result = []; + outer: for (const dirent of dirents) { const entpath = path.resolve(dir, dirent.name); + + if (blacklist) { + for (const entry of blacklist) { + if (entpath.includes(entry)) { + continue outer + } + } + } + if (dirent.isDirectory() && config.recurseLocalDirectories) { result = result.concat(await getFiles(entpath, `${prefix}${dirent.name}/`)); } else if (dirent.isFile() && dirent.name.toLowerCase().match(fileMatcher) != null) {