Vector Plexus now uses a native IPS4 REST API and OAuth2

This commit is contained in:
Timothy Baldridge 2021-06-15 05:50:37 -06:00
parent 0441bbaf17
commit ee8669f3ce
2 changed files with 34 additions and 3 deletions

View File

@ -108,11 +108,10 @@ namespace Wabbajack.Lib.Downloaders
}
public abstract class State : AbstractDownloadState
public abstract class State : AbstractDownloadState, IMetaState
{
public long IPS4Mod { get; set; }
public string IPS4File { get; set; } = "";
public string IPS4Url { get; set; } = "";
public override object[] PrimaryKey => new object[] {IPS4Mod, IPS4File};
@ -160,6 +159,26 @@ namespace Wabbajack.Lib.Downloaders
$"ips4File={IPS4File}"
};
}
public Uri URL => new(IPS4Url);
public string? Name { get; set; }
public string? Author { get; set; }
public string? Version { get; set; }
public Uri? ImageURL { get; set; }
public bool IsNSFW { get; set; }
public string? Description { get; set; }
public async Task<bool> LoadMetaData()
{
var data = await TypedDownloader.GetDownloads(IPS4Mod);
Name = data.Title;
Author = data.Author?.Name;
Version = data.Version;
ImageURL = data.PrimaryScreenshot.Url != null ? new Uri(data.PrimaryScreenshot.Url) : null;
IsNSFW = true;
Description = "";
IPS4Url = data.Url!;
return true;
}
}
}

View File

@ -416,11 +416,23 @@ namespace Wabbajack.Test
Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List<string>() }));
await converted.Download(new Archive(state: null!) { Name = "Vector Plexus Test.zip" }, filename.Path);
var archive = new Archive(state: null!) {Name = "Vector Plexus Test.zip"};
await converted.Download(archive, filename.Path);
Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await filename.Path.FileHashAsync());
Assert.Equal("Cheese for Everyone!", await filename.Path.ReadAllTextAsync());
Assert.True(converted is VectorPlexusOAuthDownloader.State);
var st = (VectorPlexusOAuthDownloader.State)converted;
Assert.True(await st.LoadMetaData());
Assert.Equal("halgari", st.Author);
Assert.Equal("Wabbajack Test File", st.Name);
Assert.True(st.IsNSFW);
Assert.Equal("1.0.0", st.Version);
Assert.Equal("https://vectorplexus.com/files/file/290-wabbajack-test-file/", st.GetManifestURL(archive));
Assert.True(st.ImageURL != null);
}