Skip to content

Commit

Permalink
Fix #726
Browse files Browse the repository at this point in the history
  • Loading branch information
lay295 committed Jun 1, 2023
1 parent 1932733 commit d96e941
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
21 changes: 12 additions & 9 deletions TwitchDownloaderCore/Chat/ChatJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,20 @@ private static async ValueTask UpgradeChatJson(ChatRoot chatRoot)
name = chatRoot.video.user_name ?? await TwitchHelper.GetStreamerName(int.Parse(chatRoot.video.user_id ?? chatRoot.comments.First().channel_id))
};

if (chatRoot.video.user_name is not null)
chatRoot.video.user_name = null;
if (chatRoot.video is not null)
{
if (chatRoot.video.user_name is not null)
chatRoot.video.user_name = null;

if (chatRoot.video.user_id is not null)
chatRoot.video.user_id = null;
if (chatRoot.video.user_id is not null)
chatRoot.video.user_id = null;

if (chatRoot.video.duration is not null)
{
chatRoot.video.length = TimeSpanExtensions.ParseTimeCode(chatRoot.video.duration).TotalSeconds;
chatRoot.video.end = chatRoot.video.length;
chatRoot.video.duration = null;
if (chatRoot.video.duration is not null)
{
chatRoot.video.length = TimeSpanExtensions.ParseTimeCode(chatRoot.video.duration).TotalSeconds;
chatRoot.video.end = chatRoot.video.length;
chatRoot.video.duration = null;
}
}
}

Expand Down
16 changes: 10 additions & 6 deletions TwitchDownloaderCore/TwitchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,19 +484,23 @@ public static async Task<List<TwitchEmote>> GetEmotes(List<Comment> comments, st
var nameList = comments.Where(comment => comment.message.user_badges != null)
.SelectMany(comment => comment.message.user_badges)
.Where(badge => !String.IsNullOrWhiteSpace(badge._id))
.Where(badge => globalBadges.ContainsKey(badge._id) || subBadges.ContainsKey(badge._id))
.Select(badge => badge._id).Distinct();

foreach (var name in nameList)
{
Dictionary<string, ChatBadgeData> versions = new();
foreach (var badge in globalBadges[name])
if (globalBadges.TryGetValue(name, out var globalBadge))
{
versions.Add(badge.version, new()
foreach (var badge in globalBadge)
{
title = badge.title,
description = badge.description,
url = badge.image_url_2x
});
versions[badge.version] = new()
{
title = badge.title,
description = badge.description,
url = badge.image_url_2x
};
}
}

//Prefer channel specific badges over global ones
Expand Down

0 comments on commit d96e941

Please sign in to comment.