Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added gzip compression support #10

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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