Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to System.CommandLine #234

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions DepotDownloader/ContentDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public static bool InitializeSteam3(string username, string password)

if (username != null && Config.RememberPassword)
{
_ = AccountSettingsStore.Instance.LoginTokens.TryGetValue(username, out loginToken);
_ = AccountSettingsStore.Instance.LoginTokens.TryGetValue(username.ToLowerInvariant(), out loginToken);
}

steam3 = new Steam3Session(
Expand Down Expand Up @@ -350,21 +350,31 @@ public static void ShutdownSteam3()
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))
{
await DownloadWebFile(appId, details.filename, details.file_url);
}
else if (details?.hcontent_file > 0)
var hcontentFiles = new HashSet<ulong>();

foreach (var details in list)
{
await DownloadAppAsync(appId, new List<(uint, ulong)> { (appId, details.hcontent_file) }, DEFAULT_BRANCH, null, null, null, false, true);
if (!string.IsNullOrEmpty(details?.file_url))
{
await DownloadWebFile(appId, details.filename, details.file_url);
}
else if (details?.hcontent_file > 0)
{
hcontentFiles.Add(details.hcontent_file);
}
else
{
Console.WriteLine("Unable to locate manifest ID for published file {0}", details?.publishedfileid);
}
}
else

if (hcontentFiles.Count > 0)
{
Console.WriteLine("Unable to locate manifest ID for published file {0}", publishedFileId);
await DownloadAppAsync(appId, hcontentFiles.Select(f => (appId, f)).ToList(), DEFAULT_BRANCH, null, null, null, false, true);
}
}

Expand Down Expand Up @@ -423,7 +433,7 @@ private static async Task DownloadWebFile(uint appId, string fileName, string ur
File.Move(fileStagingPath, fileFinalPath);
}

public static async Task DownloadAppAsync(uint appId, List<(uint depotId, ulong manifestId)> depotManifestIds, string branch, string os, string arch, string language, bool lv, bool isUgc)
public static async Task DownloadAppAsync(uint appId, List<(uint depotId, ulong manifestId)> depotManifestIds, string branch, string[] os, string[] arch, string[] language, bool lv, bool isUgc)
{
cdnPool = new CDNClientPool(steam3, appId);

Expand Down Expand Up @@ -500,15 +510,15 @@ public static async Task DownloadAppAsync(uint appId, List<(uint depotId, ulong
!string.IsNullOrWhiteSpace(depotConfig["oslist"].Value))
{
var oslist = depotConfig["oslist"].Value.Split(',');
if (Array.IndexOf(oslist, os ?? Util.GetSteamOS()) == -1)
if (!os.Any(x => oslist.Contains(x)))
continue;
}

if (depotConfig["osarch"] != KeyValue.Invalid &&
!string.IsNullOrWhiteSpace(depotConfig["osarch"].Value))
{
var depotArch = depotConfig["osarch"].Value;
if (depotArch != (arch ?? Util.GetSteamArch()))
if (!arch.Contains(depotArch))
continue;
}

Expand All @@ -517,7 +527,7 @@ public static async Task DownloadAppAsync(uint appId, List<(uint depotId, ulong
!string.IsNullOrWhiteSpace(depotConfig["language"].Value))
{
var depotLang = depotConfig["language"].Value;
if (depotLang != (language ?? "english"))
if (!language.Contains(depotLang))
continue;
}

Expand Down
8 changes: 5 additions & 3 deletions DepotDownloader/DepotDownloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="protobuf-net" Version="3.2.16" />
<PackageReference Include="QRCoder" Version="1.4.3" />
<PackageReference Include="SteamKit2" Version="2.5.0-Beta.1" />
<PackageReference Include="protobuf-net" Version="3.2.16" />
<PackageReference Include="QRCoder" Version="1.4.3" />
<PackageReference Include="SteamKit2" Version="2.5.0-Beta.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta2.21617.1" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta2.21617.1" />
</ItemGroup>
</Project>
Loading