@@ -24,7 +24,7 @@ public class ApiResponse
2424 public string status { get ; set ; }
2525 public int total_depot_ids { get ; set ; }
2626 public int existing_count { get ; set ; }
27- public List < string > depot_ids { get ; set ; }
27+ public List < string > existing_depot_ids { get ; set ; }
2828 public string timestamp { get ; set ; }
2929 }
3030
@@ -39,6 +39,7 @@ static async Task<int> Main( string[] args )
3939
4040 string apiKey = GetParameter < string > ( args , "-apikey" , null ) ;
4141 HashSet < uint > existingDepotIds = null ;
42+ bool hasApiKey = false ;
4243
4344 if ( ! string . IsNullOrWhiteSpace ( apiKey ) )
4445 {
@@ -48,10 +49,22 @@ static async Task<int> Main( string[] args )
4849 if ( existingDepotIds != null && existingDepotIds . Count > 0 )
4950 {
5051 Console . WriteLine ( "Loaded {0} depot IDs already in database" , existingDepotIds . Count ) ;
52+ hasApiKey = true ;
5153 }
5254 else
5355 {
54- Console . WriteLine ( "Failed to fetch depot IDs from API, will dump all depots" ) ;
56+ Console . WriteLine ( "Failed to fetch depot IDs from API - API key may be invalid" ) ;
57+ Console . Write ( "Continue dumping without API key filtering? (yes/no): " ) ;
58+ string response = Console . ReadLine ( ) ? . Trim ( ) . ToLower ( ) ;
59+
60+ if ( response != "yes" && response != "y" )
61+ {
62+ Console . WriteLine ( "Exiting..." ) ;
63+ return 1 ;
64+ }
65+
66+ Console . WriteLine ( "Continuing without API key filtering..." ) ;
67+ existingDepotIds = null ;
5568 }
5669 }
5770
@@ -60,30 +73,27 @@ static async Task<int> Main( string[] args )
6073 Console . Write ( "Username: " ) ;
6174 user = Console . ReadLine ( ) ;
6275
63- if ( ! string . IsNullOrWhiteSpace ( user ) )
76+ if ( string . IsNullOrWhiteSpace ( user ) )
6477 {
65- do
66- {
67- Console . Write ( "Password: " ) ;
68- if ( Console . IsInputRedirected )
69- {
70- password = Console . ReadLine ( ) ;
71- }
72- else
73- {
74- // Avoid console echoing of password
75- password = Util . ReadPassword ( ) ;
76- }
77-
78- Console . WriteLine ( ) ;
79- } while ( string . Empty == password ) ;
78+ Console . WriteLine ( "Username is required. Anonymous login is not supported." ) ;
79+ return 1 ;
8080 }
81- else
81+
82+ do
8283 {
83- // Login anonymously.
84- user = null ;
85- password = null ;
86- }
84+ Console . Write ( "Password: " ) ;
85+ if ( Console . IsInputRedirected )
86+ {
87+ password = Console . ReadLine ( ) ;
88+ }
89+ else
90+ {
91+ // Avoid console echoing of password
92+ password = Util . ReadPassword ( ) ;
93+ }
94+
95+ Console . WriteLine ( ) ;
96+ } while ( string . Empty == password ) ;
8797 }
8898
8999 AccountSettingsStore . LoadFromFile ( "xxx" ) ;
@@ -104,25 +114,15 @@ static async Task<int> Main( string[] args )
104114 return 1 ;
105115 }
106116
107- IEnumerable < uint > licenseQuery ;
108- if ( steam3 . steamUser . SteamID . AccountType == EAccountType . AnonUser )
109- {
110- licenseQuery = new List < uint > ( ) { 17906 } ;
111- }
112- else
113- {
114- Console . WriteLine ( "Getting licenses..." ) ;
115- steam3 . WaitUntilCallback ( ( ) => { } , ( ) => { return steam3 . Licenses != null ; } ) ;
116- licenseQuery = steam3 . Licenses . Select ( x => x . PackageID ) . Distinct ( ) ;
117- }
117+ Console . WriteLine ( "Getting licenses..." ) ;
118+ steam3 . WaitUntilCallback ( ( ) => { } , ( ) => { return steam3 . Licenses != null ; } ) ;
119+ var licenseQuery = steam3 . Licenses . Select ( x => x . PackageID ) . Distinct ( ) ;
118120
119121 await steam3 . RequestPackageInfo ( licenseQuery ) ;
120122
121123 if ( Config . TargetAppId == uint . MaxValue )
122124 {
123- string filenameUser = ( steam3 . steamUser . SteamID . AccountType != EAccountType . AnonUser ) ? user : "anon" ;
124-
125- StreamWriter sw_pkgs = new StreamWriter ( string . Format ( "{0}_pkgs.txt" , filenameUser ) ) ;
125+ StreamWriter sw_pkgs = new StreamWriter ( string . Format ( "{0}_pkgs.txt" , user ) ) ;
126126 sw_pkgs . AutoFlush = true ;
127127
128128 // Collect all apps user owns.
@@ -143,11 +143,11 @@ static async Task<int> Main( string[] args )
143143
144144 sw_pkgs . Close ( ) ;
145145
146- StreamWriter sw_apps = new StreamWriter ( string . Format ( "{0}_apps.txt" , filenameUser ) ) ;
146+ StreamWriter sw_apps = new StreamWriter ( string . Format ( "{0}_apps.txt" , user ) ) ;
147147 sw_apps . AutoFlush = true ;
148- StreamWriter sw_keys = new StreamWriter ( string . Format ( "{0}_keys.txt" , filenameUser ) ) ;
148+ StreamWriter sw_keys = new StreamWriter ( string . Format ( "{0}_keys.txt" , user ) ) ;
149149 sw_keys . AutoFlush = true ;
150- StreamWriter sw_appnames = new StreamWriter ( string . Format ( "{0}_appnames.txt" , filenameUser ) ) ;
150+ StreamWriter sw_appnames = new StreamWriter ( string . Format ( "{0}_appnames.txt" , user ) ) ;
151151 sw_appnames . AutoFlush = true ;
152152
153153 await steam3 . RequestAppInfoList ( apps ) ;
@@ -168,8 +168,15 @@ static async Task<int> Main( string[] args )
168168 sw_appnames . Close ( ) ;
169169
170170 Console . WriteLine ( "\n === Summary ===" ) ;
171- Console . WriteLine ( "Dumped: {0} new depot keys" , dumpedCount ) ;
172- Console . WriteLine ( "Skipped: {0} depot keys (already in database)" , skippedCount ) ;
171+ if ( hasApiKey )
172+ {
173+ Console . WriteLine ( "Dumped: {0} new depot keys" , dumpedCount ) ;
174+ Console . WriteLine ( "Skipped: {0} depot keys (already in database)" , skippedCount ) ;
175+ }
176+ else
177+ {
178+ Console . WriteLine ( "Dumped: {0} depot keys" , dumpedCount ) ;
179+ }
173180 }
174181 else
175182 {
@@ -188,8 +195,15 @@ static async Task<int> Main( string[] args )
188195 sw_appnames . Close ( ) ;
189196
190197 Console . WriteLine ( "\n === Summary ===" ) ;
191- Console . WriteLine ( "Dumped: {0} new depot keys" , result . dumped ) ;
192- Console . WriteLine ( "Skipped: {0} depot keys (already in database)" , result . skipped ) ;
198+ if ( hasApiKey )
199+ {
200+ Console . WriteLine ( "Dumped: {0} new depot keys" , result . dumped ) ;
201+ Console . WriteLine ( "Skipped: {0} depot keys (already in database)" , result . skipped ) ;
202+ }
203+ else
204+ {
205+ Console . WriteLine ( "Dumped: {0} depot keys" , result . dumped ) ;
206+ }
193207 }
194208 }
195209
@@ -227,15 +241,15 @@ static async Task<HashSet<uint>> FetchExistingDepotIds( string apiKey )
227241 return null ;
228242 }
229243
230- Console . WriteLine ( "API: {0} existing in DB, {1} missing (as of {2 })" ,
231- apiResponse . existing_count , apiResponse . depot_ids , apiResponse . timestamp ) ;
244+ Console . WriteLine ( "API: {0} existing in DB (as of {1 })" ,
245+ apiResponse . existing_count , apiResponse . timestamp ) ;
232246
233247
234248 var existingIds = new HashSet < uint > ( ) ;
235249
236- if ( apiResponse . depot_ids != null )
250+ if ( apiResponse . existing_depot_ids != null )
237251 {
238- foreach ( var depotIdStr in apiResponse . depot_ids )
252+ foreach ( var depotIdStr in apiResponse . existing_depot_ids )
239253 {
240254 if ( uint . TryParse ( depotIdStr , out uint depotId ) )
241255 {
@@ -387,7 +401,6 @@ static async Task<HashSet<uint>> FetchExistingDepotIds( string apiKey )
387401 uint workshopDepotId = depotInfo [ "workshopdepot" ] . AsUnsignedInteger ( ) ;
388402 if ( workshopDepotId != 0 && ! depots . Contains ( workshopDepotId ) )
389403 {
390- // ПРОВЕРКА: Workshop depot УЖЕ ЕСТЬ в базе?
391404 if ( existingDepotIds != null && existingDepotIds . Contains ( workshopDepotId ) )
392405 {
393406 Console . WriteLine ( "Workshop depot {0} already exists in database, skipping" , workshopDepotId ) ;
@@ -405,7 +418,7 @@ static async Task<HashSet<uint>> FetchExistingDepotIds( string apiKey )
405418 sw_keys . WriteLine ( "{0};{1}" , workshopDepotId , string . Concat ( workshopKey . Select ( b => b . ToString ( "X2" ) ) . ToArray ( ) ) ) ;
406419 depots . Add ( workshopDepotId ) ;
407420 sw_appnames . WriteLine ( "\t {0} (workshop)" , workshopDepotId ) ;
408- Console . WriteLine ( "Dumped NEW workshop depot key for depot {0}" , workshopDepotId ) ;
421+ Console . WriteLine ( "Dumped workshop depot key for depot {0}" , workshopDepotId ) ;
409422 dumpedCount ++ ;
410423 }
411424 }
0 commit comments