mirror of
https://github.com/SteamRE/DepotDownloader.git
synced 2026-10-19 15:51:50 +00:00
Allow multiple depot ids to be specified. Resolves #147
This commit is contained in:
1 parent
cda5eb5137
commit
079f91167f
2 files changed
+75
-21
No files matched your search
@@ -386,7 +386,7 @@ namespace DepotDownloader
|
||||
|
||||
if ( details?.manifest_id > 0 )
|
||||
{
|
||||
await DownloadAppAsync( appId, appId, details.manifest_id, DEFAULT_BRANCH, null, null, null, false, true );
|
||||
await DownloadAppAsync( appId, new List<Tuple<uint, ulong>>() { Tuple.Create( appId, details.manifest_id ) }, DEFAULT_BRANCH, null, null, null, false, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -394,7 +394,7 @@ namespace DepotDownloader
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task DownloadAppAsync( uint appId, uint depotId, ulong manifestId, string branch, string os, string arch, string language, bool lv, bool isUgc )
|
||||
public static async Task DownloadAppAsync( uint appId, List<Tuple<uint, ulong>> depotManifestIds, string branch, string os, string arch, string language, bool lv, bool isUgc )
|
||||
{
|
||||
cdnPool = new CDNClientPool(steam3, appId);
|
||||
|
||||
@@ -427,16 +427,21 @@ namespace DepotDownloader
|
||||
}
|
||||
}
|
||||
|
||||
var depotIDs = new List<uint>();
|
||||
var hasSpecificDepots = depotManifestIds.Count > 0;
|
||||
var depotIdsFound = new List<uint>();
|
||||
var depotIdsExpected = depotManifestIds.Select( x => x.Item1 ).ToList();
|
||||
KeyValue depots = GetSteam3AppSection( appId, EAppInfoSection.Depots );
|
||||
|
||||
if ( isUgc )
|
||||
{
|
||||
var workshopDepot = depots["workshopdepot"].AsUnsignedInteger();
|
||||
if (workshopDepot != 0)
|
||||
depotId = workshopDepot;
|
||||
if ( workshopDepot != 0 && !depotIdsExpected.Contains( workshopDepot ) )
|
||||
{
|
||||
depotIdsExpected.Add( workshopDepot );
|
||||
depotManifestIds = depotManifestIds.Select( pair => Tuple.Create( workshopDepot, pair.Item2 ) ).ToList();
|
||||
}
|
||||
|
||||
depotIDs.Add( depotId );
|
||||
depotIdsFound.AddRange( depotIdsExpected );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -453,10 +458,10 @@ namespace DepotDownloader
|
||||
if ( !uint.TryParse( depotSection.Name, out id ) )
|
||||
continue;
|
||||
|
||||
if ( depotId != INVALID_DEPOT_ID && id != depotId )
|
||||
if ( hasSpecificDepots && !depotIdsExpected.Contains( id ) )
|
||||
continue;
|
||||
|
||||
if ( depotId == INVALID_DEPOT_ID )
|
||||
if ( !hasSpecificDepots )
|
||||
{
|
||||
var depotConfig = depotSection[ "config" ];
|
||||
if ( depotConfig != KeyValue.Invalid )
|
||||
@@ -494,24 +499,28 @@ namespace DepotDownloader
|
||||
}
|
||||
}
|
||||
|
||||
depotIDs.Add( id );
|
||||
depotIdsFound.Add( id );
|
||||
|
||||
if ( !hasSpecificDepots )
|
||||
depotManifestIds.Add( Tuple.Create( id, ContentDownloader.INVALID_MANIFEST_ID ) );
|
||||
}
|
||||
}
|
||||
if ( depotIDs == null || ( depotIDs.Count == 0 && depotId == INVALID_DEPOT_ID ) )
|
||||
if ( depotManifestIds.Count == 0 && !hasSpecificDepots )
|
||||
{
|
||||
throw new ContentDownloaderException( String.Format( "Couldn't find any depots to download for app {0}", appId ) );
|
||||
}
|
||||
else if ( depotIDs.Count == 0 )
|
||||
else if ( depotIdsFound.Count < depotIdsExpected.Count )
|
||||
{
|
||||
throw new ContentDownloaderException( String.Format( "Depot {0} not listed for app {1}", depotId, appId ) );
|
||||
var remainingDepotIds = depotIdsExpected.Except( depotIdsFound );
|
||||
throw new ContentDownloaderException( String.Format( "Depot {0} not listed for app {1}", string.Join(", ", remainingDepotIds), appId ) );
|
||||
}
|
||||
}
|
||||
|
||||
var infos = new List<DepotDownloadInfo>();
|
||||
|
||||
foreach ( var depot in depotIDs )
|
||||
foreach ( var depotManifest in depotManifestIds )
|
||||
{
|
||||
var info = GetDepotInfo( depot, appId, manifestId, branch );
|
||||
var info = GetDepotInfo( depotManifest.Item1, appId, depotManifest.Item2, branch );
|
||||
if ( info != null )
|
||||
{
|
||||
infos.Add( info );
|
||||
@@ -783,6 +792,11 @@ namespace DepotDownloader
|
||||
Console.WriteLine("Encountered 401 for depot manifest {0} {1}. Aborting.", depot.id, depot.manifestId);
|
||||
break;
|
||||
}
|
||||
else if (e.StatusCode == HttpStatusCode.NotFound)
|
||||
{
|
||||
Console.WriteLine("Encountered 404 for depot manifest {0} {1}. Aborting.", depot.id, depot.manifestId);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Encountered error downloading depot manifest {0} {1}: {2}", depot.id, depot.manifestId, e.StatusCode);
|
||||
|
||||
@@ -6,6 +6,8 @@ using SteamKit2;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Linq;
|
||||
|
||||
namespace DepotDownloader
|
||||
{
|
||||
class Program
|
||||
@@ -186,23 +188,33 @@ namespace DepotDownloader
|
||||
|
||||
bool lv = HasParameter( args, "-lowviolence" );
|
||||
|
||||
uint depotId;
|
||||
List<uint> depotIdList;
|
||||
List<Tuple<uint, ulong>> depotManifestIds = new List<Tuple<uint, ulong>>();
|
||||
bool isUGC = false;
|
||||
|
||||
ulong manifestId = GetParameter<ulong>( args, "-ugc", ContentDownloader.INVALID_MANIFEST_ID );
|
||||
if ( manifestId != ContentDownloader.INVALID_MANIFEST_ID )
|
||||
{
|
||||
depotId = appId;
|
||||
depotManifestIds.Add( Tuple.Create( appId, manifestId ) );
|
||||
isUGC = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
depotId = GetParameter<uint>( args, "-depot", ContentDownloader.INVALID_DEPOT_ID );
|
||||
depotIdList = GetParameterList<uint>( args, "-depot" );
|
||||
manifestId = GetParameter<ulong>( args, "-manifest", ContentDownloader.INVALID_MANIFEST_ID );
|
||||
if ( depotId == ContentDownloader.INVALID_DEPOT_ID && manifestId != ContentDownloader.INVALID_MANIFEST_ID )
|
||||
if ( manifestId != ContentDownloader.INVALID_MANIFEST_ID )
|
||||
{
|
||||
Console.WriteLine( "Error: -manifest requires -depot to be specified" );
|
||||
return 1;
|
||||
if ( depotIdList.Count != 1 )
|
||||
{
|
||||
Console.WriteLine( "Error: -manifest requires one -depot to be specified" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
depotManifestIds.Add( Tuple.Create( depotIdList[0], manifestId ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
depotManifestIds.AddRange( depotIdList.Select( depotId => Tuple.Create( depotId, ContentDownloader.INVALID_MANIFEST_ID ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +222,7 @@ namespace DepotDownloader
|
||||
{
|
||||
try
|
||||
{
|
||||
await ContentDownloader.DownloadAppAsync( appId, depotId, manifestId, branch, os, arch, language, lv, isUGC ).ConfigureAwait( false );
|
||||
await ContentDownloader.DownloadAppAsync( appId, depotManifestIds, branch, os, arch, language, lv, isUGC ).ConfigureAwait( false );
|
||||
}
|
||||
catch ( Exception ex ) when (
|
||||
ex is ContentDownloaderException
|
||||
@@ -303,6 +315,34 @@ namespace DepotDownloader
|
||||
return default( T );
|
||||
}
|
||||
|
||||
static List<T> GetParameterList<T>(string[] args, string param)
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
int index = IndexOfParam(args, param);
|
||||
|
||||
if (index == -1 || index == (args.Length - 1))
|
||||
return list;
|
||||
|
||||
index++;
|
||||
|
||||
while (index < args.Length)
|
||||
{
|
||||
string strParam = args[index];
|
||||
|
||||
if (strParam[0] == '-') break;
|
||||
|
||||
var converter = TypeDescriptor.GetConverter(typeof(T));
|
||||
if (converter != null)
|
||||
{
|
||||
list.Add((T)converter.ConvertFromString(strParam));
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void PrintUsage()
|
||||
{
|
||||
Console.WriteLine();
|
||||
|
||||
Reference in new issue
Block a user