Skip to content

Commit

Permalink
Bumping version to 1.5.17
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Aug 21, 2019
1 parent aa2fe7f commit 45b1612
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release Notes

## 1.5.16 - 2019-08-21
## 1.5.17 - 2019-08-21
* Sonos support
* Removed Youtube

Expand Down
4 changes: 2 additions & 2 deletions src/Client/ReleaseNotes.fs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module internal ReleaseNotes

let Version = "1.5.16"
let Version = "1.5.17"

let IsPrerelease = false

let Notes = """
# Release Notes
## 1.5.16 - 2019-08-21
## 1.5.17 - 2019-08-21
* Sonos support
* Removed Youtube
Expand Down
2 changes: 1 addition & 1 deletion src/PiServer/PiServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ let previousFile (model:Model,token:string) = task {

let getStartupAction (model:Model) = task {
use webClient = new System.Net.WebClient()
let url = sprintf @"%s/api/startup" model.TagServer
let url = sprintf @"%s/api/startup/%s" model.TagServer model.UserID
let! result = webClient.DownloadStringTaskAsync(System.Uri url)

match Decode.fromString (TagActionForBox.Decoder) result with
Expand Down
33 changes: 24 additions & 9 deletions src/Server/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,33 @@ let historyEndPoint userID =
})
}

let startupEndpoint =
let startupEndpoint userID =
pipeline {
set_header "Content-Type" "application/json"
plug (fun next ctx -> task {
let! sas = getSASMediaLink "d97cdddb-8a19-4690-8ba5-b8ea43d3641f"
let action = TagActionForBox.PlayMusik sas
match! AzureTable.getUser userID with
| None ->
return! Response.notFound ctx userID
| Some user ->
let! sas = getSASMediaLink "d97cdddb-8a19-4690-8ba5-b8ea43d3641f"

let txt =
action
|> TagActionForBox.Encoder
|> Encode.toString 0
return! setBodyFromString txt next ctx
match user.SpeakerType with
| SpeakerType.Local ->
let txt =
TagActionForBox.PlayMusik sas
|> TagActionForBox.Encoder
|> Encode.toString 0
return! setBodyFromString txt next ctx
| SpeakerType.Sonos ->
let logger = ctx.GetLogger "Startup"
let! session = Sonos.createOrJoinSession logger user.SonosAccessToken Sonos.group
do! Sonos.playURL logger user.SonosAccessToken session "StartupSound" sas "StartupSound"

let txt =
TagActionForBox.Ignore
|> TagActionForBox.Encoder
|> Encode.toString 0
return! setBodyFromString txt next ctx
})
}

Expand Down Expand Up @@ -293,7 +308,7 @@ let webApp =
getf "/api/volumedown/%s" volumeDownEndpoint
postf "/api/upload/%s" uploadEndpoint
getf "/api/history/%s" historyEndPoint
get "/api/startup" startupEndpoint
getf "/api/startup/%s" startupEndpoint
get "/api/firmware" firmwareEndpoint
get "/api/latestfirmware" getLatestFirmware
getf "/api/taghistorysocket/%s" (TagHistorySocket.openSocket tagHistoryBroadcaster)
Expand Down
23 changes: 12 additions & 11 deletions src/Server/Sonos.fs
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,29 @@ let volumeDown (log:ILogger) accessToken group = task {
}



let playStream (log:ILogger) accessToken (session:Session) (tag:Tag) position = task {
let playURL (log:ILogger) accessToken (session:Session) itemID mediaURL description = task {
let headers = ["Authorization", "Bearer " + accessToken]
let url = sprintf "https://api.ws.sonos.com/control/api/v1/playbackSessions/%s/playbackSession/loadStreamUrl" session.ID


match tag.Action with
| TagAction.PlayMusik stream ->
let pos = System.Math.Abs(position % stream.Length)
let body = sprintf """{
let body = sprintf """{
"streamUrl": "%s",
"playOnCompletion": true,
"stationMetadata": {
"name": "%s"
},
"itemId" : "%s"
}""" stream.[pos] (tag.Object + " - " + tag.Description) tag.Token
}""" mediaURL description itemID


log.LogCritical(body)
let! _result = post log url headers body
()
}

let! _result = post log url headers body
()
let playStream (log:ILogger) accessToken (session:Session) (tag:Tag) position = task {
match tag.Action with
| TagAction.PlayMusik stream ->
let pos = System.Math.Abs(position % stream.Length)
do! playURL log accessToken session tag.Token stream.[pos] (tag.Object + " - " + tag.Description)
| _ ->
log.LogError(sprintf "TagAction %A can't be played on Sonos" tag.Action)
}

0 comments on commit 45b1612

Please sign in to comment.