@sebbo2002/node-pyatv 6.0.0-develop.1 → 6.0.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 +7 -0
- package/dist/lib/device.d.ts +12 -1
- package/dist/lib/device.js +37 -0
- package/dist/lib/device.js.map +1 -1
- package/dist/lib/types.d.ts +5 -0
- package/docs/coverage/cobertura-coverage.xml +709 -649
- package/docs/coverage/device-event.ts.html +1 -1
- package/docs/coverage/device-events.ts.html +8 -8
- package/docs/coverage/device.ts.html +138 -21
- package/docs/coverage/fake-spawn.ts.html +40 -40
- package/docs/coverage/index.html +20 -20
- package/docs/coverage/index.ts.html +1 -1
- package/docs/coverage/instance.ts.html +1 -1
- package/docs/coverage/tools.ts.html +250 -250
- package/docs/coverage/types.ts.html +22 -4
- package/docs/reference/assets/main.js +1 -1
- package/docs/reference/assets/search.js +1 -1
- package/docs/reference/classes/NodePyATVDevice.html +112 -74
- package/docs/reference/classes/NodePyATVDeviceEvent.html +10 -10
- package/docs/reference/classes/NodePyATVInstance.html +14 -14
- package/docs/reference/enums/NodePyATVDeviceState.html +11 -11
- package/docs/reference/enums/NodePyATVExecutableType.html +7 -7
- package/docs/reference/enums/NodePyATVKeys.html +28 -28
- package/docs/reference/enums/NodePyATVListenerState.html +9 -9
- package/docs/reference/enums/NodePyATVMediaType.html +9 -9
- package/docs/reference/enums/NodePyATVPowerState.html +7 -7
- package/docs/reference/enums/NodePyATVProtocol.html +9 -9
- package/docs/reference/enums/NodePyATVRepeatState.html +8 -8
- package/docs/reference/enums/NodePyATVShuffleState.html +8 -8
- package/docs/reference/index.html +4 -4
- package/docs/reference/interfaces/NodePyATVDeviceOptions.html +25 -25
- package/docs/reference/interfaces/NodePyATVFindAndInstanceOptions.html +19 -19
- package/docs/reference/interfaces/NodePyATVFindOptions.html +14 -14
- package/docs/reference/interfaces/NodePyATVGetStateOptions.html +6 -6
- package/docs/reference/interfaces/NodePyATVInstanceOptions.html +10 -10
- package/docs/reference/interfaces/NodePyATVService.html +7 -7
- package/docs/reference/interfaces/NodePyATVState.html +20 -20
- package/docs/reference/interfaces/NodePyATVVersionResponse.html +7 -7
- package/docs/reference/modules.html +4 -4
- package/docs/reference/types/NodePyATVEventValueType.html +5 -5
- package/docs/tests/index.html +1 -1
- package/docs/tests/mochawesome.json +705 -627
- package/package.json +9 -9
- package/src/lib/device.ts +40 -1
- package/src/lib/types.ts +6 -0
- package/test/device.ts +42 -0
package/package.json
CHANGED
|
@@ -9,28 +9,28 @@
|
|
|
9
9
|
},
|
|
10
10
|
"description": "A lightweight wrapper around pyatv…",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@qiwi/semantic-release-gh-pages-plugin": "^5.2.
|
|
12
|
+
"@qiwi/semantic-release-gh-pages-plugin": "^5.2.5",
|
|
13
13
|
"@semantic-release/changelog": "^6.0.2",
|
|
14
14
|
"@semantic-release/exec": "^6.0.3",
|
|
15
15
|
"@semantic-release/git": "^10.0.1",
|
|
16
16
|
"@semantic-release/npm": "^9.0.2",
|
|
17
17
|
"@types/mocha": "^10.0.1",
|
|
18
|
-
"@types/node": "^18.
|
|
18
|
+
"@types/node": "^18.15.3",
|
|
19
19
|
"@types/semver": "^7.3.13",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
21
|
-
"@typescript-eslint/parser": "^5.
|
|
22
|
-
"c8": "^7.
|
|
23
|
-
"eslint": "^8.
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
|
21
|
+
"@typescript-eslint/parser": "^5.54.1",
|
|
22
|
+
"c8": "^7.13.0",
|
|
23
|
+
"eslint": "^8.35.0",
|
|
24
24
|
"eslint-plugin-jsonc": "^2.6.0",
|
|
25
25
|
"esm": "^3.2.25",
|
|
26
26
|
"license-checker": "^25.0.1",
|
|
27
27
|
"mocha": "^10.2.0",
|
|
28
28
|
"mochawesome": "^7.1.3",
|
|
29
|
-
"semantic-release": "^20.1.
|
|
29
|
+
"semantic-release": "^20.1.1",
|
|
30
30
|
"semantic-release-license": "^1.0.3",
|
|
31
31
|
"source-map-support": "^0.5.21",
|
|
32
32
|
"ts-node": "^10.9.1",
|
|
33
|
-
"typedoc": "^0.23.
|
|
33
|
+
"typedoc": "^0.23.26",
|
|
34
34
|
"typescript": "^4.9.5"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"test": "mocha"
|
|
59
59
|
},
|
|
60
60
|
"type": "module",
|
|
61
|
-
"version": "6.0.0-develop.
|
|
61
|
+
"version": "6.0.0-develop.2"
|
|
62
62
|
}
|
package/src/lib/device.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
NodePyATVApp,
|
|
4
5
|
NodePyATVDeviceOptions,
|
|
5
6
|
NodePyATVDeviceState,
|
|
6
7
|
NodePyATVExecutableType,
|
|
@@ -378,7 +379,36 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
378
379
|
return state.appId;
|
|
379
380
|
}
|
|
380
381
|
|
|
381
|
-
|
|
382
|
+
/**
|
|
383
|
+
* Returns the list of installed apps on the Apple TV. Probably requires `companionCredentials`,
|
|
384
|
+
* see https://pyatv.dev/documentation/atvremote/#apps for more details.
|
|
385
|
+
*/
|
|
386
|
+
async listApps(): Promise<NodePyATVApp[]> {
|
|
387
|
+
const id = addRequestId();
|
|
388
|
+
const parameters = getParamters(this.options);
|
|
389
|
+
|
|
390
|
+
const result = await request(id, NodePyATVExecutableType.atvremote, [...parameters, 'app_list'], this.options);
|
|
391
|
+
if(typeof result !== 'string' || !result.startsWith('App: ')) {
|
|
392
|
+
throw new Error('Unexpected atvremote response: ' + result);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
removeRequestId(id);
|
|
396
|
+
const regex = /(.+) \(([^\)]+)\)$/i;
|
|
397
|
+
const items = result.substring(5, ).split(', App: ').map(i => {
|
|
398
|
+
const m = i.match(regex);
|
|
399
|
+
if (m !== null) {
|
|
400
|
+
return {
|
|
401
|
+
id: m[2],
|
|
402
|
+
name: m[1],
|
|
403
|
+
launch: () => this.launchApp(m[2])
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
}) as Array<NodePyATVApp | undefined>;
|
|
407
|
+
|
|
408
|
+
return items.filter(Boolean) as NodePyATVApp[];
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
private async _pressKey(key: NodePyATVInternalKeys | string, executableType: NodePyATVExecutableType) {
|
|
382
412
|
const id = addRequestId();
|
|
383
413
|
const parameters = getParamters(this.options);
|
|
384
414
|
|
|
@@ -611,6 +641,15 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
611
641
|
await this._pressKey(NodePyATVInternalKeys.turnOn, NodePyATVExecutableType.atvremote);
|
|
612
642
|
}
|
|
613
643
|
|
|
644
|
+
/**
|
|
645
|
+
* Launch an application. Probably requires `companionCredentials`, see
|
|
646
|
+
* https://pyatv.dev/documentation/atvremote/#apps for more details.
|
|
647
|
+
* @param id App identifier, e.g. `com.netflix.Netflix`
|
|
648
|
+
*/
|
|
649
|
+
async launchApp(id: string): Promise<void> {
|
|
650
|
+
await this._pressKey('launch_app=' + id, NodePyATVExecutableType.atvremote);
|
|
651
|
+
}
|
|
652
|
+
|
|
614
653
|
/**
|
|
615
654
|
* Add an event listener. Will start the event subscription with the
|
|
616
655
|
* Apple TV as long as there are listeners for any event registered.
|
package/src/lib/types.ts
CHANGED
package/test/device.ts
CHANGED
|
@@ -726,6 +726,35 @@ describe('NodePyATVDevice', function () {
|
|
|
726
726
|
});
|
|
727
727
|
});
|
|
728
728
|
|
|
729
|
+
describe('listApps()', function () {
|
|
730
|
+
it('should work', async function () {
|
|
731
|
+
const device = new NodePyATVDevice({
|
|
732
|
+
name: 'My Testdevice',
|
|
733
|
+
host: '192.168.178.2',
|
|
734
|
+
spawn: createFakeSpawn(cp => {
|
|
735
|
+
cp.end(
|
|
736
|
+
'App: Fitness (com.apple.Fitness), App: Podcasts (com.apple.podcasts), ' +
|
|
737
|
+
'App: Filme (com.apple.TVMovies), App: Prime Video (com.amazon.aiv.AIVApp), ' +
|
|
738
|
+
'App: TV (com.apple.TVWatchList), App: Fotos (com.apple.TVPhotos), App: App Store ' +
|
|
739
|
+
'(com.apple.TVAppStore), App: Arcade (com.apple.Arcade), App: TV-Sendungen (com.apple.TVShows), ' +
|
|
740
|
+
'App: Suchen (com.apple.TVSearch), App: Live TV (de.couchfunk.WM2014), App: RTL+ ' +
|
|
741
|
+
'(com.rtlinteractive.tvnow), App: Computer (com.apple.TVHomeSharing), App: ARTE ' +
|
|
742
|
+
'(tv.arte.plus7), App: YouTube (com.google.ios.youtube), App: ARD Mediathek ' +
|
|
743
|
+
'(de.swr.avp.ard.tablet), App: Disney+ (com.disney.disneyplus), App: Plex (com.plexapp.plex), ' +
|
|
744
|
+
'App: Joyn (de.prosiebensat1digital.seventv), App: Einstellungen (com.apple.TVSettings), ' +
|
|
745
|
+
'App: ZDFmediathek (de.zdf.mediathek.universal), App: Crossy Road (com.hipsterwhale.crossy), ' +
|
|
746
|
+
'App: Netflix (com.netflix.Netflix), App: Infuse (com.firecore.infuse), ' +
|
|
747
|
+
'App: Musik (com.apple.TVMusic)');
|
|
748
|
+
})
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
const result = await device.listApps();
|
|
752
|
+
assert.strictEqual(result.length, 25);
|
|
753
|
+
assert.strictEqual(result[0].id, 'com.apple.Fitness');
|
|
754
|
+
assert.strictEqual(result[0].name, 'Fitness');
|
|
755
|
+
});
|
|
756
|
+
});
|
|
757
|
+
|
|
729
758
|
describe('pressKey()', function () {
|
|
730
759
|
it('should work with valid key', async function () {
|
|
731
760
|
const device = new NodePyATVDevice({
|
|
@@ -781,4 +810,17 @@ describe('NodePyATVDevice', function () {
|
|
|
781
810
|
});
|
|
782
811
|
});
|
|
783
812
|
|
|
813
|
+
describe('launchApp()', function () {
|
|
814
|
+
it('should work', async function () {
|
|
815
|
+
const device = new NodePyATVDevice({
|
|
816
|
+
name: 'My Testdevice',
|
|
817
|
+
host: '192.168.178.2',
|
|
818
|
+
spawn: createFakeSpawn(cp => {
|
|
819
|
+
cp.end('');
|
|
820
|
+
})
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
await device.launchApp('com.apple.TVShows');
|
|
824
|
+
});
|
|
825
|
+
});
|
|
784
826
|
});
|