diff --git a/Manager.YouTube/Util/Converters/YouTubeVideoJsonConverter.cs b/Manager.YouTube/Util/Converters/YouTubeVideoJsonConverter.cs index cdeb522..d7f73eb 100644 --- a/Manager.YouTube/Util/Converters/YouTubeVideoJsonConverter.cs +++ b/Manager.YouTube/Util/Converters/YouTubeVideoJsonConverter.cs @@ -1,3 +1,4 @@ +using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; using DotBased.Logging; @@ -21,13 +22,19 @@ public class YouTubeVideoJsonConverter : JsonConverter var videoDetails = root.GetProperty("videoDetails"); var playerConfigJson = root.GetProperty("playerConfig"); var microformat = root.GetProperty("microformat").GetProperty("playerMicroformatRenderer"); + + var videoId = videoDetails.GetProperty("videoId").GetString() ?? microformat.GetProperty("externalVideoId").GetString(); + if (string.IsNullOrEmpty(videoId)) + { + throw new SerializationException("Failed to get videoId"); + } var thumbnails = JsonParser.ExtractWebImages(videoDetails.GetProperty("thumbnail")); thumbnails.AddRange(JsonParser.ExtractWebImages(microformat.GetProperty("thumbnail"))); var video = new YouTubeVideo { - VideoId = videoDetails.GetProperty("videoId").GetString() ?? "", + VideoId = videoId, Title = JsonParser.ExtractTextOrHtml(microformat.GetProperty("title")), Description = JsonParser.ExtractTextOrHtml(microformat.GetProperty("description")), ViewCount = videoDetails.GetProperty("viewCount").GetInt32(),