forked from wabbajack-tools/wabbajack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DepotDownloader.cs
39 lines (31 loc) · 1.11 KB
/
DepotDownloader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Microsoft.Extensions.Logging;
using SteamKit2;
using Wabbajack.Networking.Steam.DTOs;
namespace Wabbajack.Networking.Steam;
public class DepotDownloader
{
private readonly ILogger<DepotDownloader> _logger;
private readonly Client _steamClient;
public DepotDownloader(ILogger<DepotDownloader> logger, Client client)
{
_logger = logger;
_steamClient = client;
}
public async Task<bool> AccountHasAccess(uint depotId)
{
var packages = _steamClient.Licenses.Select(l => l.PackageID);
var infos = await _steamClient.GetPackageInfos(packages);
foreach (var info in infos.Where(i => i.Value != null))
{
if (info.Value!.KeyValues["appids"].Children.Any(child => child.AsUnsignedInteger() == depotId))
return true;
if (info.Value!.KeyValues["depotids"].Children.Any(child => child.AsUnsignedInteger() == depotId))
return true;
}
return false;
}
public async Task<AppInfo> GetAppInfo(uint appId)
{
return await _steamClient.GetAppInfo(appId);
}
}