private async Task FillVideoInfoFromDb() { var videoInfo = await VideoInfoDb.GetAsync(RawVideoId); if (videoInfo == null) { return; } //this.RawVideoId = videoInfo.RawVideoId; this.VideoId = videoInfo.VideoId; this.VideoLength = videoInfo.Length; this.SizeLow = (uint)videoInfo.LowSize; this.SizeHigh = (uint)videoInfo.HighSize; this.Title = videoInfo.Title; this.OwnerId = videoInfo.UserId; this.ContentType = videoInfo.MovieType; this.PostedAt = videoInfo.PostedAt; this.Tags = videoInfo.GetTags(); this.ViewCount = videoInfo.ViewCount; this.MylistCount = videoInfo.MylistCount; this.CommentCount = videoInfo.CommentCount; this.ThumbnailUrl = videoInfo.ThumbnailUrl; this.DescriptionWithHtml = videoInfo.DescriptionWithHtml; }
/// <summary> /// キャッシュ要求の基本処理を実行します /// DividedQualityNicoVideoから呼び出されます /// </summary> /// <returns></returns> internal async Task OnCacheRequested() { IfVideoDeletedThrowException(); if (CommentClient != null) { await CommentClient.GetComments(); } var info = await VideoInfoDb.GetEnsureNicoVideoInfoAsync(RawVideoId); info.VideoId = this.VideoId; info.Length = this.VideoLength; info.LowSize = (uint)this.SizeLow; info.HighSize = (uint)this.SizeHigh; info.Title = this.Title; info.UserId = this.OwnerId; info.MovieType = this.ContentType; info.PostedAt = this.PostedAt; info.SetTags(this.Tags); info.ViewCount = this.ViewCount; info.MylistCount = this.MylistCount; info.CommentCount = this.CommentCount; info.ThumbnailUrl = this.ThumbnailUrl; await VideoInfoDb.UpdateAsync(info); }
public async Task CancelCacheRequest(NicoVideoQuality?quality = null) { if (quality.HasValue) { var divided = GetDividedQualityNicoVideo(quality.Value); await divided.DeleteCache(); } else { foreach (var divided in GetAllQuality()) { await divided.DeleteCache(); } } // 全てのキャッシュリクエストが取り消されていた場合 // 動画情報とコメント情報をDBから削除する if (GetAllQuality().All(x => !x.IsCacheRequested)) { var info = await VideoInfoDb.GetEnsureNicoVideoInfoAsync(RawVideoId); if (!info.IsDeleted) { await VideoInfoDb.RemoveAsync(info); } CommentDb.Remove(RawVideoId); _NiconicoMediaManager.VideoCacheStateChanged -= _NiconicoMediaManager_VideoCacheStateChanged; } }
public async Task <WatchApiResponse> GetWatchApiResponse(string rawVideoId, bool forceLowQuality = false, HarmfulContentReactionType harmfulContentReaction = HarmfulContentReactionType.None) { if (_HohoemaApp.NiconicoContext == null) { return(null); } if (!_HohoemaApp.IsLoggedIn) { return(null); } await WaitNicoPageAccess(); using (var releaser = await _NicoPageAccessLock.LockAsync()) { var res = await Util.ConnectionRetryUtil.TaskWithRetry(() => { return(_HohoemaApp.NiconicoContext.Video.GetWatchApiAsync( rawVideoId , forceLowQuality: forceLowQuality , harmfulReactType: harmfulContentReaction )); }); if (res != null && res.UploaderInfo != null) { var uploaderInfo = res.UploaderInfo; await UserInfoDb.AddOrReplaceAsync(uploaderInfo.id, uploaderInfo.nickname, uploaderInfo.icon_url); } if (res != null) { var data = await VideoInfoDb.GetEnsureNicoVideoInfoAsync(rawVideoId); if (data != null) { await VideoInfoDb.UpdateNicoVideoInfo(data, res); } } return(res); } }
internal async Task NotifyCacheForceDeleted(NicoVideo nicoVideo) { // キャッシュ登録を削除 var videoInfo = await VideoInfoDb.GetAsync(nicoVideo.RawVideoId); if (videoInfo != null) { videoInfo.IsDeleted = true; await VideoInfoDb.UpdateAsync(videoInfo); } var toastService = App.Current.Container.Resolve <Views.Service.ToastNotificationService>(); toastService.ShowText("動画削除:" + nicoVideo.RawVideoId , $"{nicoVideo.Title} はニコニコ動画サーバーから削除されたため、キャッシュを強制削除しました。" , Microsoft.Toolkit.Uwp.Notifications.ToastDuration.Long ); }