diff --git a/Program.cs b/Program.cs index 46a6ac5..993bbc3 100644 --- a/Program.cs +++ b/Program.cs @@ -50,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("/api/AddItems", (HttpAction)AddItems,"POST"); Route.Add("/", (rq, rp, args) => { rp.AsFile(rq, Path.Combine(webSitePath, "index.html")); @@ -243,14 +243,20 @@ namespace youtube_downloader } } - private static async Task AddItems(HttpListenerRequest request, HttpListenerResponse response, Dictionary arguments) + private static void AddItems(HttpListenerRequest request, HttpListenerResponse response, Dictionary arguments) { - using (var req = new StreamReader(request.InputStream,request.ContentEncoding)) + var f = request.ParseBody(arguments); + foreach(var file in f.Values) { - List tripletlst = JsonConvert.DeserializeObject>(await req.ReadToEndAsync()); - Server.Functions.Downloader.DownloadItems(tripletlst); - response.Redirect("/"); + + using (var req = new StreamReader(file.Value)) + { + List tripletlst = JsonConvert.DeserializeObject>( req.ReadToEnd()); + Server.Functions.Downloader.DownloadItems(tripletlst); + response.Redirect("/"); + } } + } /* diff --git a/Server/Models/InfoType.cs b/Server/Models/InfoType.cs index 246f65c..fcfe540 100644 --- a/Server/Models/InfoType.cs +++ b/Server/Models/InfoType.cs @@ -22,33 +22,25 @@ namespace youtube_downloader.Server.Models switch(Type) { case InfoType.Video: - VideoId? vid = VideoId.TryParse(Id); - if (vid.HasValue) - { - return new InfomationQueueItem(vid.Value, Resolution, download); - } - break; + VideoId vid = Id; + + return new InfomationQueueItem(vid, Resolution, download); + + case InfoType.Playlist: - PlaylistId? pid = PlaylistId.TryParse(Id); - if (pid.HasValue) - { - return new InfomationQueueItem(pid.Value, Resolution, download); - } - break; + PlaylistId pid = Id; + return new InfomationQueueItem(pid, Resolution, download); + + case InfoType.Channel: - ChannelId? cid = ChannelId.TryParse(Id); - if (cid.HasValue) - { - return new InfomationQueueItem(cid.Value, Resolution, download); - } - break; + ChannelId cid = Id; + return new InfomationQueueItem(cid, Resolution, download); + case InfoType.User: - UserName? user = UserName.TryParse(Id); - if (user.HasValue) - { - return new InfomationQueueItem(user.Value, Resolution, download); - } - break; + UserName user = Id; + + return new InfomationQueueItem(user, Resolution, download); + } return null; } diff --git a/bin/Release/youtube-downloader.exe b/bin/Release/youtube-downloader.exe index 8620c28..3de808b 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 edb43ae..fd726f0 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 8620c28..3de808b 100644 Binary files a/obj/x86/Release/youtube-downloader.exe and b/obj/x86/Release/youtube-downloader.exe differ