Skip to content

Commit

Permalink
Merge pull request #10 from halsafar/feature/gzip
Browse files Browse the repository at this point in the history
Added gzip compression support
  • Loading branch information
halsafar authored Jul 12, 2021
2 parents 71a926f + 521bef6 commit 0c7b3d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion SongDataCore/BeatStar/BeatStarDataFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;

namespace SongDataCore.BeatStar
{
Expand All @@ -18,7 +20,14 @@ public BeatStarDataFile(byte[] data)

try
{
string result = System.Text.Encoding.UTF8.GetString(data);
string result;
using (var compressedStream = new MemoryStream(data))
using (var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
using (var resultStream = new MemoryStream())
{
zipStream.CopyTo(resultStream);
result = System.Text.Encoding.UTF8.GetString(resultStream.ToArray());
}

var tmpSongs = JsonConvert.DeserializeObject<Dictionary<string, BeatStarSong>>(result);
Songs = new Dictionary<string, BeatStarSong>(tmpSongs, StringComparer.OrdinalIgnoreCase);
Expand Down
2 changes: 1 addition & 1 deletion SongDataCore/BeatStar/BeatStarDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SongDataCore.BeatStar
{
public class BeatStarDatabase : DatabaseDownloader, IDatabaseDownloadHandler
{
public const String SCRAPED_SCORE_SABER_ALL_JSON_URL = "https://cdn.wes.cloud/beatstar/bssb/v2-all.json";
public const String SCRAPED_SCORE_SABER_ALL_JSON_URL = "https://cdn.wes.cloud/beatstar/bssb/v2-all.json.gz";

public BeatStarDataFile Data = null;

Expand Down
2 changes: 1 addition & 1 deletion SongDataCore/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace SongDataCore
[Plugin(RuntimeOptions.SingleStartInit)]
public class Plugin
{
public const string VERSION_NUMBER = "1.3.8";
public const string VERSION_NUMBER = "1.4.0";
public static Plugin Instance;
public static IPA.Logging.Logger Log;

Expand Down

0 comments on commit 0c7b3d9

Please sign in to comment.