diff --git a/.vs/youtube-downloader/xs/UserPrefs.xml b/.vs/youtube-downloader/xs/UserPrefs.xml index 11cc4ca..063d766 100644 --- a/.vs/youtube-downloader/xs/UserPrefs.xml +++ b/.vs/youtube-downloader/xs/UserPrefs.xml @@ -1,21 +1,22 @@  - + - + - - + + - + + @@ -23,12 +24,13 @@ + - + diff --git a/Broadcast.cs b/Broadcast.cs new file mode 100644 index 0000000..e5702c4 --- /dev/null +++ b/Broadcast.cs @@ -0,0 +1,29 @@ +using System; +using System.Net; +namespace TYTD +{ + public class Broadcast + { + public Broadcast(ushort port,string name) + { + this.port = port; + this.name = name; + + } + + public string name { get; set; } + + public ushort port { get; set; } + } + + public class BroadcastSettings + { + public BroadcastSettings() + { + name = Dns.GetHostName(); + broadcast = true; + } + public bool broadcast { get; set; } + public string name { get; set; } + } +} diff --git a/Program.cs b/Program.cs index 5096bce..9a593ee 100644 --- a/Program.cs +++ b/Program.cs @@ -25,6 +25,7 @@ using YoutubeExplode.Playlists; using Dasync.Collections; using YoutubeExplode.Search; using Hyperlinq; +using System.Net.Sockets; namespace TYTD { @@ -52,10 +53,58 @@ namespace TYTD Downloader.DL.ListenForQueueItem().GetAwaiter().GetResult(); })); + + t2.Start(); - + + string file = Path.Combine("config","discover_info.json"); + + BroadcastSettings settings = new BroadcastSettings(); + + //http://+:3250/ + if(File.Exists(file)) + { + settings=JsonConvert.DeserializeObject(file); + } + if(settings.broadcast) + { + ushort port = 3250; + if(arg.Length > 0) + { + string url0 = arg[0]; + + Uri uri = new Uri(url0.Replace("+", "domain")); + port = (ushort)uri.Port; + } + UdpClient cl; + + Thread t3 = new Thread(() => { + IPEndPoint end = new IPEndPoint(0, 0); + ushort _port = port; + UdpClient c = new UdpClient(new IPEndPoint(IPAddress.Any, 32501)); + + while (true) + { + var data= c.Receive(ref end); + string text=Encoding.UTF8.GetString(data); + if(text.Equals("TYTD_BROADCAST", StringComparison.Ordinal)) + { + byte[] json = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new Broadcast(_port,settings.name))); + c.Send(json,json.Length, end); + } + + + } + + }); + t3.Start(); + } + + + + // we need to get our app name so that // we can create unique names for our mutex and our pipe webSitePath = Downloader.DL.GetPath(true, "WebSite"); @@ -123,7 +172,7 @@ namespace TYTD Downloader.RouteAdd("/api/Cancel","Current","Cancel current video, go to next", (HttpAction)Cancel); - + /* Storage */ Downloader.RouteAdd("/api/Storage/GetDirectories/{Path}", "Storage","Get list of directories in Path\nAlready used Path.GetFileName(), its json array", (HttpAction)StorageGetDirectories); Downloader.RouteAdd("/api/Storage/GetFiles/{Path}","Storage","Get list of files in Path\nAlready used Path.GetFileName(), its json array", (HttpAction)StorageGetFiles); @@ -156,9 +205,9 @@ namespace TYTD - + /* Other */ - Downloader.RouteAdd("/","Other","Home page", (HttpAction)Index); + Downloader.RouteAdd("/", "Other", "Home page", (HttpAction)Index, "GET"); Downloader.RouteAdd("/extensions.html","Other","Extensions URL", (HttpAction)Extensions); Downloader.RouteAdd("/{Path}","Other","Website Files", (HttpAction)RootPath); Downloader.RouteAdd("/{Path}","Other","Upload file over put",(HttpAction)UploadFilePut,"PUT"); diff --git a/TYTD.Api/obj/Release/TYTD.Api.csprojAssemblyReference.cache b/TYTD.Api/obj/Release/TYTD.Api.csprojAssemblyReference.cache index 22fae63..ab3b366 100644 Binary files a/TYTD.Api/obj/Release/TYTD.Api.csprojAssemblyReference.cache and b/TYTD.Api/obj/Release/TYTD.Api.csprojAssemblyReference.cache differ diff --git a/bin/Release/youtube-downloader.exe b/bin/Release/youtube-downloader.exe index 05d1b34..8603726 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 a9c2f37..d20928f 100644 --- a/obj/x86/Release/youtube-downloader.csproj.CoreCompileInputs.cache +++ b/obj/x86/Release/youtube-downloader.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -8f38b4bfd3e4101cea207f521c4ab951a53995e7 +511bd001c80deda115b5110ee10fd30363c84ec1 diff --git a/obj/x86/Release/youtube-downloader.csprojAssemblyReference.cache b/obj/x86/Release/youtube-downloader.csprojAssemblyReference.cache index 0188d6d..69461e2 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 05d1b34..8603726 100644 Binary files a/obj/x86/Release/youtube-downloader.exe and b/obj/x86/Release/youtube-downloader.exe differ diff --git a/youtube-downloader.csproj b/youtube-downloader.csproj index ce18ecf..8d6438d 100644 --- a/youtube-downloader.csproj +++ b/youtube-downloader.csproj @@ -122,6 +122,7 @@ +