diff --git a/.vs/youtube-downloader/xs/UserPrefs.xml b/.vs/youtube-downloader/xs/UserPrefs.xml index 5fdbda1..9fe35c9 100644 --- a/.vs/youtube-downloader/xs/UserPrefs.xml +++ b/.vs/youtube-downloader/xs/UserPrefs.xml @@ -1,7 +1,11 @@  - + - + + + + + @@ -11,9 +15,10 @@ - + + + - diff --git a/Program.cs b/Program.cs index 0bbe558..46a6ac5 100644 --- a/Program.cs +++ b/Program.cs @@ -11,6 +11,9 @@ using System.Threading; using TessesYoutubeDownloader.Server.Models; using Newtonsoft.Json; using Makaretu.Dns; +using System.Net; +using System.Threading.Tasks; +using youtube_downloader.Server.Models; namespace youtube_downloader { @@ -30,22 +33,7 @@ namespace youtube_downloader })); t2.Start(); - Thread t3 = new Thread(new ThreadStart(() => - { - int port = 3250; - if(arg.Length > 0) - { - Uri uri; - if(Uri.TryCreate(arg[0], UriKind.Absolute, out uri)) - { - port = uri.Port; - } - } - - var service = new ServiceProfile("tytd", "_tesses-services._tcp", (ushort)port); - var sd = new ServiceDiscovery(); - sd.Advertise(service); - })); + // we need to get our app name so that // we can create unique names for our mutex and our pipe string webSitePath = Server.Functions.Downloader.DL.GetPath(true, "WebSite"); @@ -62,7 +50,7 @@ namespace youtube_downloader f.Save(Path.Combine(webSitePath,f.FileName)); rp.AsText("uploaded", "text/plain"); },"POST"); - + Route.Add("/api/AddItems", (HttpActionAsync)AddItems,"POST"); Route.Add("/", (rq, rp, args) => { rp.AsFile(rq, Path.Combine(webSitePath, "index.html")); @@ -242,7 +230,7 @@ namespace youtube_downloader rp.AsFile(rq, path); }); Console.WriteLine("Almost Ready To Listen"); - t3.Start(); + if (arg.Length > 0) { @@ -254,17 +242,28 @@ namespace youtube_downloader HttpServer.ListenAsync(3250, CancellationToken.None, Route.OnHttpRequestAsync).Wait(); } } - /* - private static string HandleRequest(Stream inputStream, Encoding currentEncoding) - { - using (var streamReader = new StreamReader(inputStream, currentEncoding)) - { - return Newtonsoft.Json.JsonConvert.SerializeObject(HandleRequest(Newtonsoft.Json.JsonConvert.DeserializeObject(streamReader.ReadToEnd())); - } - } - private static YoutubeDownloaderResponse HandleRequest(YoutubeDownloaderRequest data) - { - }*/ + private static async Task AddItems(HttpListenerRequest request, HttpListenerResponse response, Dictionary arguments) + { + using (var req = new StreamReader(request.InputStream,request.ContentEncoding)) + { + List tripletlst = JsonConvert.DeserializeObject>(await req.ReadToEndAsync()); + Server.Functions.Downloader.DownloadItems(tripletlst); + response.Redirect("/"); + } + + } + /* +private static string HandleRequest(Stream inputStream, Encoding currentEncoding) +{ + using (var streamReader = new StreamReader(inputStream, currentEncoding)) + { + return Newtonsoft.Json.JsonConvert.SerializeObject(HandleRequest(Newtonsoft.Json.JsonConvert.DeserializeObject(streamReader.ReadToEnd())); + } +} +private static YoutubeDownloaderResponse HandleRequest(YoutubeDownloaderRequest data) +{ + +}*/ } } diff --git a/Server/Functions/Downloader.cs b/Server/Functions/Downloader.cs index 0ee9d51..97335f7 100644 --- a/Server/Functions/Downloader.cs +++ b/Server/Functions/Downloader.cs @@ -201,8 +201,27 @@ namespace youtube_downloader.Server.Functions } } } + public static void DownloadItems(List id) + { + List items = new List(); + foreach(var item in id) + { + var iqi = item.ToInfomationQueueItem(); + if(iqi != null) + { + items.Add(iqi); + } + } + if (items.Count > 0) + { + lock (DL.infoQueue) + { - internal static void DownloadUserOnly(string id) + DL.infoQueue.InsertRange(0,items); + } + } + } + internal static void DownloadUserOnly(string id) { UserName? v = UserName.TryParse(id); if (v.HasValue) diff --git a/Server/Models/InfoType.cs b/Server/Models/InfoType.cs index 44e7c47..246f65c 100644 --- a/Server/Models/InfoType.cs +++ b/Server/Models/InfoType.cs @@ -1,4 +1,8 @@ -namespace youtube_downloader.Server.Models +using YoutubeExplode.Channels; +using YoutubeExplode.Playlists; +using YoutubeExplode.Videos; + +namespace youtube_downloader.Server.Models { public enum InfoType { @@ -8,4 +12,45 @@ User=3, ClosedCaptions=4 } + public class IDResolutionTypeTriplet + { + public string Id { get; set; } + public InfoType Type { get; set; } + public TessesYoutubeDownloader.Server.Models.Resolution Resolution { get; set; } + public InfomationQueueItem ToInfomationQueueItem(bool download=true) + { + switch(Type) + { + case InfoType.Video: + VideoId? vid = VideoId.TryParse(Id); + if (vid.HasValue) + { + return new InfomationQueueItem(vid.Value, Resolution, download); + } + break; + case InfoType.Playlist: + PlaylistId? pid = PlaylistId.TryParse(Id); + if (pid.HasValue) + { + return new InfomationQueueItem(pid.Value, Resolution, download); + } + break; + case InfoType.Channel: + ChannelId? cid = ChannelId.TryParse(Id); + if (cid.HasValue) + { + return new InfomationQueueItem(cid.Value, Resolution, download); + } + break; + case InfoType.User: + UserName? user = UserName.TryParse(Id); + if (user.HasValue) + { + return new InfomationQueueItem(user.Value, Resolution, download); + } + break; + } + return null; + } + } } \ No newline at end of file diff --git a/bin/Release/youtube-downloader.exe b/bin/Release/youtube-downloader.exe index 3515dc0..8620c28 100644 Binary files a/bin/Release/youtube-downloader.exe and b/bin/Release/youtube-downloader.exe differ diff --git a/obj/x86/Release/youtube-downloader.csproj.CoreCompileInputs.cache b/obj/x86/Release/youtube-downloader.csproj.CoreCompileInputs.cache index afb8d3c..3775f6d 100644 --- a/obj/x86/Release/youtube-downloader.csproj.CoreCompileInputs.cache +++ b/obj/x86/Release/youtube-downloader.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -d607a7342c320f7511cae09413e5de7e2242b37f +191b06d8a6f86332255c3af5c32e3875798ab34e diff --git a/obj/x86/Release/youtube-downloader.csproj.FileListAbsolute.txt b/obj/x86/Release/youtube-downloader.csproj.FileListAbsolute.txt index c96a2f0..00dcdb7 100644 --- a/obj/x86/Release/youtube-downloader.csproj.FileListAbsolute.txt +++ b/obj/x86/Release/youtube-downloader.csproj.FileListAbsolute.txt @@ -140,3 +140,145 @@ /home/tom/site/bin/Release/Makaretu.Dns.pdb /home/tom/site/bin/Release/Makaretu.Dns.xml /home/tom/site/bin/Release/Makaretu.Dns.Multicast.xml +/home/ddlovato/site/obj/x86/Release/youtube-downloader.csprojAssemblyReference.cache +/home/ddlovato/site/obj/x86/Release/youtube-downloader.csproj.CoreCompileInputs.cache +/home/ddlovato/site/obj/x86/Release/youtube-downloader.exe +/home/ddlovato/site/bin/Release/youtube-downloader.exe +/home/ddlovato/site/bin/Release/System.Runtime.InteropServices.RuntimeInformation.dll +/home/ddlovato/site/bin/Release/System.Security.Cryptography.Algorithms.dll +/home/ddlovato/site/bin/Release/System.ValueTuple.dll +/home/ddlovato/site/bin/Release/Microsoft.Win32.Primitives.dll +/home/ddlovato/site/bin/Release/netstandard.dll +/home/ddlovato/site/bin/Release/System.AppContext.dll +/home/ddlovato/site/bin/Release/System.Collections.Concurrent.dll +/home/ddlovato/site/bin/Release/System.Collections.dll +/home/ddlovato/site/bin/Release/System.Collections.NonGeneric.dll +/home/ddlovato/site/bin/Release/System.Collections.Specialized.dll +/home/ddlovato/site/bin/Release/System.ComponentModel.dll +/home/ddlovato/site/bin/Release/System.ComponentModel.EventBasedAsync.dll +/home/ddlovato/site/bin/Release/System.ComponentModel.Primitives.dll +/home/ddlovato/site/bin/Release/System.ComponentModel.TypeConverter.dll +/home/ddlovato/site/bin/Release/System.Console.dll +/home/ddlovato/site/bin/Release/System.Data.Common.dll +/home/ddlovato/site/bin/Release/System.Diagnostics.Contracts.dll +/home/ddlovato/site/bin/Release/System.Diagnostics.Debug.dll +/home/ddlovato/site/bin/Release/System.Diagnostics.FileVersionInfo.dll +/home/ddlovato/site/bin/Release/System.Diagnostics.Process.dll +/home/ddlovato/site/bin/Release/System.Diagnostics.StackTrace.dll +/home/ddlovato/site/bin/Release/System.Diagnostics.TextWriterTraceListener.dll +/home/ddlovato/site/bin/Release/System.Diagnostics.Tools.dll +/home/ddlovato/site/bin/Release/System.Diagnostics.TraceSource.dll +/home/ddlovato/site/bin/Release/System.Diagnostics.Tracing.dll +/home/ddlovato/site/bin/Release/System.Drawing.Primitives.dll +/home/ddlovato/site/bin/Release/System.Dynamic.Runtime.dll +/home/ddlovato/site/bin/Release/System.Globalization.Calendars.dll +/home/ddlovato/site/bin/Release/System.Globalization.dll +/home/ddlovato/site/bin/Release/System.Globalization.Extensions.dll +/home/ddlovato/site/bin/Release/System.IO.Compression.dll +/home/ddlovato/site/bin/Release/System.IO.Compression.ZipFile.dll +/home/ddlovato/site/bin/Release/System.IO.dll +/home/ddlovato/site/bin/Release/System.IO.FileSystem.dll +/home/ddlovato/site/bin/Release/System.IO.FileSystem.DriveInfo.dll +/home/ddlovato/site/bin/Release/System.IO.FileSystem.Primitives.dll +/home/ddlovato/site/bin/Release/System.IO.FileSystem.Watcher.dll +/home/ddlovato/site/bin/Release/System.IO.IsolatedStorage.dll +/home/ddlovato/site/bin/Release/System.IO.MemoryMappedFiles.dll +/home/ddlovato/site/bin/Release/System.IO.Pipes.dll +/home/ddlovato/site/bin/Release/System.IO.UnmanagedMemoryStream.dll +/home/ddlovato/site/bin/Release/System.Linq.dll +/home/ddlovato/site/bin/Release/System.Linq.Expressions.dll +/home/ddlovato/site/bin/Release/System.Linq.Parallel.dll +/home/ddlovato/site/bin/Release/System.Linq.Queryable.dll +/home/ddlovato/site/bin/Release/System.Net.Http.dll +/home/ddlovato/site/bin/Release/System.Net.NameResolution.dll +/home/ddlovato/site/bin/Release/System.Net.NetworkInformation.dll +/home/ddlovato/site/bin/Release/System.Net.Ping.dll +/home/ddlovato/site/bin/Release/System.Net.Primitives.dll +/home/ddlovato/site/bin/Release/System.Net.Requests.dll +/home/ddlovato/site/bin/Release/System.Net.Security.dll +/home/ddlovato/site/bin/Release/System.Net.Sockets.dll +/home/ddlovato/site/bin/Release/System.Net.WebHeaderCollection.dll +/home/ddlovato/site/bin/Release/System.Net.WebSockets.Client.dll +/home/ddlovato/site/bin/Release/System.Net.WebSockets.dll +/home/ddlovato/site/bin/Release/System.ObjectModel.dll +/home/ddlovato/site/bin/Release/System.Reflection.dll +/home/ddlovato/site/bin/Release/System.Reflection.Extensions.dll +/home/ddlovato/site/bin/Release/System.Reflection.Primitives.dll +/home/ddlovato/site/bin/Release/System.Resources.Reader.dll +/home/ddlovato/site/bin/Release/System.Resources.ResourceManager.dll +/home/ddlovato/site/bin/Release/System.Resources.Writer.dll +/home/ddlovato/site/bin/Release/System.Runtime.CompilerServices.VisualC.dll +/home/ddlovato/site/bin/Release/System.Runtime.dll +/home/ddlovato/site/bin/Release/System.Runtime.Extensions.dll +/home/ddlovato/site/bin/Release/System.Runtime.Handles.dll +/home/ddlovato/site/bin/Release/System.Runtime.InteropServices.dll +/home/ddlovato/site/bin/Release/System.Runtime.Numerics.dll +/home/ddlovato/site/bin/Release/System.Runtime.Serialization.Formatters.dll +/home/ddlovato/site/bin/Release/System.Runtime.Serialization.Json.dll +/home/ddlovato/site/bin/Release/System.Runtime.Serialization.Primitives.dll +/home/ddlovato/site/bin/Release/System.Runtime.Serialization.Xml.dll +/home/ddlovato/site/bin/Release/System.Security.Claims.dll +/home/ddlovato/site/bin/Release/System.Security.Cryptography.Csp.dll +/home/ddlovato/site/bin/Release/System.Security.Cryptography.Encoding.dll +/home/ddlovato/site/bin/Release/System.Security.Cryptography.Primitives.dll +/home/ddlovato/site/bin/Release/System.Security.Cryptography.X509Certificates.dll +/home/ddlovato/site/bin/Release/System.Security.Principal.dll +/home/ddlovato/site/bin/Release/System.Security.SecureString.dll +/home/ddlovato/site/bin/Release/System.Text.Encoding.dll +/home/ddlovato/site/bin/Release/System.Text.Encoding.Extensions.dll +/home/ddlovato/site/bin/Release/System.Text.RegularExpressions.dll +/home/ddlovato/site/bin/Release/System.Threading.dll +/home/ddlovato/site/bin/Release/System.Threading.Overlapped.dll +/home/ddlovato/site/bin/Release/System.Threading.Tasks.dll +/home/ddlovato/site/bin/Release/System.Threading.Tasks.Parallel.dll +/home/ddlovato/site/bin/Release/System.Threading.Thread.dll +/home/ddlovato/site/bin/Release/System.Threading.ThreadPool.dll +/home/ddlovato/site/bin/Release/System.Threading.Timer.dll +/home/ddlovato/site/bin/Release/System.Xml.ReaderWriter.dll +/home/ddlovato/site/bin/Release/System.Xml.XDocument.dll +/home/ddlovato/site/bin/Release/System.Xml.XmlDocument.dll +/home/ddlovato/site/bin/Release/System.Xml.XmlSerializer.dll +/home/ddlovato/site/bin/Release/System.Xml.XPath.dll +/home/ddlovato/site/bin/Release/System.Xml.XPath.XDocument.dll +/home/ddlovato/site/bin/Release/AngleSharp.dll +/home/ddlovato/site/bin/Release/AsyncEnumerable.dll +/home/ddlovato/site/bin/Release/Common.Logging.Core.dll +/home/ddlovato/site/bin/Release/Common.Logging.dll +/home/ddlovato/site/bin/Release/Makaretu.Dns.dll +/home/ddlovato/site/bin/Release/Makaretu.Dns.Multicast.dll +/home/ddlovato/site/bin/Release/Microsoft.Bcl.AsyncInterfaces.dll +/home/ddlovato/site/bin/Release/MimeTypesMap.dll +/home/ddlovato/site/bin/Release/Newtonsoft.Json.dll +/home/ddlovato/site/bin/Release/SimpleBase.dll +/home/ddlovato/site/bin/Release/SimpleHTTP.dll +/home/ddlovato/site/bin/Release/System.Buffers.dll +/home/ddlovato/site/bin/Release/System.Memory.dll +/home/ddlovato/site/bin/Release/System.Net.IPNetwork.dll +/home/ddlovato/site/bin/Release/System.Numerics.Vectors.dll +/home/ddlovato/site/bin/Release/System.Runtime.CompilerServices.Unsafe.dll +/home/ddlovato/site/bin/Release/System.Text.Encoding.CodePages.dll +/home/ddlovato/site/bin/Release/System.Text.Encodings.Web.dll +/home/ddlovato/site/bin/Release/System.Text.Json.dll +/home/ddlovato/site/bin/Release/System.Threading.Tasks.Extensions.dll +/home/ddlovato/site/bin/Release/YoutubeExplode.dll +/home/ddlovato/site/bin/Release/Newtonsoft.Json.xml +/home/ddlovato/site/bin/Release/System.Buffers.xml +/home/ddlovato/site/bin/Release/System.Numerics.Vectors.xml +/home/ddlovato/site/bin/Release/System.Runtime.CompilerServices.Unsafe.xml +/home/ddlovato/site/bin/Release/System.Memory.xml +/home/ddlovato/site/bin/Release/AngleSharp.xml +/home/ddlovato/site/bin/Release/System.Text.Encodings.Web.xml +/home/ddlovato/site/bin/Release/System.Threading.Tasks.Extensions.xml +/home/ddlovato/site/bin/Release/Microsoft.Bcl.AsyncInterfaces.xml +/home/ddlovato/site/bin/Release/System.Text.Json.xml +/home/ddlovato/site/bin/Release/YoutubeExplode.xml +/home/ddlovato/site/bin/Release/SimpleHTTP.xml +/home/ddlovato/site/bin/Release/AsyncEnumerable.xml +/home/ddlovato/site/bin/Release/Common.Logging.Core.pdb +/home/ddlovato/site/bin/Release/Common.Logging.pdb +/home/ddlovato/site/bin/Release/Common.Logging.xml +/home/ddlovato/site/bin/Release/SimpleBase.pdb +/home/ddlovato/site/bin/Release/Makaretu.Dns.pdb +/home/ddlovato/site/bin/Release/Makaretu.Dns.xml +/home/ddlovato/site/bin/Release/Makaretu.Dns.Multicast.xml +/home/ddlovato/site/obj/x86/Release/youtube-downloader.csproj.CopyComplete diff --git a/obj/x86/Release/youtube-downloader.csprojAssemblyReference.cache b/obj/x86/Release/youtube-downloader.csprojAssemblyReference.cache index d9f26a4..edb43ae 100644 Binary files a/obj/x86/Release/youtube-downloader.csprojAssemblyReference.cache and b/obj/x86/Release/youtube-downloader.csprojAssemblyReference.cache differ diff --git a/obj/x86/Release/youtube-downloader.exe b/obj/x86/Release/youtube-downloader.exe index 3515dc0..8620c28 100644 Binary files a/obj/x86/Release/youtube-downloader.exe and b/obj/x86/Release/youtube-downloader.exe differ