wabbajack/Wabbajack.Lib/Downloaders/DropboxDownloader.cs
erri120 fda325eecf
Revert "Changed Url to URL and removed GetReportEntry"
This reverts commit d62d40add41e7c7e37c2b6bae677bcc6c1d1f356.
2020-02-02 13:52:53 +01:00

40 lines
1.1 KiB
C#

using System;
using System.Threading.Tasks;
using System.Web;
namespace Wabbajack.Lib.Downloaders
{
public class DropboxDownloader : IDownloader, IUrlDownloader
{
public async Task<AbstractDownloadState> GetDownloaderState(dynamic archiveINI)
{
var urlstring = archiveINI?.General?.directURL;
return GetDownloaderState(urlstring);
}
public AbstractDownloadState GetDownloaderState(string url)
{
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()
{
Url = uri.ToString().Replace("dropbox.com:443/", "dropbox.com/")
};
}
public async Task Prepare()
{
}
}
}