Task <ICommentSession> CreateCommentSession(string contentId, DmcWatchData watchData) { var commentClient = new CommentClient(_niconicoSession, contentId); var dmcRes = watchData.DmcWatchResponse; commentClient.CommentServerInfo = new CommentServerInfo() { ServerUrl = dmcRes.Thread.ServerUrl, VideoId = contentId, DefaultThreadId = int.Parse(dmcRes.Thread.Ids.Default), ViewerUserId = dmcRes.Viewer.Id, ThreadKeyRequired = dmcRes.Video.IsOfficial }; // チャンネル動画ではOnwerはnullになる commentClient.VideoOwnerId = dmcRes.Owner?.Id; commentClient.DmcWatch = dmcRes; if (int.TryParse(dmcRes.Thread.Ids.Community, out var communityThreadId)) { commentClient.CommentServerInfo.CommunityThreadId = communityThreadId; Debug.WriteLine("dmcRes.Video.DmcInfo.Thread.PostkeyAvailable: " + dmcRes.Video.DmcInfo?.Thread?.PostkeyAvailable); } return(Task.FromResult(new VideoCommentService(commentClient) as ICommentSession)); }
public NicoVideo(string rawVideoid, NiconicoContentProvider contentProvider, NiconicoContext context, VideoCacheManager manager) { RawVideoId = rawVideoid; _ContentProvider = contentProvider; _Context = context; CacheManager = manager; CommentClient = new CommentClient(_Context, RawVideoId); }
public NicoVideo(HohoemaApp app, string rawVideoid, NiconicoMediaManager manager) { HohoemaApp = app; RawVideoId = rawVideoid; _NiconicoMediaManager = manager; _InterfaceByQuality = new Dictionary <NicoVideoQuality, DividedQualityNicoVideo>(); QualityDividedVideos = new ReadOnlyObservableCollection <DividedQualityNicoVideo>(_QualityDividedVideos); CommentClient = new CommentClient(HohoemaApp, RawVideoId); }
Task <ICommentSession> CreateCommentSession(string contentId, WatchApiResponse watchApiRes) { var commentClient = new CommentClient(_niconicoSession, contentId); commentClient.CommentServerInfo = new CommentServerInfo() { ServerUrl = watchApiRes.CommentServerUrl.OriginalString, VideoId = contentId, DefaultThreadId = (int)watchApiRes.ThreadId, CommunityThreadId = (int)watchApiRes.OptionalThreadId, ViewerUserId = watchApiRes.viewerInfo.id, ThreadKeyRequired = watchApiRes.IsKeyRequired }; commentClient.VideoOwnerId = watchApiRes.UploaderInfo?.id; return(Task.FromResult(new VideoCommentService(commentClient) as ICommentSession)); }
public async Task <ICommentSession> CreateCommentSessionAsync(string contentId) { var res = await VisitWatchPage(contentId); var commentClient = new CommentClient(NiconicoSession, contentId); if (res is WatchApiResponse watchApiRes) { commentClient.CommentServerInfo = new CommentServerInfo() { ServerUrl = watchApiRes.CommentServerUrl.OriginalString, VideoId = contentId, DefaultThreadId = (int)watchApiRes.ThreadId, CommunityThreadId = (int)watchApiRes.OptionalThreadId, ViewerUserId = watchApiRes.viewerInfo.id, ThreadKeyRequired = watchApiRes.IsKeyRequired }; commentClient.VideoOwnerId = watchApiRes.UploaderInfo?.id; } else if (res is DmcWatchData watchData) { var dmcRes = watchData.DmcWatchResponse; commentClient.CommentServerInfo = new CommentServerInfo() { ServerUrl = dmcRes.Thread.ServerUrl, VideoId = contentId, DefaultThreadId = int.Parse(dmcRes.Thread.Ids.Default), ViewerUserId = dmcRes.Viewer.Id, ThreadKeyRequired = dmcRes.Video.IsOfficial }; // チャンネル動画ではOnwerはnullになる commentClient.VideoOwnerId = dmcRes.Owner?.Id; commentClient.DmcWatch = dmcRes; if (int.TryParse(dmcRes.Thread.Ids.Community, out var communityThreadId)) { commentClient.CommentServerInfo.CommunityThreadId = communityThreadId; Debug.WriteLine("dmcRes.Video.DmcInfo.Thread.PostkeyAvailable: " + dmcRes.Video.DmcInfo?.Thread?.PostkeyAvailable); } } return(new VideoCommentService(commentClient)); }
public async Task <object> VisitWatchPage(NicoVideoQuality quality) { if (!Helpers.InternetConnection.IsInternet()) { return(null); } object res = null; try { if (quality.IsLegacy()) { res = await GetWatchApiResponse(IsForceSmileLowQuality); } else { var dmcRes = await GetDmcWatchResponse(); res = dmcRes; } } catch { if (quality.IsLegacy()) { throw; } await Task.Delay(TimeSpan.FromSeconds(1)); res = await GetWatchApiResponse(IsForceSmileLowQuality); } _LastAccessResponse = res; if (res is WatchApiResponse) { var watchApiRes = res as WatchApiResponse; CommentClient = new CommentClient(_Context, new CommentServerInfo() { ServerUrl = watchApiRes.CommentServerUrl.OriginalString, VideoId = RawVideoId, DefaultThreadId = (int)watchApiRes.ThreadId, CommunityThreadId = (int)watchApiRes.OptionalThreadId, ViewerUserId = watchApiRes.viewerInfo.id, ThreadKeyRequired = watchApiRes.IsKeyRequired }); return(res); } else if (res is DmcWatchData) { var watchdata = res as DmcWatchData; var dmcRes = watchdata.DmcWatchResponse; CommentClient = new CommentClient(_Context, new CommentServerInfo() { ServerUrl = dmcRes.Thread.ServerUrl, VideoId = RawVideoId, DefaultThreadId = int.Parse(dmcRes.Thread.Ids.Default), ViewerUserId = dmcRes.Viewer.Id, ThreadKeyRequired = dmcRes.Video.IsOfficial }) { LastAccessDmcWatchResponse = dmcRes }; if (int.TryParse(dmcRes.Thread.Ids.Community, out var communityThreadId)) { CommentClient.CommentServerInfo.CommunityThreadId = communityThreadId; Debug.WriteLine("dmcRes.Video.DmcInfo.Thread.PostkeyAvailable: " + dmcRes.Video.DmcInfo?.Thread?.PostkeyAvailable); } return(res); } else { return(null); } }