Skip to content

Commit

Permalink
Twitch変換機能修正
Browse files Browse the repository at this point in the history
- TwitchDownloader 1.50.8以降のJSONフォーマットに対応
- Chat Downloader 0.2.3のjson/jsonlファイルを変換中エラーになるのを修正
  • Loading branch information
nnn-revo2012 committed Jan 18, 2023
1 parent fc6f794 commit 878e982
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
14 changes: 13 additions & 1 deletion comeconv/ConvTwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ private string ConvChatData(IDictionary<string, string> data, Props props)
}
}

private static Regex _RegLocations = new Regex("^(\\d+)\\-(\\d+)", RegexOptions.Compiled);
public bool TwitchConvertChatDownloader(string sfile, string dfile)
{
var enc = new System.Text.UTF8Encoding(false);
Expand Down Expand Up @@ -207,7 +208,18 @@ public bool TwitchConvertChatDownloader(string sfile, string dfile)
{
foreach (var emt in jo["emotes"])
{
message = message.Replace(emt["name"].ToString(), "");
string name = emt["name"].ToString();
if (string.IsNullOrEmpty(name))
{
var msg = jo["message"].ToString();
var loc = emt["locations"].ToString();
int start = Int32.Parse(_RegLocations.Match(loc).Groups[1].ToString());
int end = Int32.Parse(_RegLocations.Match(loc).Groups[2].ToString());
System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("UTF-8");
byte[] btBytes = hEncoding.GetBytes(msg);
name = hEncoding.GetString(btBytes, start, end-start+1);
}
message = message.Replace(name, "");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions comeconv/Prop/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace comeconv.Prop
{
public class Ver
{
public static readonly string Version = "0.0.1.19";
public static readonly string VerDate = "2022/12/10";
public static readonly string Version = "0.0.1.20";
public static readonly string VerDate = "2023/01/19";

public static string GetFullVersion()
{
Expand Down
2 changes: 1 addition & 1 deletion comeconv/Util/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static int IsTwitchFileType(string filename)
result = 0;
else if (RgxCDJson.IsMatch(str))
result = 1;
else if (str.StartsWith("{\"streamer\":{\"name\":"))
else if (str.StartsWith("{\"streamer\":{\"name\":")|| str.StartsWith("{\"FileInfo\":{\"Version\":"))
result = 5;
else
result = 10;
Expand Down

0 comments on commit 878e982

Please sign in to comment.