From 08194f88fef719b10c23d8e1289dbb163349662e Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sat, 15 Dec 2018 11:39:24 +0100 Subject: [PATCH] Bumping version to 0.16.5 --- Dockerfile | 4 ++-- RELEASE_NOTES.md | 2 +- src/Client/ReleaseNotes.fs | 4 ++-- src/Server/Server.fs | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 007c95e..9b3f57d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM microsoft/dotnet:2.2.0-runtime COPY /deploy . -ADD https://yt-dl.org/downloads/latest/youtube-dl youtube-dl -RUN chmod a+rx youtube-dl +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"] diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d768a8a..b6b8e28 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,6 @@ # Release Notes -## 0.16.4 - 2018-12-15 +## 0.16.5 - 2018-12-15 * Update to ASP.NET 2.2 ## 0.15.11 - 2018-11-05 diff --git a/src/Client/ReleaseNotes.fs b/src/Client/ReleaseNotes.fs index cc49ec2..dd8c7db 100644 --- a/src/Client/ReleaseNotes.fs +++ b/src/Client/ReleaseNotes.fs @@ -1,13 +1,13 @@ module internal ReleaseNotes -let Version = "0.16.4" +let Version = "0.16.5" let IsPrerelease = false let Notes = """ # Release Notes -## 0.16.4 - 2018-12-15 +## 0.16.5 - 2018-12-15 * Update to ASP.NET 2.2 ## 0.15.11 - 2018-11-05 diff --git a/src/Server/Server.fs b/src/Server/Server.fs index 6339e3b..f54df74 100644 --- a/src/Server/Server.fs +++ b/src/Server/Server.fs @@ -13,6 +13,7 @@ open System.Threading.Tasks open Giraffe.WebSocket open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting +open System.Diagnostics #if DEBUG let publicPath = Path.GetFullPath "../Client/public" @@ -138,6 +139,40 @@ let firmwareEndpoint = } +let discoverYoutubeLink (youtubeURL:string) = task { + let lines = System.Collections.Generic.List<_>() + let proc = new Process () + let startInfo = new ProcessStartInfo() + startInfo.FileName <- "sudo" + startInfo.Arguments <- sprintf "youtube-dl -g \"%s\"" youtubeURL + startInfo.UseShellExecute <- false + startInfo.RedirectStandardOutput <- true + startInfo.CreateNoWindow <- true + proc.StartInfo <- startInfo + + proc.Start() |> ignore + while not proc.StandardOutput.EndOfStream do + let! line = proc.StandardOutput.ReadLineAsync() + lines.Add line + + let lines = Seq.toArray lines + let links = + lines + |> Array.filter (fun x -> x.Contains "&mime=audio") + + return youtubeURL,links +} + +let discoverEndpoint (url) = + pipeline { + set_header "Content-Type" "application/json" + plug (fun next ctx -> task { + let! tag = discoverYoutubeLink url + + return! setBodyFromString (sprintf "%A" tag) next ctx + }) + } + let tagHistoryBroadcaster = ConnectionManager() let t = task { @@ -154,6 +189,7 @@ let webApp = postf "/api/upload/%s" uploadEndpoint get "/api/startup" startupEndpoint get "/api/firmware" firmwareEndpoint + get "/api/discover" (discoverEndpoint "https://www.youtube.com/watch?v=kfSlg3HtaSw") get "/api/latestfirmware" getLatestFirmware getf "/api/taghistorysocket/%s" (TagHistorySocket.openSocket tagHistoryBroadcaster) }