Refactor settings and enhance download manager
Refactor application to use SettingService for managing settings. Update project to target Windows desktop application. Enhance DownloadManagerService for better task handling. Add new dependencies and remove obsolete settings files. Improve UI feedback and notifications for user actions.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using DownloadManager.Utilities;
|
||||
using System.IO;
|
||||
|
||||
namespace DownloadManager.Models.UrlGetter
|
||||
{
|
||||
@@ -6,8 +7,15 @@ namespace DownloadManager.Models.UrlGetter
|
||||
{
|
||||
public async Task<FileUrl> GetFileUrl(string taskUrl)
|
||||
{
|
||||
var fileName = System.IO.Path.GetFileName(taskUrl).ToUnescapedString();
|
||||
string? fileName = null;
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var extension = Path.GetExtension(taskUrl);
|
||||
fileName = string.IsNullOrEmpty(extension) ? "index.html" : Path.GetFileName(taskUrl).ToUnescapedString();
|
||||
});
|
||||
|
||||
return new FileUrl(taskUrl, fileName, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
return type switch
|
||||
{
|
||||
UrlGetterType.Direct => new DirectUrlGetter(),
|
||||
UrlGetterType.Yande => new YandeUrlGetter(),
|
||||
UrlGetterType.YandePost => new YandeUrlGetter(),
|
||||
_ => throw new ArgumentException("Invalid UrlGetterType"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ namespace DownloadManager.Models.UrlGetter
|
||||
[Description("Direct")]
|
||||
Direct,
|
||||
[Description("Yande post URL")]
|
||||
Yande,
|
||||
YandePost,
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ public class YandeUrlGetter : IUrlGetter
|
||||
|
||||
public async Task<FileUrl> GetFileUrl(string taskUrl)
|
||||
{
|
||||
if (!taskUrl.StartsWith("https://yande.re/post/show/"))
|
||||
return new FileUrl(null, null, null);
|
||||
|
||||
// Get the ID of the post from the URL
|
||||
var id = taskUrl.Split("https://yande.re/post/show/").Last();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user