Skip to content

Commit 22fea82

Browse files
committed
Multiple pubfile support
1 parent ff8f7c0 commit 22fea82

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

DepotDownloader/ContentDownloader.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -388,21 +388,24 @@ public static void ShutdownSteam3()
388388
steam3.Disconnect();
389389
}
390390

391-
public static async Task DownloadPubfileAsync(uint appId, ulong publishedFileId)
391+
public static async Task DownloadPubfileAsync(uint appId, ulong[] publishedFileIds)
392392
{
393-
var details = steam3.GetPublishedFileDetails(appId, publishedFileId);
393+
var list = steam3.GetPublishedFileDetails(appId, publishedFileIds);
394394

395-
if (!string.IsNullOrEmpty(details?.file_url))
395+
foreach (var details in list)
396396
{
397-
await DownloadWebFile(appId, details.filename, details.file_url);
398-
}
399-
else if (details?.hcontent_file > 0)
400-
{
401-
await DownloadAppAsync(appId, new List<(uint, ulong)> { (appId, details.hcontent_file) }, DEFAULT_BRANCH, null, null, null, false, true);
402-
}
403-
else
404-
{
405-
Console.WriteLine("Unable to locate manifest ID for published file {0}", publishedFileId);
397+
if (!string.IsNullOrEmpty(details?.file_url))
398+
{
399+
await DownloadWebFile(appId, details.filename, details.file_url);
400+
}
401+
else if (details?.hcontent_file > 0)
402+
{
403+
await DownloadAppAsync(appId, new List<(uint, ulong)> { (appId, details.hcontent_file) }, DEFAULT_BRANCH, null, null, null, false, true);
404+
}
405+
else
406+
{
407+
Console.WriteLine("Unable to locate manifest ID for published file {0}", details?.publishedfileid);
408+
}
406409
}
407410
}
408411

DepotDownloader/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static Task<int> Main(string[] args)
3131
new Option<ulong[]>("--manifest", "Manifest id of content to download (requires --depot, default: current for branch)"),
3232

3333
new Option<ulong?>("--ugc", "The UGC ID to download"),
34-
new Option<ulong?>("--pubfile", "The PublishedFileId to download (will automatically resolve to UGC id)"),
34+
new Option<ulong[]>("--pubfile", "The PublishedFileId to download (will automatically resolve to UGC id)"),
3535

3636
new Option<string?>(new[] { "--branch", "--beta" }, "Download from specified branch if available"),
3737
new Option<string?>(new[] { "--branch-password", "--betapassword" }, "Branch password if applicable"),
@@ -92,14 +92,14 @@ protected override void AddUsage(ICommand command)
9292

9393
public class InputModel
9494
{
95-
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)
95+
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)
9696
{
9797
Debug = debug;
9898
AppId = app;
9999
Depots = depot;
100100
Manifests = manifest;
101101
UgcId = ugc;
102-
Pubfile = pubfile;
102+
PublishedFileIds = pubfile;
103103
Branch = EnsureNonEmpty(branch);
104104
BranchPassword = EnsureNonEmpty(branchPassword);
105105
OperatingSystems = os;
@@ -133,7 +133,7 @@ public InputModel(bool debug, uint app, uint[] depot, ulong[] manifest, ulong? u
133133
public ulong[] Manifests { get; }
134134

135135
public ulong? UgcId { get; }
136-
public ulong? Pubfile { get; }
136+
public ulong[] PublishedFileIds { get; }
137137

138138
public string? Branch { get; }
139139
public string? BranchPassword { get; }
@@ -230,9 +230,9 @@ public static async Task<int> DownloadAsync(InputModel input)
230230
{
231231
try
232232
{
233-
if (input.Pubfile != null)
233+
if (input.PublishedFileIds.Any())
234234
{
235-
await ContentDownloader.DownloadPubfileAsync(input.AppId, input.Pubfile.Value).ConfigureAwait(false);
235+
await ContentDownloader.DownloadPubfileAsync(input.AppId, input.PublishedFileIds).ConfigureAwait(false);
236236
}
237237
else if (input.UgcId != null)
238238
{

DepotDownloader/Steam3Session.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,25 +353,25 @@ public void CheckAppBetaPassword(uint appid, string password)
353353
}, () => { return completed; });
354354
}
355355

356-
public PublishedFileDetails GetPublishedFileDetails(uint appId, PublishedFileID pubFile)
356+
public List<PublishedFileDetails> GetPublishedFileDetails(uint appId, ulong[] publishedFileIds)
357357
{
358358
var pubFileRequest = new CPublishedFile_GetDetails_Request { appid = appId };
359-
pubFileRequest.publishedfileids.Add(pubFile);
359+
pubFileRequest.publishedfileids.AddRange(publishedFileIds);
360360

361361
var completed = false;
362-
PublishedFileDetails details = null;
362+
List<PublishedFileDetails> details = null;
363363

364364
Action<SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback =>
365365
{
366366
completed = true;
367367
if (callback.Result == EResult.OK)
368368
{
369369
var response = callback.GetDeserializedResponse<CPublishedFile_GetDetails_Response>();
370-
details = response.publishedfiledetails.FirstOrDefault();
370+
details = response.publishedfiledetails;
371371
}
372372
else
373373
{
374-
throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfile {pubFile}.");
374+
throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfiles [{string.Join(", ", publishedFileIds)}].");
375375
}
376376
};
377377

0 commit comments

Comments
 (0)