Multiple pubfile support

pull/234/head
js6pak 4 years ago
parent ff8f7c0dd2
commit 22fea82562
No known key found for this signature in database
GPG Key ID: EFE980EFD32F8EE9

@ -388,21 +388,24 @@ namespace DepotDownloader
steam3.Disconnect();
}
public static async Task DownloadPubfileAsync(uint appId, ulong publishedFileId)
public static async Task DownloadPubfileAsync(uint appId, ulong[] publishedFileIds)
{
var details = steam3.GetPublishedFileDetails(appId, publishedFileId);
var list = steam3.GetPublishedFileDetails(appId, publishedFileIds);
if (!string.IsNullOrEmpty(details?.file_url))
foreach (var details in list)
{
await DownloadWebFile(appId, details.filename, details.file_url);
}
else if (details?.hcontent_file > 0)
{
await DownloadAppAsync(appId, new List<(uint, ulong)> { (appId, details.hcontent_file) }, DEFAULT_BRANCH, null, null, null, false, true);
}
else
{
Console.WriteLine("Unable to locate manifest ID for published file {0}", publishedFileId);
if (!string.IsNullOrEmpty(details?.file_url))
{
await DownloadWebFile(appId, details.filename, details.file_url);
}
else if (details?.hcontent_file > 0)
{
await DownloadAppAsync(appId, new List<(uint, ulong)> { (appId, details.hcontent_file) }, DEFAULT_BRANCH, null, null, null, false, true);
}
else
{
Console.WriteLine("Unable to locate manifest ID for published file {0}", details?.publishedfileid);
}
}
}

@ -31,7 +31,7 @@ namespace DepotDownloader
new Option<ulong[]>("--manifest", "Manifest id of content to download (requires --depot, default: current for branch)"),
new Option<ulong?>("--ugc", "The UGC ID to download"),
new Option<ulong?>("--pubfile", "The PublishedFileId to download (will automatically resolve to UGC id)"),
new Option<ulong[]>("--pubfile", "The PublishedFileId to download (will automatically resolve to UGC id)"),
new Option<string?>(new[] { "--branch", "--beta" }, "Download from specified branch if available"),
new Option<string?>(new[] { "--branch-password", "--betapassword" }, "Branch password if applicable"),
@ -92,14 +92,14 @@ namespace DepotDownloader
public class InputModel
{
public InputModel(bool debug, uint app, uint[] depot, ulong[] manifest, ulong? ugc, ulong? pubfile, string? branch, string? branchPassword, string[] os, string[] arch, string[] language, bool lowViolence, string? username, string? password, bool rememberPassword, string directory, FileInfo? fileList, bool validate, bool manifestOnly, int? cellId, int maxServers, int maxDownloads, uint? loginId)
public InputModel(bool debug, uint app, uint[] depot, ulong[] manifest, ulong? ugc, ulong[] pubfile, string? branch, string? branchPassword, string[] os, string[] arch, string[] language, bool lowViolence, string? username, string? password, bool rememberPassword, DirectoryInfo? directory, FileInfo? fileList, bool validate, bool manifestOnly, int? cellId, int maxServers, int maxDownloads, uint? loginId)
{
Debug = debug;
AppId = app;
Depots = depot;
Manifests = manifest;
UgcId = ugc;
Pubfile = pubfile;
PublishedFileIds = pubfile;
Branch = EnsureNonEmpty(branch);
BranchPassword = EnsureNonEmpty(branchPassword);
OperatingSystems = os;
@ -133,7 +133,7 @@ namespace DepotDownloader
public ulong[] Manifests { get; }
public ulong? UgcId { get; }
public ulong? Pubfile { get; }
public ulong[] PublishedFileIds { get; }
public string? Branch { get; }
public string? BranchPassword { get; }
@ -230,9 +230,9 @@ namespace DepotDownloader
{
try
{
if (input.Pubfile != null)
if (input.PublishedFileIds.Any())
{
await ContentDownloader.DownloadPubfileAsync(input.AppId, input.Pubfile.Value).ConfigureAwait(false);
await ContentDownloader.DownloadPubfileAsync(input.AppId, input.PublishedFileIds).ConfigureAwait(false);
}
else if (input.UgcId != null)
{

@ -353,13 +353,13 @@ namespace DepotDownloader
}, () => { return completed; });
}
public PublishedFileDetails GetPublishedFileDetails(uint appId, PublishedFileID pubFile)
public List<PublishedFileDetails> GetPublishedFileDetails(uint appId, ulong[] publishedFileIds)
{
var pubFileRequest = new CPublishedFile_GetDetails_Request { appid = appId };
pubFileRequest.publishedfileids.Add(pubFile);
pubFileRequest.publishedfileids.AddRange(publishedFileIds);
var completed = false;
PublishedFileDetails details = null;
List<PublishedFileDetails> details = null;
Action<SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback =>
{
@ -367,11 +367,11 @@ namespace DepotDownloader
if (callback.Result == EResult.OK)
{
var response = callback.GetDeserializedResponse<CPublishedFile_GetDetails_Response>();
details = response.publishedfiledetails.FirstOrDefault();
details = response.publishedfiledetails;
}
else
{
throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfile {pubFile}.");
throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfiles [{string.Join(", ", publishedFileIds)}].");
}
};

Loading…
Cancel
Save