2020-02-04 02:30:28 +00:00
|
|
|
using System;
|
2019-12-07 02:45:13 +00:00
|
|
|
using System.Threading.Tasks;
|
2019-10-12 21:37:16 +00:00
|
|
|
using System.Web;
|
|
|
|
|
2019-10-16 03:10:34 +00:00
|
|
|
namespace Wabbajack.Lib.Downloaders
|
2019-10-12 21:37:16 +00:00
|
|
|
{
|
2019-10-16 11:44:45 +00:00
|
|
|
public class DropboxDownloader : IDownloader, IUrlDownloader
|
2019-10-12 21:37:16 +00:00
|
|
|
{
|
2019-12-07 03:50:50 +00:00
|
|
|
public async Task<AbstractDownloadState> GetDownloaderState(dynamic archiveINI)
|
2019-10-12 21:37:16 +00:00
|
|
|
{
|
2019-11-21 15:51:57 +00:00
|
|
|
var urlstring = archiveINI?.General?.directURL;
|
2019-10-16 11:44:45 +00:00
|
|
|
return GetDownloaderState(urlstring);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AbstractDownloadState GetDownloaderState(string url)
|
|
|
|
{
|
|
|
|
if (url == null) return null;
|
|
|
|
var uri = new UriBuilder(url);
|
2019-10-12 21:37:16 +00:00
|
|
|
if (uri.Host != "www.dropbox.com") return null;
|
|
|
|
var query = HttpUtility.ParseQueryString(uri.Query);
|
|
|
|
|
2020-02-04 02:30:28 +00:00
|
|
|
if (query.GetValues("dl")?.Length > 0)
|
2019-10-12 21:37:16 +00:00
|
|
|
query.Remove("dl");
|
|
|
|
|
|
|
|
query.Set("dl", "1");
|
|
|
|
|
|
|
|
uri.Query = query.ToString();
|
|
|
|
|
|
|
|
return new HTTPDownloader.State()
|
|
|
|
{
|
|
|
|
Url = uri.ToString().Replace("dropbox.com:443/", "dropbox.com/")
|
|
|
|
};
|
|
|
|
}
|
2019-10-12 22:15:20 +00:00
|
|
|
|
2019-12-07 02:45:13 +00:00
|
|
|
public async Task Prepare()
|
2019-10-12 22:15:20 +00:00
|
|
|
{
|
|
|
|
}
|
2019-10-12 21:37:16 +00:00
|
|
|
}
|
|
|
|
}
|