Skip to content

Commit

Permalink
Bumping version to 1.5.14
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Aug 21, 2019
1 parent 60f11a6 commit c9af7b8
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 133 deletions.
9 changes: 0 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
FROM mcr.microsoft.com/dotnet/core/runtime:latest
COPY /deploy .

# Install Python.
RUN \
apt-get update && \
apt-get install -y python python-dev python-pip python-virtualenv && \
rm -rf /var/lib/apt/lists/*

ADD https://yt-dl.org/downloads/latest/youtube-dl /usr/local/bin/youtube-dl
RUN chmod a+rx /usr/local/bin/youtube-dl
WORKDIR .
EXPOSE 8085
ENTRYPOINT ["dotnet", "Server.dll"]
5 changes: 3 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release Notes

## 1.5.13 - 2019-08-20
## 1.5.14 - 2019-08-21
* Sonos support
* Removed Youtube

## 1.4.22 - 2019-08-20
* Update deps
Expand Down Expand Up @@ -35,7 +36,7 @@
## 0.13.22 - 2018-10-24
* Volume buttons

## 0.12.1 - 2018-10-23
## 0.12.2 - 2018-10-23
* Volume buttons

## 0.11.21 - 2018-10-23
Expand Down
1 change: 0 additions & 1 deletion src/Client/Client.fs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ let tagsTable (model : Model) (dispatch : Msg -> unit) =
| TagAction.PlayMusik urls ->
for url in urls do
yield td [ ] [ a [Href url ] [str tag.Description ] ]
| TagAction.PlayYoutube url -> yield td [ ] [ a [Href url ] [str tag.Description ] ]
| _ -> yield td [ Title (tag.Action.ToString()) ] [ str tag.Description ]
]
]
Expand Down
7 changes: 4 additions & 3 deletions src/Client/ReleaseNotes.fs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
module internal ReleaseNotes

let Version = "1.5.13"
let Version = "1.5.14"

let IsPrerelease = false

let Notes = """
# Release Notes
## 1.5.13 - 2019-08-20
## 1.5.14 - 2019-08-21
* Sonos support
* Removed Youtube
## 1.4.22 - 2019-08-20
* Update deps
Expand Down Expand Up @@ -42,7 +43,7 @@ let Notes = """
## 0.13.22 - 2018-10-24
* Volume buttons
## 0.12.1 - 2018-10-23
## 0.12.2 - 2018-10-23
* Volume buttons
## 0.11.21 - 2018-10-23
Expand Down
34 changes: 0 additions & 34 deletions src/Server/AzureTable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,8 @@ let connection = CloudStorageAccount.Parse storageConnectionString
let tagsTable = getTable "tags" connection
let usersTable = getTable "users" connection
let positionsTable = getTable "positions" connection
let linksTable = getTable "links" connection
let requestsTable = getTable "requests" connection


open ServerCore.Domain
open Thoth.Json.Net
open System
Expand Down Expand Up @@ -182,22 +180,6 @@ let saveTag (tag:Tag) =
let operation = TableOperation.InsertOrReplace entity
tagsTable.ExecuteAsync operation


let saveLinks (tag:Tag) (urls:string []) = task {
let batch = TableBatchOperation()
let mutable i = 0
for url in urls do
let entity = DynamicTableEntity()
entity.PartitionKey <- tag.Token
entity.RowKey <- string i
entity.Properties.["Url"] <- EntityProperty.GeneratePropertyForString url
batch.InsertOrReplace entity
i <- i + 1
if i > 0 then
let! _ = linksTable.ExecuteBatchAsync batch
()
}

let saveRequest (userID:string) (token:string) =
let entity = DynamicTableEntity()
entity.PartitionKey <- userID
Expand Down Expand Up @@ -295,19 +277,3 @@ let getAllTags () = task {
return [| for result in results -> mapTag result |]
}

let getAllLinksForTag (tagToken:string) = task {
let rec getResults token = task {
let query = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, tagToken)
let! result = linksTable.ExecuteQuerySegmentedAsync(TableQuery(FilterString = query), token)
let token = result.ContinuationToken
let result = result |> Seq.toList
if isNull token then
return result
else
let! others = getResults token
return result @ others }

let! results = getResults null

return [| for result in results -> mapLink result |]
}
77 changes: 0 additions & 77 deletions src/Server/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,42 +63,6 @@ let mapBlobMusikTag (tag:Tag) = task {
| _ -> return tag
}


let discoverYoutubeLink (youtubeURL:string) = task {
let lines = System.Collections.Generic.List<_>()
let proc = new Process ()
let startInfo = ProcessStartInfo()
startInfo.FileName <- "/usr/local/bin/youtube-dl"
startInfo.Arguments <- sprintf " -g \"%s\"" youtubeURL
startInfo.UseShellExecute <- false
startInfo.RedirectStandardOutput <- true
startInfo.RedirectStandardError <- true
startInfo.CreateNoWindow <- true
proc.StartInfo <- startInfo

proc.Start() |> ignore

while not proc.StandardOutput.EndOfStream do
let! line = proc.StandardOutput.ReadLineAsync()
lines.Add line

while not proc.StandardError.EndOfStream do
let! line = proc.StandardError.ReadLineAsync()
lines.Add line

let lines = Seq.toArray lines
return youtubeURL,lines
}

let mapYoutube (tag:Tag) = task {
match tag.Action with
| TagAction.PlayYoutube _ ->
let! links = getAllLinksForTag tag.Token
let links = links |> Array.map (fun l -> l.Url)
return { tag with Action = TagAction.PlayMusik links }
| _ -> return tag
}

let uploadEndpoint (userID:string) =
pipeline {
set_header "Content-Type" "application/json"
Expand Down Expand Up @@ -151,7 +115,6 @@ let previousFileEndpoint (userID,token) =
Object = "" }
task { return t }

let! tag = mapYoutube tag
match user.SpeakerType with
| SpeakerType.Local ->
let tag : TagForBox = {
Expand Down Expand Up @@ -206,7 +169,6 @@ let nextFileEndpoint (userID,token) =
Object = "" }
task { return t }

let! tag = mapYoutube tag
let! _ = AzureTable.savePlayListPosition userID token position

match user.SpeakerType with
Expand Down Expand Up @@ -315,37 +277,6 @@ let firmwareEndpoint =
})
}

let discoverYoutube() = task {
try
let! tags = getAllTags()
for tag in tags do
try
match tag.Action with
| TagAction.PlayYoutube url ->
let! _,urls = discoverYoutubeLink url
let urls =
urls
|> Array.filter (fun x -> x.Contains "&mime=audio")
let! _ = saveLinks tag urls
let! _ = saveTag { tag with LastVerified = DateTimeOffset.UtcNow }
()
| _ -> ()
with
| _ -> ()
with
| _ -> ()
}

let youtubeEndpoint =
pipeline {
set_header "Content-Type" "application/json"
plug (fun next ctx -> task {
do! discoverYoutube()
let! _,urls = discoverYoutubeLink "https://www.youtube.com/watch?v=DeTePthFfDY"
let txt = sprintf "%A" urls
return! setBodyFromString txt next ctx
})
}

let tagHistoryBroadcaster = ConnectionManager()

Expand All @@ -368,7 +299,6 @@ let webApp =
getf "/api/history/%s" historyEndPoint
get "/api/startup" startupEndpoint
get "/api/firmware" firmwareEndpoint
get "/api/youtube" youtubeEndpoint
get "/api/latestfirmware" getLatestFirmware
getf "/api/taghistorysocket/%s" (TagHistorySocket.openSocket tagHistoryBroadcaster)
}
Expand All @@ -389,11 +319,4 @@ let app = application {
app_config configureApp
}

let discoverTask = task {
while true do
do! discoverYoutube()
do! Task.Delay (1000 * 60 * 20)
return ()
}

run app
7 changes: 0 additions & 7 deletions src/Shared/Shared.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type TagAction =
| UnknownTag
| StopMusik
| PlayMusik of string []
| PlayYoutube of string
| PlayBlobMusik of System.Guid []

static member Encoder (action : TagAction) =
Expand All @@ -47,10 +46,6 @@ type TagAction =
Encode.object [
"PlayMusik", Encode.array (Array.map Encode.string urls)
]
| TagAction.PlayYoutube url ->
Encode.object [
"PlayYoutube", Encode.string url
]
| TagAction.PlayBlobMusik urls ->
Encode.object [
"PlayBlobMusik", Encode.array (Array.map Encode.guid urls)
Expand All @@ -62,8 +57,6 @@ type TagAction =
Decode.field "StopMusik" (Decode.succeed TagAction.StopMusik)
Decode.field "PlayMusik" (Decode.array Decode.string)
|> Decode.map TagAction.PlayMusik
Decode.field "PlayYoutube" Decode.string
|> Decode.map TagAction.PlayYoutube
Decode.field "PlayBlobMusik" (Decode.array Decode.guid)
|> Decode.map TagAction.PlayBlobMusik
]
Expand Down

0 comments on commit c9af7b8

Please sign in to comment.