public static void DownloadApp(uint appId, uint depotId, string branch, bool forceDepot = false) { if (steam3 != null) { steam3.RequestAppInfo(appId); } if (!AccountHasAccess(appId)) { if (steam3.RequestFreeAppLicense(appId)) { Console.WriteLine("Obtained FreeOnDemand license for app {0}", appId); } else { string contentName = GetAppOrDepotName(INVALID_DEPOT_ID, appId); Console.WriteLine("App {0} ({1}) is not available from this account.", appId, contentName); return; } } Console.WriteLine("Using app branch: '{0}'.", branch); var depotIDs = new List <uint>(); KeyValue depots = GetSteam3AppSection(appId, EAppInfoSection.Depots); if (forceDepot) { depotIDs.Add(depotId); } else { if (depots != null) { foreach (var depotSection in depots.Children) { uint id = INVALID_DEPOT_ID; if (depotSection.Children.Count == 0) { continue; } if (!uint.TryParse(depotSection.Name, out id)) { continue; } if (depotId != INVALID_DEPOT_ID && id != depotId) { continue; } if (!Config.DownloadAllPlatforms) { var depotConfig = depotSection["config"]; if (depotConfig != KeyValue.Invalid && depotConfig["oslist"] != KeyValue.Invalid && !string.IsNullOrWhiteSpace(depotConfig["oslist"].Value)) { var oslist = depotConfig["oslist"].Value.Split(','); if (Array.IndexOf(oslist, Util.GetSteamOS()) == -1) { continue; } } } depotIDs.Add(id); } } if (depotIDs == null || (depotIDs.Count == 0 && depotId == INVALID_DEPOT_ID)) { Console.WriteLine("Couldn't find any depots to download for app {0}", appId); return; } else if (depotIDs.Count == 0) { Console.Write("Depot {0} not listed for app {1}", depotId, appId); if (!Config.DownloadAllPlatforms) { Console.Write(" or not available on this platform"); } Console.WriteLine(); return; } } var infos = new List <DepotDownloadInfo>(); foreach (var depot in depotIDs) { DepotDownloadInfo info = GetDepotInfo(depot, appId, branch); if (info != null) { infos.Add(info); } } try { DownloadSteam3(appId, infos); } catch (OperationCanceledException) { Console.WriteLine("App {0} was not completely downloaded.", appId); } }
public static async Task DownloadAppAsync(uint appId, uint depotId, ulong manifestId, string branch, string os, string arch, string language, bool lv, bool isUgc) { // Load our configuration data containing the depots currently installed string configPath = ContentDownloader.Config.InstallDirectory; if (string.IsNullOrWhiteSpace(configPath)) { configPath = DEFAULT_DOWNLOAD_DIR; } Directory.CreateDirectory(Path.Combine(configPath, CONFIG_DIR)); DepotConfigStore.LoadFromFile(Path.Combine(configPath, CONFIG_DIR, "depot.config")); if (steam3 != null) { steam3.RequestAppInfo(appId); } if (!AccountHasAccess(appId)) { if (steam3.RequestFreeAppLicense(appId)) { Console.WriteLine("Obtained FreeOnDemand license for app {0}", appId); } else { string contentName = GetAppOrDepotName(INVALID_DEPOT_ID, appId); throw new ContentDownloaderException(String.Format("App {0} ({1}) is not available from this account.", appId, contentName)); } } var depotIDs = new List <uint>(); KeyValue depots = GetSteam3AppSection(appId, EAppInfoSection.Depots); if (isUgc) { var workshopDepot = depots["workshopdepot"].AsUnsignedInteger(); if (workshopDepot != 0) { depotId = workshopDepot; } depotIDs.Add(depotId); } else { Console.WriteLine("Using app branch: '{0}'.", branch); if (depots != null) { foreach (var depotSection in depots.Children) { uint id = INVALID_DEPOT_ID; if (depotSection.Children.Count == 0) { continue; } if (!uint.TryParse(depotSection.Name, out id)) { continue; } if (depotId != INVALID_DEPOT_ID && id != depotId) { continue; } if (depotId == INVALID_DEPOT_ID) { var depotConfig = depotSection["config"]; if (depotConfig != KeyValue.Invalid) { if (!Config.DownloadAllPlatforms && depotConfig["oslist"] != KeyValue.Invalid && !string.IsNullOrWhiteSpace(depotConfig["oslist"].Value)) { var oslist = depotConfig["oslist"].Value.Split(','); if (Array.IndexOf(oslist, os ?? Util.GetSteamOS()) == -1) { continue; } } if (depotConfig["osarch"] != KeyValue.Invalid && !string.IsNullOrWhiteSpace(depotConfig["osarch"].Value)) { var depotArch = depotConfig["osarch"].Value; if (depotArch != (arch ?? Util.GetSteamArch())) { continue; } } if (!Config.DownloadAllLanguages && depotConfig["language"] != KeyValue.Invalid && !string.IsNullOrWhiteSpace(depotConfig["language"].Value)) { var depotLang = depotConfig["language"].Value; if (depotLang != (language ?? "english")) { continue; } } if (!lv && depotConfig["lowviolence"] != KeyValue.Invalid && depotConfig["lowviolence"].AsBoolean()) { continue; } } } depotIDs.Add(id); } } if (depotIDs == null || (depotIDs.Count == 0 && depotId == INVALID_DEPOT_ID)) { throw new ContentDownloaderException(String.Format("Couldn't find any depots to download for app {0}", appId)); } else if (depotIDs.Count == 0) { throw new ContentDownloaderException(String.Format("Depot {0} not listed for app {1}", depotId, appId)); } } var infos = new List <DepotDownloadInfo>(); foreach (var depot in depotIDs) { var info = GetDepotInfo(depot, appId, manifestId, branch); if (info != null) { infos.Add(info); } } try { await DownloadSteam3Async(appId, infos).ConfigureAwait(false); } catch (OperationCanceledException) { Console.WriteLine("App {0} was not completely downloaded.", appId); throw; } }
public static async Task DownloadAppAsync(uint appId, uint depotId, ulong manifestId, string branch, string os, bool isUgc) { if (steam3 != null) { steam3.RequestAppInfo(appId); } if (!AccountHasAccess(appId)) { if (steam3.RequestFreeAppLicense(appId)) { Console.WriteLine("Obtained FreeOnDemand license for app {0}", appId); } else { string contentName = GetAppOrDepotName(INVALID_DEPOT_ID, appId); throw new ContentDownloaderException(String.Format("App {0} ({1}) is not available from this account.", appId, contentName)); } } var depotIDs = new List <uint>(); KeyValue depots = GetSteam3AppSection(appId, EAppInfoSection.Depots); if (isUgc) { var workshopDepot = depots["workshopdepot"].AsUnsignedInteger(); if (workshopDepot != 0) { depotId = workshopDepot; } depotIDs.Add(depotId); } else { Console.WriteLine("Using app branch: '{0}'.", branch); if (depots != null) { foreach (var depotSection in depots.Children) { uint id = INVALID_DEPOT_ID; if (depotSection.Children.Count == 0) { continue; } if (!uint.TryParse(depotSection.Name, out id)) { continue; } if (depotId != INVALID_DEPOT_ID && id != depotId) { continue; } if (depotId == INVALID_DEPOT_ID && !Config.DownloadAllPlatforms) { var depotConfig = depotSection["config"]; if (depotConfig != KeyValue.Invalid && depotConfig["oslist"] != KeyValue.Invalid && !string.IsNullOrWhiteSpace(depotConfig["oslist"].Value)) { var oslist = depotConfig["oslist"].Value.Split(','); if (Array.IndexOf(oslist, os ?? Util.GetSteamOS()) == -1) { continue; } } } depotIDs.Add(id); } } if (depotIDs == null || (depotIDs.Count == 0 && depotId == INVALID_DEPOT_ID)) { throw new ContentDownloaderException(String.Format("Couldn't find any depots to download for app {0}", appId)); } else if (depotIDs.Count == 0) { throw new ContentDownloaderException(String.Format("Depot {0} not listed for app {1}", depotId, appId)); } } var infos = new List <DepotDownloadInfo>(); foreach (var depot in depotIDs) { var info = GetDepotInfo(depot, appId, manifestId, branch); if (info != null) { infos.Add(info); } } try { await DownloadSteam3Async(appId, infos).ConfigureAwait(false); } catch (OperationCanceledException) { Console.WriteLine("App {0} was not completely downloaded.", appId); throw; } }
public static async Task DownloadAppAsync(Steam3Session steam3, uint appId, uint depotId, ulong manifestId, string branch, string os, bool isUgc, Action downloadCompleteAction = null) { if (steam3 != null) { await steam3.RequestAppInfo(appId); } bool hasAccess = await AccountHasAccess(steam3, appId); if (!hasAccess) { bool freeAppLicense = await steam3.RequestFreeAppLicense(appId); if (freeAppLicense) { DebugLog.WriteLine("ContentDownloader", "Obtained FreeOnDemand license for app " + appId); } else { string contentName = GetAppOrDepotName(steam3, INVALID_DEPOT_ID, appId); DebugLog.WriteLine("ContentDownloader", "App " + appId + " (" + contentName + ") is not available from this account."); return; } } var depotIDs = new List <uint>(); KeyValue depots = GetSteam3AppSection(steam3, appId, EAppInfoSection.Depots); if (isUgc) { var workshopDepot = depots["workshopdepot"].AsUnsignedInteger(); if (workshopDepot != 0) { depotId = workshopDepot; } depotIDs.Add(depotId); } else { DebugLog.WriteLine("ContentDownloader", "Using app branch: '" + branch + "'."); if (depots != null) { foreach (var depotSection in depots.Children) { uint id = INVALID_DEPOT_ID; if (depotSection.Children.Count == 0) { continue; } if (!uint.TryParse(depotSection.Name, out id)) { continue; } if (depotId != INVALID_DEPOT_ID && id != depotId) { continue; } if (depotId == INVALID_DEPOT_ID && !Config.DownloadAllPlatforms) { var depotConfig = depotSection["config"]; if (depotConfig != KeyValue.Invalid && depotConfig["oslist"] != KeyValue.Invalid && !string.IsNullOrWhiteSpace(depotConfig["oslist"].Value)) { var oslist = depotConfig["oslist"].Value.Split(','); if (Array.IndexOf(oslist, os ?? Util.GetSteamOS()) == -1) { continue; } } } depotIDs.Add(id); } } if (depotIDs == null || (depotIDs.Count == 0 && depotId == INVALID_DEPOT_ID)) { DebugLog.WriteLine("ContentDownloader", "Couldn't find any depots to download for app " + appId); return; } else if (depotIDs.Count == 0) { DebugLog.WriteLine("ContentDownloader", "Depot " + depotId + " not listed for app " + appId); return; } } var infos = new List <DepotDownloadInfo>(); foreach (var depot in depotIDs) { var info = await GetDepotInfo(steam3, depot, appId, manifestId, branch); if (info != null) { infos.Add(info); } } try { IsDownloading = true; await DownloadSteam3Async(appId, infos, downloadCompleteAction); } catch (OperationCanceledException) { DebugLog.WriteLine("ContentDownloader", "App " + appId + " was not completely downloaded."); } finally { DebugLog.WriteLine("ContentDownloader", "Download completed"); } }
public static async Task DownloadAppAsync( ) { if (steam3 != null) { steam3.RequestAppInfo(Config.AppID); } if (!AccountHasAccess(Config.AppID)) { if (steam3.RequestFreeAppLicense(Config.AppID)) { Logger.Error("Obtained FreeOnDemand license for app {0}", Config.AppID); } else { string contentName = GetAppOrDepotName(INVALID_DEPOT_ID, Config.AppID); Logger.Error("App {0} ({1}) is not available from this account.", Config.AppID, contentName); return; } } Logger.Info("Using app branch: '{0}'.", Config.Branch); var depotIDs = new List <uint>(); KeyValue depots = GetSteam3AppSection(Config.AppID, EAppInfoSection.Depots); if (Config.ForceDepot) { depotIDs.Add(Config.DepotID); } else { if (depots != null) { foreach (var depotSection in depots.Children) { uint id = INVALID_DEPOT_ID; if (depotSection.Children.Count == 0) { continue; } if (!uint.TryParse(depotSection.Name, out id)) { continue; } if (Config.DepotID != INVALID_DEPOT_ID && id != Config.DepotID) { continue; } if (!Config.DownloadAllPlatforms) { var depotConfig = depotSection["config"]; if (depotConfig != KeyValue.Invalid && depotConfig["oslist"] != KeyValue.Invalid && !string.IsNullOrWhiteSpace(depotConfig["oslist"].Value)) { var oslist = depotConfig["oslist"].Value.Split(','); if (Array.IndexOf(oslist, Config.OS ?? Util.GetSteamOS()) == -1) { continue; } } } depotIDs.Add(id); } } if (depotIDs.Count == 0 && Config.DepotID == INVALID_DEPOT_ID) { Logger.Error("Couldn't find any depots to download for app {0}", Config.AppID); return; } else if (depotIDs.Count == 0) { var msg = $"Depot {Config.DepotID} not listed for app {Config.AppID}"; if (!Config.DownloadAllPlatforms) { msg += " or not available on this platform"; } Logger.Error(msg); return; } } var infos = new List <DepotDownloadInfo>(); foreach (var depot in depotIDs) { var info = GetDepotInfo(depot, Config.AppID, Config.Branch); if (info != null) { infos.Add(info); } } try { await DownloadSteam3Async(Config.AppID, infos).ConfigureAwait(false); } catch (OperationCanceledException) { Logger.Error("App {0} was not completely downloaded.", Config.AppID); } }