diff --git a/.vs/youtube-downloader/xs/UserPrefs.xml b/.vs/youtube-downloader/xs/UserPrefs.xml index 31f0540..65dc63e 100644 --- a/.vs/youtube-downloader/xs/UserPrefs.xml +++ b/.vs/youtube-downloader/xs/UserPrefs.xml @@ -1,13 +1,13 @@  - + - + - + diff --git a/Program.cs b/Program.cs index 8e8a4db..020bc74 100644 --- a/Program.cs +++ b/Program.cs @@ -119,7 +119,7 @@ namespace TYTD Route.Add("/extensions.html", (HttpAction)Extensions); Route.Add("/{Path}", (HttpAction)RootPath); Route.Add("/{Path}",(HttpAction)UploadFilePut,"PUT"); - Console.CancelKeyPress += (sender, e) => { ApiLoader.Dispose();var date = DateTime.Now.ToString("yyyyMMdd_HHmmss");Directory.CreateDirectory(Path.Combine("config","queues-close")); File.WriteAllText(Path.Combine("config","queues-close",$"{date}.json"), Downloader.GetQueue()); e.Cancel = false; }; + Console.CancelKeyPress += (sender, e) => { ApiLoader.Dispose();var date = DateTime.Now.ToString("yyyyMMdd_HHmmss");Directory.CreateDirectory(Path.Combine("config","queues-close")); File.WriteAllText(Path.Combine("config", "queues-close", $"{date}.json"), Downloader.GetQueue()); Console.WriteLine("TYTD has Closed"); Environment.Exit(0); }; Console.WriteLine("Almost Ready To Listen"); @@ -164,40 +164,44 @@ namespace TYTD { Downloader.DownloadItem(System.Web.HttpUtility.UrlDecode(args["Id"])); - rp.AsText(""); + rp.AsText("\n"); } public static void AddItemRes(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadItem(System.Web.HttpUtility.UrlDecode(args["Id"]), (Resolution)int.Parse(args["R"])); - rp.AsText(""); + rp.AsText("\n"); } public static void AddFile(HttpListenerRequest request, HttpListenerResponse response, Dictionary arguments) { Downloader.DownloadFile(arguments["Url"]); + response.AsText("\n"); } public static void AddCaptions(HttpListenerRequest request, HttpListenerResponse response, Dictionary arguments) { Downloader.DownloadCaptions(arguments["Id"]); + response.AsText("\n"); + } #endregion #region Video public static void AddVideoInfo(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadVideoInfo(System.Web.HttpUtility.UrlDecode(args["Id"]), Resolution.NoConvert); - rp.AsText(""); + rp.AsText("\n"); + } public static void AddVideo(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadVideo(System.Web.HttpUtility.UrlDecode(args["Id"])); - rp.AsText(""); + rp.AsText("\n"); } public static void AddVideoRes(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadVideo(System.Web.HttpUtility.UrlDecode(args["Id"]), (Resolution)int.Parse(args["R"])); - rp.AsText(""); + rp.AsText("\n"); } public static void Redownload(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { @@ -206,7 +210,7 @@ namespace TYTD string id =Path.GetFileNameWithoutExtension(item); Downloader.DownloadVideo(id, Resolution.NoConvert); } - rp.AsText(""); + rp.AsText("\n"); } public static void RedownloadRes(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) @@ -216,7 +220,7 @@ namespace TYTD string id = System.IO.Path.GetFileNameWithoutExtension(item); Downloader.DownloadVideo(id, (Resolution)int.Parse(args["R"])); } - rp.AsText(""); + rp.AsText("\n"); } public static void Watch(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { @@ -228,18 +232,18 @@ namespace TYTD public static void AddPlaylistOnly(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadPlaylistOnly(System.Web.HttpUtility.UrlDecode(args["Id"]), Resolution.NoConvert); - rp.AsText(""); + rp.AsText("\n"); } public static void AddPlaylist(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadPlaylist(System.Web.HttpUtility.UrlDecode(args["Id"])); - rp.AsText(""); + rp.AsText("\n"); } public static void AddPlaylistRes(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadPlaylist(System.Web.HttpUtility.UrlDecode(args["Id"]), (Resolution)int.Parse(args["R"])); - rp.AsText(""); + rp.AsText("\n"); } public static void PersonalPlaylist(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { @@ -390,36 +394,36 @@ namespace TYTD { Downloader.DownloadChannelOnly(System.Web.HttpUtility.UrlDecode(args["Id"])); - rp.AsText(""); + rp.AsText("\n"); } public static void AddChannel(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadChannel(System.Web.HttpUtility.UrlDecode(args["Id"])); - rp.AsText(""); + rp.AsText("\n"); } public static void AddChannelRes(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadChannel(System.Web.HttpUtility.UrlDecode(args["Id"]), (Resolution)int.Parse(args["R"])); - rp.AsText(""); + rp.AsText("\n"); } #endregion #region User public static void AddUserOnly(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadUserOnly(System.Web.HttpUtility.UrlDecode(args["Id"])); - rp.AsText(""); + rp.AsText("\n"); } public static void AddUser(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadUser(System.Web.HttpUtility.UrlDecode(args["Id"])); - rp.AsText(""); + rp.AsText("\n"); } public static void AddUserRes(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.DownloadUser(System.Web.HttpUtility.UrlDecode(args["Id"]), (Resolution)int.Parse(args["R"])); - rp.AsText(""); + rp.AsText("\n"); } #endregion #region Queue And Progress @@ -431,7 +435,7 @@ namespace TYTD public static void QueueMove(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { Downloader.ModQueue(args["To"], args["From"]); - rp.AsText(""); + rp.AsText("\n"); } public static void QueueMove2(HttpListenerRequest request, HttpListenerResponse response, Dictionary arguments) { @@ -450,7 +454,7 @@ namespace TYTD Downloader.RedownloadIt = true; Downloader.DL.cancelSrc.Item.Cancel(); } - + rp.AsText("\n"); } public static void Cancel(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary args) { @@ -460,7 +464,7 @@ namespace TYTD Downloader.RedownloadIt = false; Downloader.DL.cancelSrc.Item.Cancel(); } - + rp.AsText("\n"); } #endregion #region Storage diff --git a/TYTD.Api/Server/Models/InfomationQueueItem.cs b/TYTD.Api/Server/Models/InfomationQueueItem.cs index 81e37f0..de96257 100644 --- a/TYTD.Api/Server/Models/InfomationQueueItem.cs +++ b/TYTD.Api/Server/Models/InfomationQueueItem.cs @@ -99,7 +99,9 @@ namespace TYTD.Server.Models string langFileName = $"{trackType}_{track.Language.Code}.srt"; string track2 = Functions.Downloader.DL.GetPath(true, "ClosedCaptions", Data,langFileName); await Functions.Downloader.DL.ytc.Videos.ClosedCaptions.DownloadAsync(track, track2); + await Task.Delay(10); } + } break; case InfoType.Video: @@ -115,6 +117,7 @@ namespace TYTD.Server.Models foreach(var tn in sv.Video.Thumbnails) { Functions.Downloader.DL._DownloadThumbnail2(tn.Item1, tn.Item2, sv.Video.Id, tn.Item3); + await Task.Delay(10); } } else{ @@ -153,6 +156,7 @@ namespace TYTD.Server.Models foreach (var tn in sv.Video.Thumbnails) { Functions.Downloader.DL._DownloadThumbnail2(tn.Item1, tn.Item2, sv.Video.Id, tn.Item3); + await Task.Delay(10); } } else @@ -161,7 +165,7 @@ namespace TYTD.Server.Models { var vinfo = await Functions.Downloader.DL.ytc.Videos.GetAsync(str); - + await Task.Delay(10); sv = SavedVideo.CreateFrom(res, vinfo, Functions.Downloader.DL._DownloadThumbnail); }catch(Exception ex) { @@ -209,6 +213,7 @@ namespace TYTD.Server.Models foreach (var tn in sv.Video.Thumbnails) { Functions.Downloader.DL._DownloadThumbnail2(tn.Item1, tn.Item2, sv.Video.Id, tn.Item3); + await Task.Delay(10); } video.Add(sv); } @@ -271,6 +276,7 @@ namespace TYTD.Server.Models foreach (var tn in sv.Video.Thumbnails) { Functions.Downloader.DL._DownloadThumbnail2(tn.Item1, tn.Item2, sv.Video.Id, tn.Item3); + await Task.Delay(10); } video.Add(sv); } @@ -283,6 +289,7 @@ namespace TYTD.Server.Models SavedVideoObject sv = SavedVideo.CreateFrom(res, vinfo, Functions.Downloader.DL._DownloadThumbnail); video.Add(sv); + await Task.Delay(10); } catch (Exception ex) { diff --git a/TYTD.Api/Server/Models/SavedPlaylist.cs b/TYTD.Api/Server/Models/SavedPlaylist.cs index 60f3741..74baab7 100644 --- a/TYTD.Api/Server/Models/SavedPlaylist.cs +++ b/TYTD.Api/Server/Models/SavedPlaylist.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using Dasync.Collections; @@ -26,6 +27,7 @@ namespace TYTD.Server.Models foreach (var thumb in pl.Thumbnails) { downloadThumbnail(thumb.Resolution.Width, thumb.Resolution.Height,id, thumb.Url); + await Task.Delay(10); } try { @@ -34,7 +36,7 @@ namespace TYTD.Server.Models addToQueue(v.Id, res); pl2.Videos.Add(v.Id); - + Thread.Sleep(10); }); }catch(Exception ex) { diff --git a/TYTD.Api/bin/Release/TYTD.Api.dll b/TYTD.Api/bin/Release/TYTD.Api.dll index c0c4887..d719c5e 100644 Binary files a/TYTD.Api/bin/Release/TYTD.Api.dll and b/TYTD.Api/bin/Release/TYTD.Api.dll differ diff --git a/TYTD.Api/obj/Release/TYTD.Api.csprojAssemblyReference.cache b/TYTD.Api/obj/Release/TYTD.Api.csprojAssemblyReference.cache index d34f8d5..246f72e 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/TYTD.Api/obj/Release/TYTD.Api.dll b/TYTD.Api/obj/Release/TYTD.Api.dll index c0c4887..d719c5e 100644 Binary files a/TYTD.Api/obj/Release/TYTD.Api.dll and b/TYTD.Api/obj/Release/TYTD.Api.dll differ diff --git a/bin/Release/TYTD.Api.dll b/bin/Release/TYTD.Api.dll index c0c4887..d719c5e 100644 Binary files a/bin/Release/TYTD.Api.dll and b/bin/Release/TYTD.Api.dll differ diff --git a/bin/Release/youtube-downloader.exe b/bin/Release/youtube-downloader.exe index 372b612..9796657 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.csprojAssemblyReference.cache b/obj/x86/Release/youtube-downloader.csprojAssemblyReference.cache index 1238fd0..2d9e6c9 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 372b612..9796657 100644 Binary files a/obj/x86/Release/youtube-downloader.exe and b/obj/x86/Release/youtube-downloader.exe differ