2019-10-12 21:37:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
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-11-21 15:51:57 +00:00
|
|
|
|
public 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);
|
|
|
|
|
|
|
|
|
|
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/")
|
|
|
|
|
};
|
|
|
|
|
}
|
2019-10-12 22:15:20 +00:00
|
|
|
|
|
|
|
|
|
public void Prepare()
|
|
|
|
|
{
|
|
|
|
|
}
|
2019-10-12 21:37:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|