示例#1
0
        private async Task <IDisposable> Update()
        {
            using (var relaser = await _UpdateLock.LockAsync())
            {
                NewItemsPerPlayableList.Clear();

                // 視聴履歴を取得して再生済み動画の情報を更新する
                _ = LoginUserDataProvider.GetHistory();

#if true
                // TODO: 前回更新時間から15分以上経っているか確認
                return(SubscriptionManager.GetSubscriptionFeedResultAsObservable(withoutDisabled: true)
                       .Subscribe(info =>
                {
                    Debug.WriteLine($"購読 {info.Subscription.Label} - {info.Source?.Label}");

                    if (!info.Subscription.IsEnabled)
                    {
                        Debug.WriteLine($"購読 {info.Subscription.Label} - {info.Source?.Label} の通知をスキップ(理由:自動更新が無効)");
                        return;
                    }

                    if (info.IsFirstUpdate)
                    {
                        Debug.WriteLine($"購読 {info.Subscription.Label} - {info.Source?.Label} の通知をスキップ(理由:初回更新)");
                        return;
                    }

                    if (info.NewFeedItems?.Any() ?? false)
                    {
                        // NGキーワードを含むタイトルの動画を取り除いて
                        var filterdNewItems = info.NewFeedItems
                                              .Where(x => !WatchItLater.IsVideoPlayed(x.Id))
                                              .Where(x => !info.Subscription.IsContainDoNotNoticeKeyword(x.Label))
                                              .ToList()
                        ;

                        // 新着動画を対象プレイリストに追加
                        Scheduler.Schedule(async() =>
                        {
                            Debug.WriteLine($"{info.Subscription.Label} - {info.Source?.Label} -> {string.Join(",", filterdNewItems.Select(x => x.Id))}");
                            await NewVideosAddToDestinations(info.Subscription.Destinations, filterdNewItems);

                            // トースト通知を発行
                            ShowNewVideosToastNotification(info.Subscription, info.Source.Value, info.NewFeedItems);
                        });
                    }
                }));
#else
                // 通知テスト
                foreach (var subsc in SubscriptionManager.Instance.Subscriptions)
                {
                    var feedResult = Database.Local.Subscription.SubscriptionFeedResultDb.GetEnsureFeedResult(subsc);

                    var result = feedResult.GetFeedResultSet(subsc.Sources[0]);
                    var info   = new SubscriptionUpdateInfo()
                    {
                        Subscription = subsc,
                        Source       = subsc.Sources[0],
                        NewFeedItems = result.Items.Take(5).Select(x => Database.NicoVideoDb.Get(x)).ToList(),
                    };

                    ShowNewVideosToastNotification(info.Subscription, info.Source, info.NewFeedItems);
                }
                return(new CompositeDisposable());
#endif
            }
        }
示例#2
0
 public MembershipUserProvider()
 {
     LoginUserProvider = new LoginUserDataProvider(this, TableName, DatabaseName, "", "");
 }