mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using Wabbajack.Common;
|
|
|
|
namespace Wabbajack.Lib.Downloaders
|
|
{
|
|
public class DropboxDownloader : IDownloader, IUrlDownloader
|
|
{
|
|
public async Task<AbstractDownloadState?> GetDownloaderState(dynamic archiveINI, bool quickMode)
|
|
{
|
|
var urlstring = archiveINI?.General?.directURL;
|
|
return GetDownloaderState(urlstring);
|
|
}
|
|
|
|
public AbstractDownloadState? GetDownloaderState(string url)
|
|
{
|
|
try
|
|
{
|
|
if (url == null) return null;
|
|
var uri = new UriBuilder(url);
|
|
if (uri.Host != "www.dropbox.com") return null;
|
|
var query = HttpUtility.ParseQueryString(uri.Query);
|
|
|
|
if (query.GetValues("dl")?.Length > 0)
|
|
query.Remove("dl");
|
|
|
|
query.Set("dl", "1");
|
|
|
|
uri.Query = query.ToString();
|
|
|
|
return new HTTPDownloader.State(uri.ToString().Replace("dropbox.com:443/", "dropbox.com/"));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
Utils.Error($"Error downloading Dropbox link: {url}");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task Prepare()
|
|
{
|
|
}
|
|
}
|
|
}
|