11using System ;
22using System . Collections . Generic ;
33using System . IO ;
4+ using System . Linq ;
45using System . Threading ;
56using System . Xml . Linq ;
67
@@ -16,40 +17,36 @@ public Sporecast(long id)
1617 }
1718
1819 /// <summary>
19- /// Gets a collection of IDs for all of this sporecast's assets. Maximum speed of 500 creations per second, to reduce impact on the server.
20+ /// Gets a collection of IDs for all of this sporecast's assets.
2021 /// </summary>
2122 public Queue < long > getAllAssetIds ( )
2223 {
2324 var server = new SporeServer ( ) ;
2425
2526 var assetIds = new Queue < long > ( ) ;
2627
27- for ( int i = 0 ; ; i += 500 )
28- {
29- var doc = server . getAssetsForSporecast ( Id , i , 500 ) . Element ( "assets" ) ;
3028
31- if ( doc is null )
32- {
33- break ;
34- }
29+ var doc = server . getSporecastFeed ( Id ) . Element ( "{http://www.w3.org/2005/Atom}feed" ) ; //.Elements().FirstOrDefault()?.Elements().FirstOrDefault();
30+ Console . WriteLine ( doc ? . ToString ( ) ) ;
3531
36- foreach ( var asset in doc . Elements ( "asset" ) )
32+ if ( doc is not null )
33+ {
34+ foreach ( var asset in doc . Elements ( "{http://www.w3.org/2005/Atom}entry" ) )
3735 {
38- long assetId = long . Parse ( asset . Element ( "id" ) ! . Value ) ;
36+ string entryId = asset . Element ( "{http://www.w3.org/2005/Atom}id" ) ! . Value ;
37+ long assetId = long . Parse ( entryId . Split ( '/' ) [ 1 ] ) ;
3938
4039 assetIds . Enqueue ( assetId ) ;
4140
4241 Console . WriteLine ( $ "Found asset ID { assetId } for sporecast { Id } ") ;
4342 }
44-
45- // Check if the number of retrieved creations is less than 500, if it is, exit loop
46- int retrievedCount = int . Parse ( doc . Element ( "count" ) ! . Value ) ;
47- if ( retrievedCount < 500 ) break ;
48- // Pause for a second, so we don't upset the server
49- else Thread . Sleep ( 1000 ) ;
43+ Console . WriteLine ( $ "Found { assetIds . Count } assets for sporecast { Id } ") ;
44+ }
45+ else
46+ {
47+ Console . WriteLine ( $ "Found no assets for sporecast { Id } , feed did not exist") ;
5048 }
5149
52- Console . WriteLine ( $ "Found { assetIds . Count } assets for sporecast { Id } ") ;
5350
5451 return assetIds ;
5552 }
0 commit comments