lay295 / TwitchDownloader

Twitch VOD/Clip Downloader - Chat Download/Render/Replay
MIT License
2.78k stars 261 forks source link

Chat downloads fail (emoticon id is null) #1254

Closed AdmiralCurtiss closed 2 weeks ago

AdmiralCurtiss commented 2 weeks ago

Checklist

Edition

Command Line Interface

Describe your issue here

Command line arguments:

chatdownload -E --chat-connections 1 --id 2300936847 -o test.json

Output with somewhat useless stack trace:

[WARNING] --chat-connections has been deprecated in favor of -t / --threads and may be removed. Run 'TwitchDownloaderCLI.exe help' for more information.
TwitchDownloaderCLI 1.55.0 Copyright (c) lay295 and contributors
[STATUS] - Downloading 100%
[STATUS] - Downloading Embed Images 25%Unhandled exception. System.AggregateException: One or more errors occurred. (A task was canceled.)
 ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at System.Threading.Tasks.Task.GetExceptions(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at TwitchDownloaderCLI.Modes.DownloadChat.Download(ChatDownloadArgs inputOptions) in TwitchDownloader\TwitchDownloaderCLI\Modes\DownloadChat.cs:line 23
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at TwitchDownloaderCLI.Program.Main(String[] args) in TwitchDownloader\TwitchDownloaderCLI\Program.cs:line 34
--- End of stack trace from previous location ---

   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at TwitchDownloaderCLI.Modes.DownloadChat.Download(ChatDownloadArgs inputOptions) in TwitchDownloader\TwitchDownloaderCLI\Modes\DownloadChat.cs:line 23
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at TwitchDownloaderCLI.Program.Main(String[] args) in TwitchDownloader\TwitchDownloaderCLI\Program.cs:line 34

TwitchDownloader\TwitchDownloaderCLI\bin\Release\net6.0\TwitchDownloaderCLI.exe (process 8564) exited with code 0.

Actual stack:

[Async] Task (System.Net.Http.HttpConnection) [Promise]
[Async] System.Threading.Tasks.TaskCompletionSourceWithCancellation<System.Net.Http.HttpConnection>.WaitWithCancellationAsync(System.Threading.CancellationToken)
[Async] System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(System.Net.Http.HttpRequestMessage, bool, System.Threading.CancellationToken)
[Async] System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(System.Net.Http.HttpRequestMessage, bool, bool, System.Threading.CancellationToken)
[Async] System.Net.Http.RedirectHandler.SendAsync(System.Net.Http.HttpRequestMessage, bool, System.Threading.CancellationToken)
[Async] System.Net.Http.HttpClient.GetByteArrayAsyncCore(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
[Async] TwitchDownloaderCore.TwitchHelper.GetImage(System.IO.DirectoryInfo, string, string, int, string, TwitchDownloaderCore.Interfaces.ITaskLogger, System.Threading.CancellationToken)
[Async] TwitchDownloaderCore.TwitchHelper.GetEmotes(System.Collections.Generic.List<TwitchDownloaderCore.TwitchObjects.Comment>, string, TwitchDownloaderCore.Interfaces.ITaskLogger, TwitchDownloaderCore.TwitchObjects.EmbeddedData, bool, System.Threading.CancellationToken)
[Async] TwitchDownloaderCore.ChatDownloader.EmbedImages(TwitchDownloaderCore.TwitchObjects.ChatRoot, System.Threading.CancellationToken)
[Async] TwitchDownloaderCore.ChatDownloader.DownloadAsyncImpl(System.IO.FileInfo, System.IO.FileStream, System.Threading.CancellationToken)
[Async] TwitchDownloaderCore.ChatDownloader.DownloadAsync(System.Threading.CancellationToken)
TwitchDownloaderCLI.Modes.DownloadChat.Download(TwitchDownloaderCLI.Modes.Arguments.ChatDownloadArgs)
CommandLine.ParserResultExtensions.WithParsed<TwitchDownloaderCLI.Modes.Arguments.ChatDownloadArgs>(CommandLine.ParserResult<object>, System.Action<TwitchDownloaderCLI.Modes.Arguments.ChatDownloadArgs>)
TwitchDownloaderCLI.Program.Main(string[])

I've debugged this a little bit and the cause seems to stem from this loop here:

https://github.com/lay295/TwitchDownloader/blob/d42d70b8d8d89e99aa3be7da252e6e9153c03220/TwitchDownloaderCore/TwitchHelper.cs#L540-L549

The loop variable ends up being null at some point, which causes the call to GetImage() to be invoked with an url of https://static-cdn.jtvnw.net/emoticons/v2//default/dark/2.0, which obviously fails to produce anything useful.

It's unclear to me whether this is just missing a null check (if so, how was this never noticed before?) or whether there's an underlying issue here that I'm not seeing due to lack of familiarity with this code.

Add any related files or extra information here

No response