Skip to content

Commit a8674ff

Browse files
svrooijpascalopitz
andauthored
Merge pull request #483 from bencevans/alpha
Releasing all improvements in alpha version Signed-off-by: Ben Evans <638535+bencevans@users.noreply.github.com> Signed-off-by: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Co-authored-by: Pascal Opitz <271740+pascalopitz@users.noreply.github.com>
2 parents 1985700 + 35c7b76 commit a8674ff

7 files changed

Lines changed: 186 additions & 58 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- master
77
- beta
8+
- alpha
89
pull_request:
910

1011
jobs:
@@ -20,4 +21,35 @@ jobs:
2021
- name: Install depencencies
2122
run: npm ci
2223
- name: Run tests
23-
run: npm run test
24+
run: npm run test
25+
26+
release:
27+
needs: build-and-test
28+
runs-on: ubuntu-latest
29+
if: github.ref == 'refs/heads/alpha' # only run on alpha branch for now.
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v1
33+
- name: Use node 12
34+
uses: actions/setup-node@v1
35+
with:
36+
node-version: 12
37+
- uses: svrooij/secret-gate-action@v1 # see https://github.com/svrooij/secret-gate-action this is to fail quiet until secret is set.
38+
id: mygate
39+
with:
40+
inputsToCheck: 'NPM_TOKEN'
41+
env:
42+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
43+
- name: Install depencencies
44+
if: steps.mygate.outputs.inputsChecked == 'true'
45+
run: npm ci
46+
- name: Run tests
47+
if: steps.mygate.outputs.inputsChecked == 'true'
48+
run: npm run test
49+
- name: Semantic Release
50+
uses: cycjimmy/semantic-release-action@v2
51+
if: steps.mygate.outputs.inputsChecked == 'true'
52+
id: semantic
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

