[CHANGE] Implementation video data
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user