@sebbo2002/node-pyatv 4.0.0 → 4.2.0-develop.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -5
- package/dist/lib/device-event.d.ts +1 -1
- package/dist/lib/device-events.d.ts +1 -2
- package/dist/lib/device-events.js +26 -24
- package/dist/lib/device-events.js.map +1 -1
- package/dist/lib/device.d.ts +1 -1
- package/dist/lib/device.js +19 -18
- package/dist/lib/device.js.map +1 -1
- package/dist/lib/index.d.ts +3 -1
- package/dist/lib/index.js +7 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/instance.d.ts +1 -1
- package/dist/lib/instance.js +13 -13
- package/dist/lib/instance.js.map +1 -1
- package/dist/lib/tools.js +13 -0
- package/dist/lib/tools.js.map +1 -1
- package/dist/lib/types.d.ts +3 -0
- package/docs/coverage/cobertura-coverage.xml +671 -635
- package/docs/coverage/device-event.ts.html +2 -2
- package/docs/coverage/device-events.ts.html +99 -87
- package/docs/coverage/device.ts.html +38 -26
- package/docs/coverage/fake-spawn.ts.html +25 -25
- package/docs/coverage/index.html +29 -29
- package/docs/coverage/index.ts.html +22 -7
- package/docs/coverage/instance.ts.html +2 -2
- package/docs/coverage/tools.ts.html +149 -107
- package/docs/coverage/types.ts.html +11 -2
- package/docs/reference/.nojekyll +1 -0
- package/docs/reference/assets/highlight.css +99 -0
- package/docs/reference/assets/icons.css +1043 -0
- package/docs/reference/assets/{images/icons.png → icons.png} +0 -0
- package/docs/reference/assets/{images/icons@2x.png → icons@2x.png} +0 -0
- package/docs/reference/assets/main.js +52 -0
- package/docs/reference/assets/search.js +1 -0
- package/docs/reference/assets/style.css +1388 -0
- package/docs/reference/assets/{images/widgets.png → widgets.png} +0 -0
- package/docs/reference/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
- package/docs/reference/classes/NodePyATVDevice.html +147 -0
- package/docs/reference/classes/NodePyATVDeviceEvent.html +13 -3190
- package/docs/reference/classes/default.html +46 -3402
- package/docs/reference/enums/NodePyATVDeviceState.html +1 -3131
- package/docs/reference/enums/NodePyATVKeys.html +1 -3341
- package/docs/reference/enums/NodePyATVListenerState.html +1 -0
- package/docs/reference/enums/NodePyATVMediaType.html +1 -3103
- package/docs/reference/enums/NodePyATVPowerState.html +1 -0
- package/docs/reference/enums/NodePyATVProtocol.html +1 -3103
- package/docs/reference/enums/NodePyATVRepeatState.html +1 -3089
- package/docs/reference/enums/NodePyATVShuffleState.html +1 -3089
- package/docs/reference/index.html +74 -3150
- package/docs/reference/interfaces/NodePyATVDeviceOptions.html +1 -3281
- package/docs/reference/interfaces/NodePyATVFindAndInstanceOptions.html +1 -3275
- package/docs/reference/interfaces/NodePyATVFindOptions.html +1 -3158
- package/docs/reference/interfaces/NodePyATVGetStateOptions.html +1 -3069
- package/docs/reference/interfaces/NodePyATVInstanceOptions.html +1 -3157
- package/docs/reference/interfaces/NodePyATVState.html +1 -3265
- package/docs/reference/interfaces/NodePyATVVersionResponse.html +1 -3083
- package/docs/reference/modules.html +1 -3154
- package/docs/tests/assets/app.css +1 -1
- package/docs/tests/assets/app.js +2 -2
- package/docs/tests/assets/app.js.LICENSE.txt +1 -1
- package/docs/tests/index.html +1 -1
- package/docs/tests/mochawesome.json +793 -698
- package/package.json +19 -18
- package/src/lib/device-event.ts +1 -1
- package/src/lib/device-events.ts +8 -4
- package/src/lib/device.ts +12 -8
- package/src/lib/index.ts +6 -1
- package/src/lib/instance.ts +1 -1
- package/src/lib/tools.ts +14 -0
- package/src/lib/types.ts +3 -0
- package/test/device-events.ts +24 -3
- package/test/device.ts +18 -0
- package/test/instance.ts +9 -1
- package/test/tools.ts +21 -6
- package/typedoc.json +2 -2
- package/docs/reference/assets/css/main.css +0 -2660
- package/docs/reference/assets/js/main.js +0 -248
- package/docs/reference/assets/js/search.js +0 -1
package/package.json
CHANGED
|
@@ -9,27 +9,28 @@
|
|
|
9
9
|
},
|
|
10
10
|
"description": "A lightweight wrapper around pyatv…",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@amanda-mitchell/semantic-release-npm-multiple": "^2.
|
|
13
|
-
"@qiwi/semantic-release-gh-pages-plugin": "^5.
|
|
14
|
-
"@semantic-release/changelog": "^
|
|
15
|
-
"@semantic-release/exec": "^
|
|
16
|
-
"@semantic-release/git": "^
|
|
12
|
+
"@amanda-mitchell/semantic-release-npm-multiple": "^2.15.0",
|
|
13
|
+
"@qiwi/semantic-release-gh-pages-plugin": "^5.2.0",
|
|
14
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
15
|
+
"@semantic-release/exec": "^6.0.2",
|
|
16
|
+
"@semantic-release/git": "^10.0.1",
|
|
17
17
|
"@types/mocha": "^9.0.0",
|
|
18
|
-
"@types/node": "^16.
|
|
19
|
-
"@types/semver": "^7.3.
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
21
|
-
"@typescript-eslint/parser": "^4.
|
|
22
|
-
"eslint": "^
|
|
23
|
-
"eslint-plugin-jsonc": "^
|
|
18
|
+
"@types/node": "^16.11.9",
|
|
19
|
+
"@types/semver": "^7.3.9",
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
21
|
+
"@typescript-eslint/parser": "^5.4.0",
|
|
22
|
+
"eslint": "^8.3.0",
|
|
23
|
+
"eslint-plugin-jsonc": "^2.0.0",
|
|
24
24
|
"license-checker": "^25.0.1",
|
|
25
|
-
"mocha": "^9.
|
|
26
|
-
"mochawesome": "^
|
|
25
|
+
"mocha": "^9.1.3",
|
|
26
|
+
"mochawesome": "^7.0.1",
|
|
27
27
|
"nyc": "^15.1.0",
|
|
28
|
-
"semantic-release": "^
|
|
28
|
+
"semantic-release": "^18.0.0",
|
|
29
29
|
"semantic-release-license": "^1.0.3",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
30
|
+
"source-map-support": "^0.5.21",
|
|
31
|
+
"ts-node": "^10.4.0",
|
|
32
|
+
"typedoc": "^0.22.9",
|
|
33
|
+
"typescript": "^4.5.2"
|
|
33
34
|
},
|
|
34
35
|
"engines": {
|
|
35
36
|
"node": ">=12.0.0"
|
|
@@ -54,5 +55,5 @@
|
|
|
54
55
|
"postinstall": "./check.sh",
|
|
55
56
|
"test": "mocha"
|
|
56
57
|
},
|
|
57
|
-
"version": "4.0.
|
|
58
|
+
"version": "4.2.0-develop.2"
|
|
58
59
|
}
|
package/src/lib/device-event.ts
CHANGED
package/src/lib/device-events.ts
CHANGED
|
@@ -11,8 +11,7 @@ import {
|
|
|
11
11
|
import {ChildProcess} from 'child_process';
|
|
12
12
|
|
|
13
13
|
import {EventEmitter} from 'events';
|
|
14
|
-
import NodePyATVDevice from '
|
|
15
|
-
import NodePyATVDeviceEvent from './device-event';
|
|
14
|
+
import {NodePyATVDevice, NodePyATVDeviceEvent} from '../lib';
|
|
16
15
|
import {addRequestId, debug, execute, getParamters, parseState, removeRequestId} from './tools';
|
|
17
16
|
import {FakeChildProcess} from './fake-spawn';
|
|
18
17
|
|
|
@@ -91,8 +90,13 @@ export default class NodePyATVDeviceEvents extends EventEmitter {
|
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
private applyPushUpdate(update: NodePyATVInternalState, reqId: string): void {
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
try {
|
|
94
|
+
const newState = parseState(update, reqId, this.options);
|
|
95
|
+
this.applyStateAndEmitEvents(newState);
|
|
96
|
+
}
|
|
97
|
+
catch(error) {
|
|
98
|
+
this.emit('error', error);
|
|
99
|
+
}
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
private checkListener(): void {
|
package/src/lib/device.ts
CHANGED
|
@@ -14,8 +14,7 @@ import {
|
|
|
14
14
|
} from './types';
|
|
15
15
|
|
|
16
16
|
import {addRequestId, getParamters, parseState, removeRequestId, request} from './tools';
|
|
17
|
-
import NodePyATVDeviceEvents from '
|
|
18
|
-
import NodePyATVDeviceEvent from './device-event';
|
|
17
|
+
import {NodePyATVDeviceEvents, NodePyATVDeviceEvent} from '../lib';
|
|
19
18
|
import { EventEmitter } from 'events';
|
|
20
19
|
|
|
21
20
|
/**
|
|
@@ -148,14 +147,19 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
const id = addRequestId();
|
|
151
|
-
const parameters = getParamters(this.options);
|
|
152
150
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
this.applyState(newState);
|
|
151
|
+
try {
|
|
152
|
+
const parameters = getParamters(this.options);
|
|
156
153
|
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
const result = await request(id, NodePyATVExecutableType.atvscript, [...parameters, 'playing'], this.options);
|
|
155
|
+
const newState = parseState(result, id, this.options);
|
|
156
|
+
|
|
157
|
+
this.applyState(newState);
|
|
158
|
+
return newState;
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
removeRequestId(id);
|
|
162
|
+
}
|
|
159
163
|
}
|
|
160
164
|
|
|
161
165
|
/**
|
package/src/lib/index.ts
CHANGED
|
@@ -13,9 +13,14 @@ export {
|
|
|
13
13
|
NodePyATVFindAndInstanceOptions,
|
|
14
14
|
NodePyATVDeviceOptions,
|
|
15
15
|
NodePyATVGetStateOptions,
|
|
16
|
-
NodePyATVState
|
|
16
|
+
NodePyATVState,
|
|
17
|
+
NodePyATVPowerState,
|
|
18
|
+
NodePyATVListenerState,
|
|
19
|
+
NodePyATVEventValueType,
|
|
17
20
|
} from './types';
|
|
18
21
|
|
|
19
22
|
export {default as NodePyATVDeviceEvent} from './device-event';
|
|
23
|
+
export {default as NodePyATVDeviceEvents} from './device-events';
|
|
24
|
+
export {default as NodePyATVDevice} from './device';
|
|
20
25
|
|
|
21
26
|
export {default} from './instance';
|
package/src/lib/instance.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from './types';
|
|
12
12
|
|
|
13
13
|
import {addRequestId, debug, getParamters, removeRequestId, request} from './tools';
|
|
14
|
-
import NodePyATVDevice from '
|
|
14
|
+
import {NodePyATVDevice} from '../lib';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Default class exported by `@sebbo2002/node-pyatv`. Use [[find]] to scan for devices in your local network. Use
|
package/src/lib/tools.ts
CHANGED
|
@@ -205,6 +205,12 @@ export function getParamters(options: NodePyATVFindAndInstanceOptions = {}): str
|
|
|
205
205
|
if (options.airplayCredentials) {
|
|
206
206
|
parameters.push('--airplay-credentials', options.airplayCredentials);
|
|
207
207
|
}
|
|
208
|
+
if (options.companionCredentials) {
|
|
209
|
+
parameters.push('--companion-credentials', options.companionCredentials);
|
|
210
|
+
}
|
|
211
|
+
if (options.raopCredentials) {
|
|
212
|
+
parameters.push('--raop-credentials', options.raopCredentials);
|
|
213
|
+
}
|
|
208
214
|
|
|
209
215
|
return parameters;
|
|
210
216
|
}
|
|
@@ -246,6 +252,14 @@ export function parseState(input: NodePyATVInternalState, id: string, options: N
|
|
|
246
252
|
if (!input || typeof input !== 'object') {
|
|
247
253
|
return result;
|
|
248
254
|
}
|
|
255
|
+
if(input.exception) {
|
|
256
|
+
let errorStr = 'Got pyatv Error: ' + input.exception;
|
|
257
|
+
if(input.stacktrace) {
|
|
258
|
+
errorStr += '\n\npyatv Stacktrace:\n' + input.stacktrace;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
throw new Error(errorStr);
|
|
262
|
+
}
|
|
249
263
|
|
|
250
264
|
// datetime
|
|
251
265
|
if (typeof input.datetime === 'string') {
|
package/src/lib/types.ts
CHANGED
|
@@ -132,6 +132,8 @@ export interface NodePyATVFindOptions {
|
|
|
132
132
|
dmapCredentials?: string;
|
|
133
133
|
mrpCredentials?: string;
|
|
134
134
|
airplayCredentials?: string;
|
|
135
|
+
companionCredentials?: string;
|
|
136
|
+
raopCredentials?: string;
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
export interface NodePyATVFindAndInstanceOptions extends NodePyATVInstanceOptions, NodePyATVFindOptions {
|
|
@@ -169,6 +171,7 @@ export interface NodePyATVInternalState {
|
|
|
169
171
|
power_state?: string | unknown,
|
|
170
172
|
push_updates?: string | unknown,
|
|
171
173
|
exception?: string | unknown,
|
|
174
|
+
stacktrace?: string | unknown,
|
|
172
175
|
connection?: string | unknown
|
|
173
176
|
}
|
|
174
177
|
|
package/test/device-events.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import assert from 'assert';
|
|
4
|
-
import NodePyATVDevice from '../src/lib/device';
|
|
5
4
|
import {createFakeSpawn} from '../src/lib/fake-spawn';
|
|
6
|
-
import NodePyATVDeviceEvent from '../src/lib
|
|
7
|
-
import {NodePyATVPowerState} from '../src/lib/types';
|
|
5
|
+
import {NodePyATVDeviceEvent, NodePyATVPowerState, NodePyATVDevice} from '../src/lib';
|
|
8
6
|
|
|
9
7
|
describe('NodePyATVDeviceEvents', function () {
|
|
10
8
|
describe('applyStateAndEmitEvents()', function () {
|
|
@@ -89,6 +87,29 @@ describe('NodePyATVDeviceEvents', function () {
|
|
|
89
87
|
|
|
90
88
|
assert.deepStrictEqual(sort, ['update:title', 'update']);
|
|
91
89
|
});
|
|
90
|
+
it('should emit error events on failures', async function () {
|
|
91
|
+
const device = new NodePyATVDevice({
|
|
92
|
+
name: 'My Testdevice',
|
|
93
|
+
host: '192.168.178.2',
|
|
94
|
+
spawn: createFakeSpawn(cp => {
|
|
95
|
+
cp.onStdIn(() => cp.end());
|
|
96
|
+
cp.stdout({
|
|
97
|
+
result: 'failure',
|
|
98
|
+
datetime: '2021-11-24T21:13:36.424576+03:00',
|
|
99
|
+
exception: 'invalid credentials: 321',
|
|
100
|
+
stacktrace: 'Traceback (most recent call last):\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 302, in appstart\n print(args.output(await _handle_command(args, abort_sem, loop)), flush=True)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 196, in _handle_command\n atv = await connect(config, loop, protocol=Protocol.MRP)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/__init__.py\", line 96, in connect\n for setup_data in proto_methods.setup(\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 192, in setup\n stream = AirPlayStream(config, service)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 79, in __init__\n self._credentials: HapCredentials = parse_credentials(self.service.credentials)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/auth/hap_pairing.py\", line 139, in parse_credentials\n raise exceptions.InvalidCredentialsError(\"invalid credentials: \" + detail_string)\npyatv.exceptions.InvalidCredentialsError: invalid credentials: 321\n'
|
|
101
|
+
});
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
await new Promise(cb => {
|
|
106
|
+
device.once('error', error => {
|
|
107
|
+
assert.ok(error instanceof Error);
|
|
108
|
+
assert.ok(error.toString().includes('invalid credentials: 321'));
|
|
109
|
+
cb(undefined);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
92
113
|
it('should not emit an update if new value is same as old one', async function () {
|
|
93
114
|
let spawnCounter = 0;
|
|
94
115
|
let eventCounter = 0;
|
package/test/device.ts
CHANGED
|
@@ -237,6 +237,24 @@ describe('NodePyATVDevice', function () {
|
|
|
237
237
|
powerState: null
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
|
+
it('should reject with error if pyatv fails', async function () {
|
|
241
|
+
const device = new NodePyATVDevice({
|
|
242
|
+
name: 'My Testdevice',
|
|
243
|
+
host: '192.168.178.2',
|
|
244
|
+
spawn: createFakeSpawn(cp => {
|
|
245
|
+
cp.end({
|
|
246
|
+
result: 'failure',
|
|
247
|
+
datetime: '2021-11-24T21:13:36.424576+03:00',
|
|
248
|
+
exception: 'invalid credentials: 321',
|
|
249
|
+
stacktrace: 'Traceback (most recent call last):\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 302, in appstart\n print(args.output(await _handle_command(args, abort_sem, loop)), flush=True)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 196, in _handle_command\n atv = await connect(config, loop, protocol=Protocol.MRP)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/__init__.py\", line 96, in connect\n for setup_data in proto_methods.setup(\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 192, in setup\n stream = AirPlayStream(config, service)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 79, in __init__\n self._credentials: HapCredentials = parse_credentials(self.service.credentials)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/auth/hap_pairing.py\", line 139, in parse_credentials\n raise exceptions.InvalidCredentialsError(\"invalid credentials: \" + detail_string)\npyatv.exceptions.InvalidCredentialsError: invalid credentials: 321\n'
|
|
250
|
+
});
|
|
251
|
+
})
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
assert.rejects(async () => {
|
|
255
|
+
await device.getState();
|
|
256
|
+
}, /Got pyatv Error: invalid credentials: 321/);
|
|
257
|
+
});
|
|
240
258
|
it('should cache requests for a bit', async function () {
|
|
241
259
|
let executions = 0;
|
|
242
260
|
const device = new NodePyATVDevice({
|
package/test/instance.ts
CHANGED
|
@@ -9,7 +9,9 @@ import NodePyATVInstance, {
|
|
|
9
9
|
NodePyATVDeviceState,
|
|
10
10
|
NodePyATVRepeatState,
|
|
11
11
|
NodePyATVShuffleState,
|
|
12
|
-
NodePyATVKeys
|
|
12
|
+
NodePyATVKeys,
|
|
13
|
+
NodePyATVListenerState,
|
|
14
|
+
NodePyATVPowerState
|
|
13
15
|
} from '../src/lib/index';
|
|
14
16
|
|
|
15
17
|
describe('NodePyATVInstance', function () {
|
|
@@ -330,5 +332,11 @@ describe('NodePyATVInstance', function () {
|
|
|
330
332
|
it('Type NodePyATVKeys should be exported', function() {
|
|
331
333
|
assert.ok(NodePyATVKeys);
|
|
332
334
|
});
|
|
335
|
+
it('Type NodePyATVInstanceOptions should be exported', function() {
|
|
336
|
+
assert.ok(NodePyATVListenerState);
|
|
337
|
+
});
|
|
338
|
+
it('Type NodePyATVPowerState should be exported', function() {
|
|
339
|
+
assert.ok(NodePyATVPowerState);
|
|
340
|
+
});
|
|
333
341
|
});
|
|
334
342
|
});
|
package/test/tools.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import assert from 'assert';
|
|
4
|
-
import {addRequestId, debug, getExecutable, getParamters, parseState, removeRequestId} from '../src/lib/tools';
|
|
4
|
+
import { addRequestId, debug, getExecutable, getParamters, parseState, removeRequestId } from '../src/lib/tools';
|
|
5
5
|
import {
|
|
6
6
|
NodePyATVDeviceState,
|
|
7
7
|
NodePyATVExecutableType,
|
|
@@ -28,7 +28,7 @@ describe('Tools', function () {
|
|
|
28
28
|
debug('TEST', 'Hello World.', {});
|
|
29
29
|
});
|
|
30
30
|
it('should work with default logger', function () {
|
|
31
|
-
debug('TEST', 'Hello World.', {debug: true});
|
|
31
|
+
debug('TEST', 'Hello World.', { debug: true });
|
|
32
32
|
});
|
|
33
33
|
it('should work with custom logger', function () {
|
|
34
34
|
debug('TEST', 'Hello World.', {
|
|
@@ -39,7 +39,7 @@ describe('Tools', function () {
|
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
it('should work with colors disabled', function () {
|
|
42
|
-
debug('TEST', 'Hello World.', {noColors: true});
|
|
42
|
+
debug('TEST', 'Hello World.', { noColors: true });
|
|
43
43
|
});
|
|
44
44
|
it('should work with custom logger and colors disabled', function () {
|
|
45
45
|
debug('TEST', 'Hello World.', {
|
|
@@ -103,7 +103,9 @@ describe('Tools', function () {
|
|
|
103
103
|
protocol: NodePyATVProtocol.mrp,
|
|
104
104
|
dmapCredentials: '****',
|
|
105
105
|
mrpCredentials: '****',
|
|
106
|
-
airplayCredentials: '****'
|
|
106
|
+
airplayCredentials: '****',
|
|
107
|
+
companionCredentials: '1234',
|
|
108
|
+
raopCredentials: '::foo:'
|
|
107
109
|
});
|
|
108
110
|
assert.deepEqual(result, [
|
|
109
111
|
'-s', '192.168.178.2,192.168.178.3',
|
|
@@ -111,7 +113,9 @@ describe('Tools', function () {
|
|
|
111
113
|
'--protocol', 'mrp',
|
|
112
114
|
'--dmap-credentials', '****',
|
|
113
115
|
'--mrp-credentials', '****',
|
|
114
|
-
'--airplay-credentials', '****'
|
|
116
|
+
'--airplay-credentials', '****',
|
|
117
|
+
'--companion-credentials', '1234',
|
|
118
|
+
'--raop-credentials', '::foo:'
|
|
115
119
|
]);
|
|
116
120
|
});
|
|
117
121
|
});
|
|
@@ -197,8 +201,19 @@ describe('Tools', function () {
|
|
|
197
201
|
powerState: null
|
|
198
202
|
});
|
|
199
203
|
});
|
|
204
|
+
it('should throw an error for pyatv exceptions', function () {
|
|
205
|
+
const input = {
|
|
206
|
+
result: 'failure',
|
|
207
|
+
datetime: '2021-11-24T21:13:36.424576+03:00',
|
|
208
|
+
exception: 'invalid credentials: 321',
|
|
209
|
+
stacktrace: 'Traceback (most recent call last):\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 302, in appstart\n print(args.output(await _handle_command(args, abort_sem, loop)), flush=True)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 196, in _handle_command\n atv = await connect(config, loop, protocol=Protocol.MRP)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/__init__.py\", line 96, in connect\n for setup_data in proto_methods.setup(\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 192, in setup\n stream = AirPlayStream(config, service)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 79, in __init__\n self._credentials: HapCredentials = parse_credentials(self.service.credentials)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/auth/hap_pairing.py\", line 139, in parse_credentials\n raise exceptions.InvalidCredentialsError(\"invalid credentials: \" + detail_string)\npyatv.exceptions.InvalidCredentialsError: invalid credentials: 321\n'
|
|
210
|
+
};
|
|
211
|
+
assert.throws(() => {
|
|
212
|
+
parseState(input, '', {});
|
|
213
|
+
}, /Got pyatv Error: invalid credentials: 321/);
|
|
214
|
+
});
|
|
200
215
|
it('should ignore date if it\'s an invalid date', function () {
|
|
201
|
-
const input = {datetime: 'today'};
|
|
216
|
+
const input = { datetime: 'today' };
|
|
202
217
|
const result = parseState(input, '', {});
|
|
203
218
|
assert.deepStrictEqual(result, {
|
|
204
219
|
dateTime: null,
|
package/typedoc.json
CHANGED