Multiple pubfile support

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

@ -388,10 +388,12 @@ namespace DepotDownloader
steam3.Disconnect(); 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);
foreach (var details in list)
{
if (!string.IsNullOrEmpty(details?.file_url)) if (!string.IsNullOrEmpty(details?.file_url))
{ {
await DownloadWebFile(appId, details.filename, details.file_url); await DownloadWebFile(appId, details.filename, details.file_url);
@ -402,7 +404,8 @@ namespace DepotDownloader
} }
else else
{ {
Console.WriteLine("Unable to locate manifest ID for published file {0}", publishedFileId); 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[]>("--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?>("--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", "--beta" }, "Download from specified branch if available"),
new Option<string?>(new[] { "--branch-password", "--betapassword" }, "Branch password if applicable"), new Option<string?>(new[] { "--branch-password", "--betapassword" }, "Branch password if applicable"),
@ -92,14 +92,14 @@ namespace DepotDownloader
public class InputModel 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; Debug = debug;
AppId = app; AppId = app;
Depots = depot; Depots = depot;
Manifests = manifest; Manifests = manifest;
UgcId = ugc; UgcId = ugc;
Pubfile = pubfile; PublishedFileIds = pubfile;
Branch = EnsureNonEmpty(branch); Branch = EnsureNonEmpty(branch);
BranchPassword = EnsureNonEmpty(branchPassword); BranchPassword = EnsureNonEmpty(branchPassword);
OperatingSystems = os; OperatingSystems = os;
@ -133,7 +133,7 @@ namespace DepotDownloader
public ulong[] Manifests { get; } public ulong[] Manifests { get; }
public ulong? UgcId { get; } public ulong? UgcId { get; }
public ulong? Pubfile { get; } public ulong[] PublishedFileIds { get; }
public string? Branch { get; } public string? Branch { get; }
public string? BranchPassword { get; } public string? BranchPassword { get; }
@ -230,9 +230,9 @@ namespace DepotDownloader
{ {
try 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) else if (input.UgcId != null)
{ {

@ -353,13 +353,13 @@ namespace DepotDownloader
}, () => { return completed; }); }, () => { 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 }; var pubFileRequest = new CPublishedFile_GetDetails_Request { appid = appId };
pubFileRequest.publishedfileids.Add(pubFile); pubFileRequest.publishedfileids.AddRange(publishedFileIds);
var completed = false; var completed = false;
PublishedFileDetails details = null; List<PublishedFileDetails> details = null;
Action<SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback => Action<SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback =>
{ {
@ -367,11 +367,11 @@ namespace DepotDownloader
if (callback.Result == EResult.OK) if (callback.Result == EResult.OK)
{ {
var response = callback.GetDeserializedResponse<CPublishedFile_GetDetails_Response>(); var response = callback.GetDeserializedResponse<CPublishedFile_GetDetails_Response>();
details = response.publishedfiledetails.FirstOrDefault(); details = response.publishedfiledetails;
} }
else 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