Add basic support for downloading Workshop collections (#661)

pull/664/head
Nicholas Hastings 1 month ago
parent d5afc41b97
commit 2fba893440

@ -337,19 +337,54 @@ namespace DepotDownloader
public static async Task DownloadPubfileAsync(uint appId, ulong publishedFileId)
{
var details = await steam3.GetPublishedFileDetails(appId, publishedFileId);
List<ValueTuple<string, string>> fileUrls = new();
List<ulong> contentFileIds = new();
if (!string.IsNullOrEmpty(details?.file_url))
var details = await steam3.GetPublishedFileDetails(appId, publishedFileId);
if (details.file_type == (uint)EWorkshopFileType.Collection)
{
await DownloadWebFile(appId, details.filename, details.file_url);
foreach (var child in details.children)
{
var childDetails = await steam3.GetPublishedFileDetails(appId, child.publishedfileid);
if (!string.IsNullOrEmpty(childDetails?.file_url))
{
fileUrls.Add((childDetails.filename, childDetails.file_url));
}
else if (details?.hcontent_file > 0)
{
contentFileIds.Add(childDetails.hcontent_file);
}
else
{
Console.WriteLine("Unable to locate manifest ID for published file {0} in collection {1}", childDetails.publishedfileid, publishedFileId);
}
}
}
else if (details?.hcontent_file > 0)
else
{
await DownloadAppAsync(appId, new List<(uint, ulong)> { (appId, details.hcontent_file) }, DEFAULT_BRANCH, null, null, null, false, true);
if (!string.IsNullOrEmpty(details?.file_url))
{
fileUrls.Add((details.filename, details.file_url));
}
else if (details?.hcontent_file > 0)
{
contentFileIds.Add(details.hcontent_file);
}
else
{
Console.WriteLine("Unable to locate manifest ID for published file {0}", publishedFileId);
}
}
else
foreach (var item in fileUrls)
{
await DownloadWebFile(appId, item.Item1, item.Item2);
}
if (contentFileIds.Count > 0)
{
Console.WriteLine("Unable to locate manifest ID for published file {0}", publishedFileId);
var depotManifestIds = contentFileIds.Select(id => (appId, id)).ToList();
await DownloadAppAsync(appId, depotManifestIds, DEFAULT_BRANCH, null, null, null, false, true);
}
}

@ -333,7 +333,11 @@ namespace DepotDownloader
public async Task<PublishedFileDetails> GetPublishedFileDetails(uint appId, PublishedFileID pubFile)
{
var pubFileRequest = new CPublishedFile_GetDetails_Request { appid = appId };
var pubFileRequest = new CPublishedFile_GetDetails_Request
{
appid = appId,
includechildren = true,
};
pubFileRequest.publishedfileids.Add(pubFile);
var details = await steamPublishedFile.GetDetails(pubFileRequest);

Loading…
Cancel
Save