From 05d6da9662e47a6c765dd1dd97278324990e0527 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Fri, 5 Jun 2020 21:47:52 +0300 Subject: [PATCH] Implement package tokens (#103) --- DepotDownloader/DepotDownloader.csproj | 4 ++-- DepotDownloader/Steam3Session.cs | 29 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/DepotDownloader/DepotDownloader.csproj b/DepotDownloader/DepotDownloader.csproj index cb9395df..99dbf8f8 100644 --- a/DepotDownloader/DepotDownloader.csproj +++ b/DepotDownloader/DepotDownloader.csproj @@ -5,7 +5,7 @@ false - - + + \ No newline at end of file diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index a88944e3..ec162698 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -1,5 +1,5 @@ using SteamKit2; -using SteamKit2.Unified.Internal; +using SteamKit2.Internal; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -33,6 +33,7 @@ namespace DepotDownloader public Dictionary AppTickets { get; private set; } public Dictionary AppTokens { get; private set; } + public Dictionary PackageTokens { get; private set; } public Dictionary DepotKeys { get; private set; } public ConcurrentDictionary> CDNAuthTokens { get; private set; } public Dictionary AppInfo { get; private set; } @@ -82,6 +83,7 @@ namespace DepotDownloader this.AppTickets = new Dictionary(); this.AppTokens = new Dictionary(); + this.PackageTokens = new Dictionary(); this.DepotKeys = new Dictionary(); this.CDNAuthTokens = new ConcurrentDictionary>(); this.AppInfo = new Dictionary(); @@ -236,9 +238,24 @@ namespace DepotDownloader } }; + var packageRequests = new List(); + + foreach ( var package in packages ) + { + var request = new SteamApps.PICSRequest( package ); + + if ( PackageTokens.TryGetValue( package, out var token ) ) + { + request.AccessToken = token; + request.Public = false; + } + + packageRequests.Add( request ); + } + WaitUntilCallback( () => { - callbacks.Subscribe( steamApps.PICSGetProductInfo( new List(), packages ), cbMethod ); + callbacks.Subscribe( steamApps.PICSGetProductInfo( new List(), packageRequests ), cbMethod ); }, () => { return completed; } ); } @@ -627,6 +644,14 @@ namespace DepotDownloader Console.WriteLine( "Got {0} licenses for account!", licenseList.LicenseList.Count ); Licenses = licenseList.LicenseList; + + foreach ( var license in licenseList.LicenseList ) + { + if ( license.AccessToken > 0 ) + { + PackageTokens.Add( license.PackageID, license.AccessToken ); + } + } } private void UpdateMachineAuthCallback( SteamUser.UpdateMachineAuthCallback machineAuth )