Skip to content

Commit

Permalink
cli: update
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Feb 28, 2023
1 parent a5cb8c3 commit fed1cf2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
7 changes: 4 additions & 3 deletions packages/cli/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"configurations": [
{
"console": "integratedTerminal",
"type": "pwa-node",
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
Expand All @@ -20,8 +20,9 @@
"ts-node/register"
],
"args": [
"install",
"@scrypted/google-device-access"
"ffplay",
"Kitchen",
"getVideoStream"
],
"sourceMaps": true,
"resolveSourceMapLocations": [
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrypted",
"version": "1.0.57",
"version": "1.0.58",
"description": "",
"main": "./dist/packages/cli/src/main.js",
"bin": {
Expand Down
22 changes: 18 additions & 4 deletions packages/cli/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import https from 'https';
import mkdirp from 'mkdirp';
import { installServe, serveMain } from './service';
import { connectScryptedClient } from '../../client/src/index';
import { ScryptedMimeTypes, FFMpegInput } from '@scrypted/types';
import { ScryptedMimeTypes, FFmpegInput } from '../../../sdk/types/src/types.input';
import semver from 'semver';
import child_process from 'child_process';

const httpsAgent = new https.Agent({
rejectUnauthorized: false,
});

if (!semver.gte(process.version, '16.0.0')) {
throw new Error('"node" version out of date. Please update node to v16 or higher.')
}
Expand Down Expand Up @@ -57,6 +61,7 @@ async function doLogin(host: string) {
password,
},
url,
httpsAgent,
}, axiosConfig));

mkdirp.sync(scryptedHome);
Expand Down Expand Up @@ -112,6 +117,9 @@ async function runCommand() {
pluginId: '@scrypted/core',
username: login.username,
password: login.token,
axiosConfig: {
httpsAgent,
}
});

const device: any = sdk.systemManager.getDeviceById(idOrName) || sdk.systemManager.getDeviceByName(idOrName);
Expand Down Expand Up @@ -157,9 +165,15 @@ async function main() {
}
else if (process.argv[2] === 'ffplay') {
const { sdk, pendingResult } = await runCommand();
const ffinput = await sdk.mediaManager.convertMediaObjectToJSON<FFMpegInput>(await pendingResult, ScryptedMimeTypes.FFmpegInput);
console.log(ffinput);
child_process.spawn('ffplay', ffinput.inputArguments, {
const ffmpegInput = await sdk.mediaManager.convertMediaObjectToJSON<FFmpegInput>(await pendingResult, ScryptedMimeTypes.FFmpegInput);
if (ffmpegInput.url && ffmpegInput.urls?.[0]) {
const url = new URL(ffmpegInput.url);
if (url.hostname === '127.0.0.1' && ffmpegInput.urls?.[0]) {
ffmpegInput.inputArguments = ffmpegInput.inputArguments.map(i => i === ffmpegInput.url ? ffmpegInput.urls?.[0] : i);
}
}
console.log('ffplay', ...ffmpegInput.inputArguments);
child_process.spawn('ffplay', ffmpegInput.inputArguments, {
stdio: 'inherit',
});
sdk.disconnect();
Expand Down

0 comments on commit fed1cf2

Please sign in to comment.