-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix incorrect percentages in chat updater * Make crop lock object not static * Update video info if possible when updating chats * Compress chat crop updater temp files with gzip * Fix ArgumentOutOfRangeException when loading information from chat files with less than 2 comments * Add functionality to deserialize only the first and last comments * Fix chapter updating
- Loading branch information
Showing
5 changed files
with
137 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
|
||
namespace TwitchDownloaderCore.Tools | ||
{ | ||
public static class JsonElementExtensions | ||
{ | ||
public static List<T> DeserializeFirstAndLastFromList<T>(this JsonElement arrayElement, JsonSerializerOptions options = null) | ||
{ | ||
// It's not the prettiest, but for arrays with thousands of objects it can save whole seconds and prevent tons of fragmented memory | ||
var list = new List<T>(2); | ||
JsonElement lastElement = default; | ||
foreach (var element in arrayElement.EnumerateArray()) | ||
{ | ||
if (list.Count == 0) | ||
{ | ||
list.Add(element.Deserialize<T>(options: options)); | ||
continue; | ||
} | ||
|
||
lastElement = element; | ||
} | ||
|
||
if (lastElement.ValueKind != JsonValueKind.Undefined) | ||
{ | ||
list.Add(lastElement.Deserialize<T>(options: options)); | ||
} | ||
|
||
return list; | ||
} | ||
} | ||
} |
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