[CHANGE] Implementation video data

This commit is contained in:
max
2025-10-21 20:46:31 +02:00
parent ed1b7406a6
commit 97f7f5dcf6
5 changed files with 182 additions and 62 deletions

View File

@@ -4,6 +4,7 @@ using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using DotBased.Monads;
using Manager.YouTube.Models;
using Manager.YouTube.Models.Innertube;
using Manager.YouTube.Parsers;
using Manager.YouTube.Parsers.Json;
@@ -308,7 +309,7 @@ public sealed class YouTubeClient : IDisposable
return ResultError.Fail("Failed to get datasyncIds! Client not logged in.");
}
public async Task<Result> GetVideoByIdAsync(string videoId, CancellationToken cancellationToken = default)
public async Task<Result<YouTubeVideo>> GetVideoByIdAsync(string videoId, CancellationToken cancellationToken = default)
{
if (string.IsNullOrWhiteSpace(videoId))
{
@@ -331,14 +332,20 @@ public sealed class YouTubeClient : IDisposable
//TODO: Log warning: failed to update client state!
}
var htmlParseReult = HtmlParser.GetVideoDataFromHtml(html);
if (!htmlParseReult.IsSuccess)
var htmlParseResult = HtmlParser.GetVideoDataFromHtml(html);
if (!htmlParseResult.IsSuccess)
{
return htmlParseReult;
return htmlParseResult.Error ?? ResultError.Fail("Failed to parse HTML video data!");
}
//TODO: Process to YouTubeVideo model && decipher stream urls
var videoParseResult = VideoJsonParser.ParseVideoData(htmlParseResult.Value);
if (!videoParseResult.IsSuccess)
{
return videoParseResult;
}
//TODO: decipher stream urls
return Result.Success();
return videoParseResult.Value;
}
}