lib/deviceDiscovery.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ DeviceDiscovery.prototype.destroy = function (callback) {
8787
* @param {Object} options Optional Options to control search behavior.
8888
* Set 'timeout' to how long to search for devices
8989
* (in milliseconds).
90+
* Set 'port' to use a specific inbound UDP port,
91+
* rather than a randomly assigned one
9092
* @param {Function} listener Optional 'DeviceAvailable' listener (sonos)
9193
* @return {DeviceDiscovery}
9294
*/

lib/events/adv-listener.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const listenAddress = process.env.SONOS_LISTENER || ip.address('public')
1818

1919
const globalEventEndpoints = [
2020
'/AlarmClock/Event',
21-
'/ZoneGroupTopology/Event'
21+
'/ZoneGroupTopology/Event',
22+
'/MediaServer/ContentDirectory/Event'
2223
]
2324
const deviceEventEndpoints = [
2425
'/MediaRenderer/AVTransport/Event',

lib/events/eventParser.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ EventParser.ParseAndEmitEvents = async function (endpoint, body, device) {
1919
return EventParser._parseGroupRenderingControlEvent(body, device)
2020
case '/MediaRenderer/Queue/Event':
2121
return EventParser._parseQueueEvent(body, device)
22+
case '/MediaServer/ContentDirectory/Event':
23+
return EventParser._parseContentDirectoryEvent(body, device)
2224
default:
2325
return EventParser._genericEvent(endpoint, body, device)
2426
}
@@ -103,6 +105,12 @@ EventParser._genericEvent = function (endpoint, body, device) {
103105
return event
104106
}
105107

108+
EventParser._parseContentDirectoryEvent = function (body, device) {
109+
debug('ContentDirectory event %j', body)
110+
const event = { name: 'ContentDirectory', eventBody: body }
111+
return event
112+
}
113+
106114
EventParser._parseAlarmEvent = function (body, device) {
107115
debug('Alarm event %j', body)
108116
const event = { name: 'AlarmClock', eventBody: body }

lib/services/ContentDirectory.js

Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ class ContentDirectory extends Service {
2525
this.SCPDURL = '/xml/ContentDirectory1.xml'
2626
}
2727

28-
async Browse (options) { return this._request('Browse', options) }
29-
30-
async DestroyObject (options) { return this._request('DestroyObject', options) }
31-
3228
async _parseResult (input) {
3329
input.Result = await Helpers.ParseXml(input.Result)
3430
return input
@@ -66,6 +62,105 @@ class ContentDirectory extends Service {
6662
}
6763
})
6864
}
65+
66+
async Browse (options) {
67+
return this._request('Browse', options)
68+
}
69+
70+
async DestroyObject (options) {
71+
return this._request('DestroyObject', options)
72+
}
73+
74+
/**
75+
* See: http://docs.python-soco.com/en/latest/api/soco.music_library.html#soco.music_library.MusicLibrary.album_artist_display_option
76+
*
77+
* Possible values are:
78+
* 'WMP' - use Album Artists
79+
* 'ITUNES' - use iTunes® Compilations
80+
* 'NONE' - do not group compilations
81+
*/
82+
async GetSearchCapabilities () {
83+
return this._request('GetSearchCapabilities', {}).then(
84+
(r) => r.SearchCaps
85+
)
86+
}
87+
88+
async GetSortCapabilities () {
89+
return this._request('GetSortCapabilities', {}).then((r) => r.SortCaps)
90+
}
91+
92+
async GetSystemUpdateID () {
93+
return this._request('GetSystemUpdateID', {}).then((r) => r.Id)
94+
}
95+
96+
async GetAlbumArtistDisplayOption () {
97+
return this._request('GetAlbumArtistDisplayOption', {}).then(
98+
(r) => r.AlbumArtistDisplayOption
99+
)
100+
}
101+
102+
async GetLastIndexChange () {
103+
return this._request('GetLastIndexChange', {}).then(
104+
(r) => r.LastIndexChange
105+
)
106+
}
107+
108+
async FindPrefix (ObjectID, Prefix) {
109+
return this._request('FindPrefix', {
110+
ObjectID,
111+
Prefix
112+
})
113+
}
114+
115+
async GetAllPrefixLocations (ObjectID) {
116+
return this._request('GetAllPrefixLocations', {
117+
ObjectID
118+
})
119+
}
120+
121+
async CreateObject (ContainerID, Elements) {
122+
return this._request('CreateObject', {
123+
ContainerID,
124+
Elements
125+
})
126+
}
127+
128+
async UpdateObject (ObjectID, CurrentTagValue) {
129+
return this._request('UpdateObject', {
130+
ObjectID,
131+
CurrentTagValue
132+
})
133+
}
134+
135+
async RefreshShareIndex (AlbumArtistDisplayOption = '') {
136+
return this._request('RefreshShareIndex', {
137+
AlbumArtistDisplayOption
138+
})
139+
}
140+
141+
async RequestResort (SortOrder) {
142+
return this._request('RequestResort', {
143+
SortOrder
144+
})
145+
}
146+
147+
async GetShareIndexInProgress () {
148+
return this._request('GetShareIndexInProgress', {}).then(
149+
(r) => r.IsIndexing !== '0'
150+
)
151+
}
152+
153+
async GetBrowseable () {
154+
return this._request('GetBrowseable', {}).then(
155+
(r) => r.IsBrowseable !== '0'
156+
)
157+
}
158+
159+
async SetBrowseable (Browseable) {
160+
return this._request('SetBrowseable', {
161+
Browseable
162+
})
163+
}
69164
}
70165

71166
module.exports = ContentDirectory

lib/services/RenderingControl.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ class RenderingControl extends Service {
111111
}
112112

113113
/**
114-
* (Un)set bass of a speaker.
115-
* @param {boolean} loudness Should it be with or without bass?
114+
* Set bass of a speaker.
115+
* @param {integer} bass desired level of bass, range from -10 to +10
116116
*/
117117
async SetBass (bass) {
118118
return this._request('SetBass', {
119119
InstanceID: 0,
120-
DesiredBass: (bass ? '1' : '0')
120+
DesiredBass: bass
121121
})
122122
}
123123

@@ -131,13 +131,13 @@ class RenderingControl extends Service {
131131
}
132132

133133
/**
134-
* (Un)set treble of a speaker.
135-
* @param {boolean} treble Should it be with or without treble?
134+
* Set treble of a speaker.
135+
* @param {integer} treble desired level of treble, range from -10 to +10
136136
*/
137137
async SetTreble (treble) {
138138
return this._request('SetTreble', {
139139
InstanceID: 0,
140-
DesiredTreble: (treble ? '1' : '0')
140+
DesiredTreble: treble
141141
})
142142
}
143143

@@ -153,7 +153,7 @@ class RenderingControl extends Service {
153153

154154
/**
155155
* (Un)set room calibration status (TruePlay) of a speaker.
156-
* @param {boolean} enabled Should it be with or without treble?
156+
* @param {boolean} enabled Should it be with or without truePlay?
157157
*/
158158
async SetRoomCalibrationStatus (enabled) {
159159
return this._request('SetRoomCalibrationStatus', {

0 commit comments

Comments
 (0)