-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add etag of included CardDefs.base.xml
- Loading branch information
Showing
6 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
HearthDb.CardDefsDownloader/HearthDb.CardDefsDownloader.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<LangVersion>8</LangVersion> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.IO; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
|
||
namespace HearthDb.CardDefsDownloader | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine(args[0]); | ||
var httpClient = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }); | ||
|
||
// CardDefs.base.xml contains non localized tags and enUS tag | ||
// Other languages can be found under e.g. CardDefs.deDE.xml | ||
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.hearthstonejson.com/v1/latest/CardDefs.base.xml"); | ||
request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip")); | ||
request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate")); | ||
|
||
var response = httpClient.SendAsync(request).Result; | ||
var data = response.Content.ReadAsStringAsync().Result; | ||
File.WriteAllText(Path.Combine(args[0], "CardDefs.base.xml"), data); | ||
|
||
var etag = response.Headers.ETag.Tag; | ||
var lastModified = response.Content.Headers.LastModified; | ||
File.WriteAllText(Path.Combine(args[0], "CardDefs.base.etag"), $"{etag}\n{lastModified.ToString()}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters