Skip to content

Commit 209d838

Browse files
committed
Multiple pubfile support
1 parent 8f6fe83 commit 209d838

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
@@ -379,21 +379,24 @@ public static void ShutdownSteam3()
379379
steam3.Disconnect();
380380
}
381381

382-
public static async Task DownloadPubfileAsync(uint appId, ulong publishedFileId)
382+
public static async Task DownloadPubfileAsync(uint appId, ulong[] publishedFileIds)
383383
{
384-
var details = steam3.GetPublishedFileDetails(appId, publishedFileId);
384+
var list = steam3.GetPublishedFileDetails(appId, publishedFileIds);
385385

386-
if (!string.IsNullOrEmpty(details?.file_url))
386+
foreach (var details in list)
387387
{
388-
await DownloadWebFile(appId, details.filename, details.file_url);
389-
}
390-
else if (details?.hcontent_file > 0)
391-
{
392-
await DownloadAppAsync(appId, new List<(uint, ulong)> { (appId, details.hcontent_file) }, DEFAULT_BRANCH, null, null, null, false, true);
393-
}
394-
else
395-
{
396-
Console.WriteLine("Unable to locate manifest ID for published file {0}", publishedFileId);
388+
if (!string.IsNullOrEmpty(details?.file_url))
389+
{
390+
await DownloadWebFile(appId, details.filename, details.file_url);
391+
}
392+
else if (details?.hcontent_file > 0)
393+
{
394+
await DownloadAppAsync(appId, new List<(uint, ulong)> { (appId, details.hcontent_file) }, DEFAULT_BRANCH, null, null, null, false, true);
395+
}
396+
else
397+
{
398+
Console.WriteLine("Unable to locate manifest ID for published file {0}", details?.publishedfileid);
399+
}
397400
}
398401
}
399402

DepotDownloader/Program.cs

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

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

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

9191
public class InputModel
9292
{
93-
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)
93+
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)
9494
{
9595
Debug = debug;
9696
AppId = app;
9797
Depots = depot;
9898
Manifests = manifest;
9999
UgcId = ugc;
100-
Pubfile = pubfile;
100+
PublishedFileIds = pubfile;
101101
Branch = EnsureNonEmpty(branch);
102102
BranchPassword = EnsureNonEmpty(branchPassword);
103103
OperatingSystems = os;
@@ -131,7 +131,7 @@ public InputModel(bool debug, uint app, uint[] depot, ulong[] manifest, ulong? u
131131
public ulong[] Manifests { get; }
132132

133133
public ulong? UgcId { get; }
134-
public ulong? Pubfile { get; }
134+
public ulong[] PublishedFileIds { get; }
135135

136136
public string? Branch { get; }
137137
public string? BranchPassword { get; }
@@ -223,9 +223,9 @@ public static async Task<int> DownloadAsync(InputModel input)
223223
{
224224
try
225225
{
226-
if (input.Pubfile != null)
226+
if (input.PublishedFileIds.Any())
227227
{
228-
await ContentDownloader.DownloadPubfileAsync(input.AppId, input.Pubfile.Value).ConfigureAwait(false);
228+
await ContentDownloader.DownloadPubfileAsync(input.AppId, input.PublishedFileIds).ConfigureAwait(false);
229229
}
230230
else if (input.UgcId != null)
231231
{

DepotDownloader/Steam3Session.cs

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

387-
public PublishedFileDetails GetPublishedFileDetails(uint appId, PublishedFileID pubFile)
387+
public List<PublishedFileDetails> GetPublishedFileDetails(uint appId, ulong[] publishedFileIds)
388388
{
389389
var pubFileRequest = new CPublishedFile_GetDetails_Request { appid = appId };
390-
pubFileRequest.publishedfileids.Add(pubFile);
390+
pubFileRequest.publishedfileids.AddRange(publishedFileIds);
391391

392392
var completed = false;
393-
PublishedFileDetails details = null;
393+
List<PublishedFileDetails> details = null;
394394

395395
Action<SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback =>
396396
{
397397
completed = true;
398398
if (callback.Result == EResult.OK)
399399
{
400400
var response = callback.GetDeserializedResponse<CPublishedFile_GetDetails_Response>();
401-
details = response.publishedfiledetails.FirstOrDefault();
401+
details = response.publishedfiledetails;
402402
}
403403
else
404404
{
405-
throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfile {pubFile}.");
405+
throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfiles [{string.Join(", ", publishedFileIds)}].");
406406
}
407407
};
408408

0 commit comments

Comments
 (0)