Tyrrrz / YoutubeDownloader

Downloads videos and playlists from YouTube
MIT License
8.71k stars 1.19k forks source link

Failing to download a video due to closed captions parsing error #362

Closed xs2237 closed 1 year ago

xs2237 commented 1 year ago

Version

v1.10.1

Platform

Windows 10

Steps to reproduce

Video URL: https://www.youtube.com/watch?v=TqxQru7bdt0

Download settings:

Application settings:

Steps:

Details

Some videos fail to download. There seems to be something wrong with the subtitles.

Error message:

System.Xml.XmlException: Root element is missing.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlReader.MoveToContent()
   at System.Xml.Linq.XElement.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XElement.Parse(String text, LoadOptions options)
   at YoutubeExplode.Utils.Xml.Parse(String source) in /_/YoutubeExplode/Utils/Xml.cs:line 9
   at YoutubeExplode.Bridge.ClosedCaptionTrackResponse.Parse(String raw) in /_/YoutubeExplode/Bridge/ClosedCaptionTrackResponse.cs:line 75
   at YoutubeExplode.Videos.ClosedCaptions.ClosedCaptionController.GetClosedCaptionTrackResponseAsync(String url, CancellationToken cancellationToken) in /_/YoutubeExplode/Videos/ClosedCaptions/ClosedCaptionController.cs:line 25
   at YoutubeExplode.Videos.ClosedCaptions.ClosedCaptionClient.GetClosedCaptionsAsync(ClosedCaptionTrackInfo trackInfo, CancellationToken cancellationToken)+MoveNext() in /_/YoutubeExplode/Videos/ClosedCaptions/ClosedCaptionClient.cs:line 68
   at YoutubeExplode.Videos.ClosedCaptions.ClosedCaptionClient.GetClosedCaptionsAsync(ClosedCaptionTrackInfo trackInfo, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at YoutubeExplode.Utils.Extensions.AsyncCollectionExtensions.ToListAsync[T](IAsyncEnumerable`1 source) in /_/YoutubeExplode/Utils/Extensions/AsyncCollectionExtensions.cs:line 48
   at YoutubeExplode.Utils.Extensions.AsyncCollectionExtensions.ToListAsync[T](IAsyncEnumerable`1 source) in /_/YoutubeExplode/Utils/Extensions/AsyncCollectionExtensions.cs:line 48
   at YoutubeExplode.Videos.ClosedCaptions.ClosedCaptionClient.GetAsync(ClosedCaptionTrackInfo trackInfo, CancellationToken cancellationToken) in /_/YoutubeExplode/Videos/ClosedCaptions/ClosedCaptionClient.cs:line 121
   at YoutubeExplode.Videos.ClosedCaptions.ClosedCaptionClient.WriteToAsync(ClosedCaptionTrackInfo trackInfo, TextWriter writer, IProgress`1 progress, CancellationToken cancellationToken) in /_/YoutubeExplode/Videos/ClosedCaptions/ClosedCaptionClient.cs:line 143
   at YoutubeExplode.Videos.ClosedCaptions.ClosedCaptionClient.DownloadAsync(ClosedCaptionTrackInfo trackInfo, String filePath, IProgress`1 progress, CancellationToken cancellationToken) in /_/YoutubeExplode/Videos/ClosedCaptions/ClosedCaptionClient.cs:line 181
   at YoutubeExplode.Converter.Converter.PopulateSubtitleInputsAsync(String baseFilePath, IReadOnlyList`1 closedCaptionTrackInfos, ICollection`1 subtitleInputs, IProgress`1 progress, CancellationToken cancellationToken) in /_/YoutubeExplode.Converter/Converter.cs:line 218
   at YoutubeExplode.Converter.Converter.ProcessAsync(String filePath, Container container, IReadOnlyList`1 streamInfos, IReadOnlyList`1 closedCaptionTrackInfos, IProgress`1 progress, CancellationToken cancellationToken) in /_/YoutubeExplode.Converter/Converter.cs:line 264
   at YoutubeExplode.Converter.ConversionExtensions.DownloadAsync(VideoClient videoClient, IReadOnlyList`1 streamInfos, IReadOnlyList`1 closedCaptionTrackInfos, ConversionRequest request, IProgress`1 progress, CancellationToken cancellationToken) in /_/YoutubeExplode.Converter/ConversionExtensions.cs:line 81
   at YoutubeDownloader.Core.Downloading.VideoDownloader.DownloadVideoAsync(String filePath, IVideo video, VideoDownloadOption downloadOption, IProgress`1 progress, CancellationToken cancellationToken) in D:\a\YoutubeDownloader\YoutubeDownloader\YoutubeDownloader.Core\Downloading\VideoDownloader.cs:line 58
   at YoutubeDownloader.ViewModels.Components.DashboardViewModel.<>c__DisplayClass31_0.<<EnqueueDownload>b__0>d.MoveNext() in D:\a\YoutubeDownloader\YoutubeDownloader\YoutubeDownloader\ViewModels\Components\DashboardViewModel.cs:line 110

Checklist

Tyrrrz commented 1 year ago

I'm getting this right now.

image

xs2237 commented 1 year ago

I checked again here, but there was no problem watching the video. ss_202308150931

xs2237 commented 1 year ago

The video contributor may have restrictions on which countries can be viewed.

https://support.google.com/youtube/answer/6303378?hl=en

Tyrrrz commented 1 year ago

Hmm, I switched my location to Japan/Tokyo via VPN and I was able to download the video just fine:

image

You can try the latest CI build, e.g.: https://github.com/Tyrrrz/YoutubeDownloader/suites/15052712649/artifacts/859584208

But I don't think there's anything that changed related to that.

xs2237 commented 1 year ago

I tried again today and both the latest and CI builds successfully downloaded the video.✅

Other than that, I have some additional information that might help fix this bug that I will post later.