wabbajack/Wabbajack.Lib/Downloaders/DropboxDownloader.cs

39 lines
1.0 KiB
C#
Raw Normal View History

using System;
using System.Web;
namespace Wabbajack.Lib.Downloaders
{
public class DropboxDownloader : IDownloader, IUrlDownloader
{
2019-11-21 15:51:57 +00:00
public AbstractDownloadState GetDownloaderState(dynamic archiveINI)
{
2019-11-21 15:51:57 +00:00
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 void Prepare()
{
}
}
}