Try to get DLC name if missing and not using SteamDB

This commit is contained in:
Jeddunk 2021-01-05 12:30:34 +01:00
parent 1d69b7b45a
commit 8a4e601236
2 changed files with 61 additions and 62 deletions

View File

@ -111,31 +111,31 @@ namespace auto_creamapi.Services
MyLogger.Log.Debug($"Type for Steam App {steamApp.Name}: \"{steamAppDetails.Type}\"");
if (steamAppDetails.Type == "game" | steamAppDetails.Type == "demo")
{
steamAppDetails?.DLC.ForEach(x =>
steamAppDetails.DLC.ForEach(x =>
{
var result = _cache.FirstOrDefault(y => y.AppId.Equals(x)) ??
new SteamApp {AppId = x, Name = $"Unknown DLC {x}"};
var result = _cache.FirstOrDefault(y => y.AppId.Equals(x));
if (result == null)
{
var dlcDetails = AppDetails.GetAsync(x).Result;
result = dlcDetails != null
? new SteamApp { AppId = dlcDetails.SteamAppId, Name = dlcDetails.Name }
: new SteamApp { AppId = x, Name = $"Unknown DLC {x}" };
}
dlcList.Add(result);
});
dlcList.ForEach(x => MyLogger.Log.Debug($"{x.AppId}={x.Name}"));
MyLogger.Log.Information("Got DLC successfully...");
if (!useSteamDb) return dlcList;
// Get DLC from SteamDB
// Get Cloudflare cookie
// Scrape and parse HTML page
// Add missing to DLC list
if (useSteamDb)
{
var steamDbUri = new Uri($"https://steamdb.info/app/{steamApp.AppId}/dlc/");
/* var handler = new ClearanceHandler();
var client = new HttpClient(handler);
var content = client.GetStringAsync(steamDbUri).Result;
MyLogger.Log.Debug(content); */
var client = new HttpClient();
client.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
@ -182,7 +182,6 @@ namespace auto_creamapi.Services
}
}
}
dlcList.ForEach(x => MyLogger.Log.Debug($"{x.AppId}={x.Name}"));
MyLogger.Log.Information("Got DLC from SteamDB successfully...");
}
@ -191,7 +190,6 @@ namespace auto_creamapi.Services
MyLogger.Log.Error("Could not get DLC from SteamDB!");
}
}
}
else
{
MyLogger.Log.Error("Could not get DLC: Steam App is not of type: \"Game\"");

View File

@ -10,7 +10,8 @@
xmlns:vm="clr-namespace:auto_creamapi.ViewModels"
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
xmlns:converters="clr-namespace:auto_creamapi.Converters"
mc:Ignorable="d">
mc:Ignorable="d"
d:DesignHeight="720" d:DesignWidth="560">
<views:MvxWpfView.Resources>
<converters:ListOfDLcToStringNativeConverter x:Key="DlcConv" />
</views:MvxWpfView.Resources>
@ -27,7 +28,7 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<wcl:WatermarkTextBox Text="{Binding DllPath}" Watermark="Path to game's steam_api(64).dll..."
Margin="10,11,55,0" TextWrapping="NoWrap" VerticalAlignment="Top" Padding="0"
Margin="10,10,55,0" TextWrapping="NoWrap" VerticalAlignment="Top" Padding="0"
Grid.Row="0" IsReadOnly="True" IsReadOnlyCaretVisible="True">
<!--MouseDoubleClick="{Binding Path=OpenFileCommand}"-->
<wcl:WatermarkTextBox.InputBindings>
@ -95,7 +96,7 @@
Text="{Binding Dlcs, Converter={StaticResource DlcConv}, Mode=TwoWay}"
Margin="10,10,10,0" Watermark="List of DLCs...&#xA;0000 = DLC Name"
TextWrapping="Wrap" AcceptsReturn="True"
VerticalScrollBarVisibility="Visible" Padding="0"
VerticalScrollBarVisibility="Visible" Padding="5,5,5,5"
FontFamily="../resources/#Courier Prime" Grid.Row="3" />
<Button Content="Get DLCs for AppID" Margin="0,10,10,10" Height="19.96" HorizontalAlignment="Right"
VerticalAlignment="Bottom" Width="108" Command="{Binding GetListOfDlcCommand}" Grid.Row="4" />