From dad51e60c17233825fe4c99e3e0380b7d2508d44 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Fri, 13 May 2022 20:49:10 -0500 Subject: [PATCH] Added docker --- Dockerfile | 16 +++++++++ Tesses.YouTubeDownloader.Net6/Program.cs | 7 +++- .../WebSite/index.html | 12 ------- .../JavaScript/tytd-jquery.js | 36 +++++++++---------- 4 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 Dockerfile delete mode 100644 Tesses.YouTubeDownloader.Net6/WebSite/index.html diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a236014 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env + +WORKDIR /app +RUN git clone https://github.com/tesses50/tytd-2022 . +WORKDIR /app/Tesses.YouTubeDownloader.Net6 +# Restore as distinct layers +RUN dotnet restore +# Build and publish a release +RUN dotnet publish -c Release -o /app/out + +# Build runtime image +FROM mcr.microsoft.com/dotnet/runtime:6.0 +WORKDIR /app +EXPOSE 3250 +COPY --from=build-env /app/out . +ENTRYPOINT ["dotnet", "Tesses.YouTubeDownloader.Net6.dll","--docker"] \ No newline at end of file diff --git a/Tesses.YouTubeDownloader.Net6/Program.cs b/Tesses.YouTubeDownloader.Net6/Program.cs index 0c9128d..c52f3c0 100644 --- a/Tesses.YouTubeDownloader.Net6/Program.cs +++ b/Tesses.YouTubeDownloader.Net6/Program.cs @@ -7,10 +7,15 @@ namespace Tesses.YouTubeDownloader.Net6 { public static async Task Main(string[] args) { + if(args.Contains("--docker")) + { + + Environment.CurrentDirectory="/data"; + } TYTDCurrentDirectory currentDirectory=new TYTDCurrentDirectory(new HttpClient()); TYTDServer server=new TYTDServer(currentDirectory); server.RootServer.Server=new StaticServer("WebSite"); - + currentDirectory.CanDownload=false; HttpServerListener listener=new HttpServerListener(new System.Net.IPEndPoint(System.Net.IPAddress.Any,3252),server.InnerServer); currentDirectory.StartLoop(); TYTDStorage.FFmpeg ="/usr/bin/ffmpeg"; diff --git a/Tesses.YouTubeDownloader.Net6/WebSite/index.html b/Tesses.YouTubeDownloader.Net6/WebSite/index.html deleted file mode 100644 index 1d099fa..0000000 --- a/Tesses.YouTubeDownloader.Net6/WebSite/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Document - - -

Hello, World!

- - \ No newline at end of file diff --git a/Tesses.YouTubeDownloader.OtherClients/JavaScript/tytd-jquery.js b/Tesses.YouTubeDownloader.OtherClients/JavaScript/tytd-jquery.js index efbd19c..4fbabbb 100644 --- a/Tesses.YouTubeDownloader.OtherClients/JavaScript/tytd-jquery.js +++ b/Tesses.YouTubeDownloader.OtherClients/JavaScript/tytd-jquery.js @@ -23,7 +23,7 @@ class TYTD downloadItem(url,res) { var callurl=new URL(`api/AddItemRes/${res}/${url}`,this.server).href; - $.get(callurl,function(e){}); + $.ajax(callurl,function(e){}); } downloadItem(url) { @@ -33,14 +33,14 @@ class TYTD progress(p) { var callurl=new URL("api/v2/Progress",this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ p(JSON.parse(e)); }); } queuelist(ql) { var callurl=new URL("api/v2/QueueList",this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ ql(JSON.parse(e)); }); } @@ -81,21 +81,21 @@ class TYTD getvideoinfofile(filename,info) { var callurl=new URL(`api/Storage/File/Info/${filename}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ info(JSON.parse(e)); }); } getchannelinfofile(filename,info) { var callurl=new URL(`api/Storage/File/Channel/${filename}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ info(JSON.parse(e)); }); } getvideoinfofiles(vid) { var callurl=new URL("api/Storage/GetFiles/Info",this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ vid(JSON.parse(e)); }); } @@ -106,28 +106,28 @@ class TYTD getplaylistinfofile(info) { var callurl=new URL(`api/Storage/File/Playlist/${filename}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ info(JSON.parse(e)); }); } getplaylistinfofiles(pl) { var callurl = new URL("api/Storage/GetFiles/Playlist",this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ pl(JSON.parse(e)); }); } getchannelinfofiles(chan) { var callurl = new URL("api/Storage/GetFiles/Channel",this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ chan(JSON.parse(e)); }); } getsubscriptions(subs) { var callurl = new URL("api/v2/subscriptions",this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ subs(JSON.parse(e)); }); } @@ -135,28 +135,28 @@ class TYTD { var ginfo = getinfo == true ? "true" : "false"; var callurl = new URL(`api/v2/subscribe?id=${encodeURIComponent(cid)}&conf=${conf}&getinfo=${getinfo}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ }); } subscribe(name,conf) { var callurl = new URL(`api/v2/subscribe?id=${encodeURIComponent(name)}&conf=${conf}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ }); } unsubscribe(cid) { var callurl = new URL(`api/v2/unsubscribe?id=${encodeURIComponent(cid)}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ }); } resubscribe(cid,conf) { var callurl = new URL(`api/v2/resubscribe?id=${encodeURIComponent(cid)}&conf=${conf}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ }); } @@ -164,21 +164,21 @@ class TYTD getfiles(path,ls) { var callurl=new URL(`api/Storage/GetFiles/${path}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ ls(JSON.parse(e)); }); } getdirectories(path,ls) { var callurl=new URL(`api/Storage/GetDirectories/${path}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ ls(JSON.parse(e)); }); } fileexists(path,exists,doesntexist) { var callurl=new URL(`api/Storage/FileExists/${path}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ if(e==="true") { exists(); @@ -190,7 +190,7 @@ class TYTD directoryexists(path,exists,doesntexist) { var callurl=new URL(`api/Storage/DirectoryExists/${path}`,this.server).href; - $.get(callurl,function(e){ + $.ajax(callurl,function(e){ if(e==="true") { exists();