Drunk programming isn't necessarily a good idea
This commit is contained in:
parent
854e02dd0d
commit
4eec201547
2 changed files with 7 additions and 15 deletions
|
@ -240,7 +240,7 @@ You may also want to verify the game's files by right clicking the game in Steam
|
|||
private async void refreshbtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
CheckIfPatched(); //Set from placeholder
|
||||
lastGameUpdateTime = GetLastGameUpdateTime();
|
||||
lastGameUpdateTime = await GetLastGameUpdateTime();
|
||||
var mods = GetInstalledMods();
|
||||
await GetAvailableMods();
|
||||
CheckUninstalledMods(mods);
|
||||
|
|
|
@ -161,25 +161,17 @@ namespace GCMM
|
|||
return false;
|
||||
}
|
||||
|
||||
public DateTime GetLastGameUpdateTime()
|
||||
public async Task<DateTime> GetLastGameUpdateTime()
|
||||
{
|
||||
if (GetExe() == null)
|
||||
return default;
|
||||
foreach (var line in File.ReadAllLines(GamePath(@"\..\..\appmanifest_1078000.acf")))
|
||||
using (var client = GetClient())
|
||||
{
|
||||
var regex = new Regex("\\t\"LastUpdated\"\\t\\t\"(\\d+)\"");
|
||||
var match = regex.Match(line);
|
||||
string html = await client.DownloadStringTaskAsync("https://steamdb.info/app/1078000/depots/?branch=public");
|
||||
var regex = new Regex("<i>timeupdated:</i>[^<]*<b>([^<]*)</b>");
|
||||
var match = regex.Match(html);
|
||||
if (!match.Success)
|
||||
continue;
|
||||
string updated = match.Groups[1].Value;
|
||||
if (string.IsNullOrWhiteSpace(updated))
|
||||
return default;
|
||||
var updatedTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
updatedTime = updatedTime.AddSeconds(double.Parse(updated)).ToLocalTime();
|
||||
return updatedTime;
|
||||
|
||||
}
|
||||
return default;
|
||||
return new DateTime(1970, 1, 1).AddSeconds(long.Parse(match.Groups[1].Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue