kolbyjack / MMM-Wallpaper

MagicMirror module to display wallpapers from various online sources
https://magicmirror.builders/
MIT License
99 stars 31 forks source link

Feature Request: Images From Chromecast Background (Pull Request Created) #11

Closed JaffaKetchup closed 4 years ago

JaffaKetchup commented 4 years ago

Hello!

I've used this repo for a long time now. And I've tweaked it a bit. It now works with Chromecast images, thanks to this raw content from a github repo I found. I have attached the updated files inside a zip folder below. The changes have been made to node_helper.js, and I've added chromecast.json as the resource list: updatedFilesToCreateChromecastFunctionality.zip. The link to the forked repo I made for this is here. And this is a link to the pull request.

Unfortunately, I haven't had the time to create a caption for every single new image, so I just used Find & Replace to find all "}," and replace with ",'caption':''},", which worked a treat. I also surrounded it by the 'images' array. In the helper script I added "self.chromecast = JSON.parse(fs.readFileSync(fmt("{}/chromecast.json", __dirname)));" after the firetv line. I also added this to list of if statements:

} else if (source === "chromecast") {
        self.sendSocketNotification("WALLPAPERS", {
        "source": config.source,
        "orientation": config.orientation,
        "images": shuffle(self.chromecast.images).slice(0, config.maximumEntries),
      });
      return;
    }

This all works a treat. All that's needed is for the user to change the 'source' setting in the main config file to "chromecast".

Hope you use this, please (if you want) mention me in the readme. Thanks for this library. Bye!