Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

homebridge-website-to-camera

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-website-to-camera - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

8

CameraSource.js

@@ -15,3 +15,3 @@ "use strict";

this.streamControllers = [];
this.screenshotHelper = new ScreenshotHelper(log, conf.url, conf.width, conf.height, conf.chromiumPath)
this.screenshotHelper = new ScreenshotHelper(log, conf.url, conf.chromiumPath)

@@ -63,8 +63,12 @@ this.pendingSessions = {};

Camera.prototype.handleSnapshotRequest = function (request, callback) {
this.screenshotHelper.getScreenshot()
let width = this.conf.width || (request.width * (this.conf.scale || 2));
let height = this.conf.height || (request.height * (this.conf.scale || 2));
this.screenshotHelper.getScreenshot(width, height)
.then(
img => {
this.log("Got screenshot");
callback(null, img);
},
reason => {
this.log(reason);
callback(reason);

@@ -71,0 +75,0 @@ })

@@ -17,6 +17,10 @@ {

"name": "Google Maps Traffic",
"url": "",
"renderDelay": 2000,
"width": 1280,
"height": 800
"url": "http://google.com",
"height": 1334,
"width": 750
},
{
"name": "Google Maps Traffic #2",
"url": "http://google.com",
"scale": 1
}

@@ -23,0 +27,0 @@ ]

{
"name": "homebridge-website-to-camera",
"version": "1.1.1",
"version": "1.2.0",
"description": "shows the screenshot of a website as camera (image)",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -31,4 +31,2 @@ # homebridge-website-to-camera

"url": "http://github.com",
"width": 800,
"height": 400,
"chromiumPath": "/usr/bin/chromium-browser"

@@ -41,2 +39,4 @@ }

**You can add multiple cameras!**
## Config file

@@ -52,4 +52,5 @@

* `url` the URL of the website that is to be captured (required)
* `width` the width of the virtual browser window (defaults to 640)
* `height` the height of the virtual browser window (defaults to 360)
* `scale` HomeApp requests an (probably device dependent) size for the preview-image.
With e.g. `scale` set to `2` (default) the virtual browser window is set to this size. Best is to skip this field.
* OR `width` / `height` the width/height of the virtual browser window. This is optional and overrides `scale`.
* `chromiumPath` path to chromium-executable (defaults to "/usr/bin/chromium-browser")

@@ -72,2 +73,2 @@

* Live-Video not working yet
* Live-Video not working. As far as I understood HomeKit requires an RTSP-stream where it can connect to. So this feature might not come at all.

@@ -5,6 +5,4 @@ const puppeteer = require('puppeteer');

function ScreenshotHelper(log, url, width = 640, height = 360, chromiumPath = "/usr/bin/chromium-browser") {
function ScreenshotHelper(log, url, chromiumPath = "/usr/bin/chromium-browser") {
this.log = log;
this.width = width;
this.height = height;
this.url = url;

@@ -15,3 +13,3 @@ this.chromiumPath = chromiumPath;

ScreenshotHelper.prototype.getScreenshot = async function () {
ScreenshotHelper.prototype.getScreenshot = async function (width, height) {
if (!this.browser) {

@@ -22,10 +20,12 @@ this.log("Starting new instance of Chromium: " + this.chromiumPath);

}
this.log("Opening new page");
const page = await this.browser.newPage();
await page.setViewport({width: 640, height: 360});
this.log("Setting Viewport to " + width + "x" + height);
await page.setViewport({width: width, height: height});
this.log("Going to page: " + this.url);
await page.goto(this.url, {waitUntil: 'networkidle0', timeout: 6000});
await page.setViewport({width: this.width, height: this.height});
await page.goto(this.url, {waitUntil: 'networkidle0', timeout: 10000});
const screenshot = await page.screenshot({type: "jpeg"});
this.log("Created screenshot");
page.close();
return screenshot;
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc