コード例 #1
0
        /// <summary>
        /// Models.Provider.NicoVideoProvider内で検出した動画削除のイベントを受けて
        /// キャッシュされた動画を削除します
        /// </summary>
        /// <param name="eventAggregator"></param>
        /// <param name="videoCacheManager"></param>
        /// <param name="notificationService"></param>
        public NotificationCacheVideoDeletedService(
            IEventAggregator eventAggregator,
            Models.Cache.VideoCacheManager videoCacheManager,
            Services.NotificationService notificationService
            )
        {
            EventAggregator     = eventAggregator;
            VideoCacheManager   = videoCacheManager;
            NotificationService = notificationService;

            EventAggregator.GetEvent <Models.Provider.VideoDeletedEvent>()
            .Subscribe(async videoInfo =>
            {
                var deletedCount = await VideoCacheManager.DeleteCachedVideo(videoInfo.RawVideoId);

                if (deletedCount > 0)
                {
                    NotificationService.ShowToast("動画削除:" + videoInfo.RawVideoId
                                                  , $"『{videoInfo?.Title ?? videoInfo.RawVideoId}』 はニコニコ動画サーバーから削除されたため、キャッシュを強制削除しました。"
                                                  , Microsoft.Toolkit.Uwp.Notifications.ToastDuration.Long
                                                  );
                }
            }
                       , keepSubscriberReferenceAlive: true
                       );
        }
コード例 #2
0
        public UserMylistManager(
            NiconicoSession niconicoSession,
            Provider.LoginUserMylistProvider loginUserMylistProvider,
            Services.NotificationService notificationService
            )
        {
            _niconicoSession         = niconicoSession;
            _loginUserMylistProvider = loginUserMylistProvider;
            _notificationService     = notificationService;
            _mylists = new ObservableCollection <LoginUserMylistPlaylist>();
            Mylists  = new ReadOnlyObservableCollection <LoginUserMylistPlaylist>(_mylists);

            _niconicoSession.LogIn += async(_, e) =>
            {
                using (await _mylistSyncLock.LockAsync())
                {
                    IsLoginUserMylistReady = false;

                    await SyncMylistGroups();

                    IsLoginUserMylistReady = true;
                }
            };

            _niconicoSession.LogOut += async(_, e) =>
            {
                using (await _mylistSyncLock.LockAsync())
                {
                    IsLoginUserMylistReady = false;

                    _mylists.Clear();
                }
            };
        }
コード例 #3
0
        public LocalMylistManager(
            PlaylistRepository playlistRepository,
            NicoVideoProvider nicoVideoProvider,
            Services.NotificationService notificationService
            )
        {
            _playlistRepository  = playlistRepository;
            _nicoVideoProvider   = nicoVideoProvider;
            _notificationService = notificationService;
            MigrateLocalMylistToPlaylistRepository(_playlistRepository);

            var localPlaylistEntities = _playlistRepository.GetPlaylistsFromOrigin(Interfaces.PlaylistOrigin.Local);
            var localPlaylists        = localPlaylistEntities.Select(x => new LocalPlaylist(x.Id, _playlistRepository)
            {
                Label = x.Label,
                Count = x.Count
            }).ToList();

            _playlists     = new ObservableCollection <LocalPlaylist>(localPlaylists);
            LocalPlaylists = new ReadOnlyObservableCollection <LocalPlaylist>(_playlists);

            localPlaylists.ForEach(HandleItemsChanged);

            foreach (var entity in localPlaylistEntities)
            {
                _playlistIdToEntity.Add(entity.Id, entity);
            }
        }
コード例 #4
0
 public VideoInfomationPageViewModel(
     ILoggerFactory loggerFactory,
     ApplicationLayoutManager applicationLayoutManager,
     AppearanceSettings appearanceSettings,
     VideoFilteringSettings ngSettings,
     NiconicoSession niconicoSession,
     LoginUserOwnedMylistManager userMylistManager,
     NicoVideoProvider nicoVideoProvider,
     LoginUserMylistProvider loginUserMylistProvider,
     SubscriptionManager subscriptionManager,
     NicoVideoSessionProvider nicoVideo,
     PageManager pageManager,
     Services.NotificationService notificationService,
     Services.DialogService dialogService,
     VideoPlayWithQueueCommand videoPlayWithQueueCommand,
     MylistAddItemCommand addMylistCommand,
     LocalPlaylistAddItemCommand localPlaylistAddItemCommand,
     AddSubscriptionCommand addSubscriptionCommand,
     OpenLinkCommand openLinkCommand,
     CopyToClipboardCommand copyToClipboardCommand,
     CopyToClipboardWithShareTextCommand copyToClipboardWithShareTextCommand,
     OpenShareUICommand openShareUICommand,
     CacheAddRequestCommand cacheAddRequestCommand,
     RecommendProvider recommendProvider,
     UserFollowProvider userFollowProvider,
     ChannelFollowProvider channelFollowProvider
     )
 {
     _logger = loggerFactory.CreateLogger <VideoInfomationPageViewModel>();
     ApplicationLayoutManager = applicationLayoutManager;
     AppearanceSettings       = appearanceSettings;
     NgSettings              = ngSettings;
     NiconicoSession         = niconicoSession;
     UserMylistManager       = userMylistManager;
     NicoVideoProvider       = nicoVideoProvider;
     LoginUserMylistProvider = loginUserMylistProvider;
     SubscriptionManager     = subscriptionManager;
     NicoVideo                           = nicoVideo;
     PageManager                         = pageManager;
     NotificationService                 = notificationService;
     DialogService                       = dialogService;
     VideoPlayWithQueueCommand           = videoPlayWithQueueCommand;
     AddMylistCommand                    = addMylistCommand;
     LocalPlaylistAddItemCommand         = localPlaylistAddItemCommand;
     AddSubscriptionCommand              = addSubscriptionCommand;
     OpenLinkCommand                     = openLinkCommand;
     CopyToClipboardCommand              = copyToClipboardCommand;
     CopyToClipboardWithShareTextCommand = copyToClipboardWithShareTextCommand;
     OpenShareUICommand                  = openShareUICommand;
     CacheAddRequestCommand              = cacheAddRequestCommand;
     _recommendProvider                  = recommendProvider;
     _userFollowProvider                 = userFollowProvider;
     _channelFollowProvider              = channelFollowProvider;
     NowLoading                          = new ReactiveProperty <bool>(false);
     IsLoadFailed                        = new ReactiveProperty <bool>(false);
 }
コード例 #5
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("[Fanout]");

            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            // configuration
            var accessKey = configuration.GetSection("sns").GetSection("accessKey").Value;
            var secretKey = configuration.GetSection("sns").GetSection("secretKey").Value;
            var region    = configuration.GetSection("sns").GetSection("region").Value;
            var topicName = configuration.GetSection("sns").GetSection("topicName").Value;

            CancellationTokenSource cts = new CancellationTokenSource();

            Console.CancelKeyPress += (_, e) => {
                e.Cancel = true; // prevent the process from terminating.
                cts.Cancel();
            };

            try
            {
                var service = new Services.NotificationService(accessKey, secretKey, region);
                await service.CreateTopicAsync(topicName, cts.Token);

                while (true)
                {
                    Console.Write("Send message: ");
                    var message = Console.ReadLine();

                    if (!string.IsNullOrEmpty(message))
                    {
                        await service.SendAsync(topicName, message, cts.Token);
                    }
                }
            }
            catch (OperationCanceledException)
            {
                Console.WriteLine("Force stop");
            }

            Console.WriteLine("Ended");
        }
コード例 #6
0
 public VideoInfomationPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     AppearanceSettings appearanceSettings,
     NGSettings ngSettings,
     Models.NiconicoSession niconicoSession,
     UserMylistManager userMylistManager,
     HohoemaPlaylist hohoemaPlaylist,
     NicoVideoProvider nicoVideoProvider,
     LoginUserMylistProvider loginUserMylistProvider,
     VideoCacheManager videoCacheManager,
     SubscriptionManager subscriptionManager,
     Models.NicoVideoSessionProvider nicoVideo,
     Services.PageManager pageManager,
     Services.NotificationService notificationService,
     Services.DialogService dialogService,
     Services.ExternalAccessService externalAccessService,
     AddMylistCommand addMylistCommand,
     Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     _appearanceSettings      = appearanceSettings;
     NgSettings              = ngSettings;
     NiconicoSession         = niconicoSession;
     UserMylistManager       = userMylistManager;
     HohoemaPlaylist         = hohoemaPlaylist;
     NicoVideoProvider       = nicoVideoProvider;
     LoginUserMylistProvider = loginUserMylistProvider;
     VideoCacheManager       = videoCacheManager;
     SubscriptionManager     = subscriptionManager;
     NicoVideo                      = nicoVideo;
     PageManager                    = pageManager;
     NotificationService            = notificationService;
     DialogService                  = dialogService;
     ExternalAccessService          = externalAccessService;
     AddMylistCommand               = addMylistCommand;
     CreateSubscriptionGroupCommand = createSubscriptionGroupCommand;
     NowLoading                     = new ReactiveProperty <bool>(false);
     IsLoadFailed                   = new ReactiveProperty <bool>(false);
 }
コード例 #7
0
 public VideoInfomationPageViewModel(
     NGSettings ngSettings,
     Models.NiconicoSession niconicoSession,
     UserMylistManager userMylistManager,
     Services.HohoemaPlaylist hohoemaPlaylist,
     NicoVideoProvider nicoVideoProvider,
     LoginUserMylistProvider loginUserMylistProvider,
     VideoCacheManager videoCacheManager,
     Models.NicoVideoStreamingSessionProvider nicoVideo,
     Services.Helpers.MylistHelper mylistHelper,
     Services.PageManager pageManager,
     Services.NotificationService notificationService,
     Services.DialogService dialogService,
     Services.ExternalAccessService externalAccessService,
     Commands.AddMylistCommand addMylistCommand,
     Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand
     )
     : base(pageManager)
 {
     NgSettings              = ngSettings;
     NiconicoSession         = niconicoSession;
     UserMylistManager       = userMylistManager;
     HohoemaPlaylist         = hohoemaPlaylist;
     NicoVideoProvider       = nicoVideoProvider;
     LoginUserMylistProvider = loginUserMylistProvider;
     VideoCacheManager       = videoCacheManager;
     NicoVideo                      = nicoVideo;
     MylistHelper                   = mylistHelper;
     NotificationService            = notificationService;
     DialogService                  = dialogService;
     ExternalAccessService          = externalAccessService;
     AddMylistCommand               = addMylistCommand;
     CreateSubscriptionGroupCommand = createSubscriptionGroupCommand;
     NowLoading                     = new ReactiveProperty <bool>(false);
     IsLoadFailed                   = new ReactiveProperty <bool>(false);
 }
コード例 #8
0
        /// <summary>
        /// Models.Provider.NicoVideoProvider内で検出した動画削除のイベントを受けて
        /// キャッシュされた動画を削除します
        /// </summary>
        /// <param name="eventAggregator"></param>
        /// <param name="videoCacheManager"></param>
        /// <param name="notificationService"></param>
        public NotificationCacheVideoDeletedService(
            IEventAggregator eventAggregator,
            Models.Cache.VideoCacheManager videoCacheManager,
            Services.NotificationService notificationService
            )
        {
            EventAggregator     = eventAggregator;
            VideoCacheManager   = videoCacheManager;
            NotificationService = notificationService;

            EventAggregator.GetEvent <Models.Provider.VideoDeletedEvent>()
            .Subscribe(async videoInfo =>
            {
                if (await VideoCacheManager.DeleteFromNiconicoServer(videoInfo.RawVideoId))
                {
                    NotificationService.ShowToast("ToastNotification_VideoDeletedWithId".Translate(videoInfo.RawVideoId)
                                                  , "ToastNotification_ExplainVideoForceDeletion".Translate(videoInfo?.Title ?? videoInfo.RawVideoId)
                                                  , Microsoft.Toolkit.Uwp.Notifications.ToastDuration.Long
                                                  );
                }
            }
                       , keepSubscriberReferenceAlive: true
                       );
        }
コード例 #9
0
        public SubscriptionManager(
            IScheduler scheduler,
            Provider.ChannelProvider channelProvider,
            Provider.SearchProvider searchProvider,
            Provider.UserProvider userProvider,
            Provider.MylistProvider mylistProvider,
            Services.NotificationService notificationService

            )
        {
            Scheduler           = scheduler;
            ChannelProvider     = channelProvider;
            SearchProvider      = searchProvider;
            UserProvider        = userProvider;
            MylistProvider      = mylistProvider;
            NotificationService = notificationService;

            var storedSubscriptions = Database.Local.Subscription.SubscriptionDb.GetOrderedSubscriptions();

            Subscriptions = new ObservableCollection <Subscription>(storedSubscriptions);

            Subscriptions.CollectionChangedAsObservable()
            .Subscribe(arg =>
            {
                switch (arg.Action)
                {
                case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                    foreach (var item in arg.NewItems.Cast <Subscription>())
                    {
                        AddOrUpdateToSubscriptionDatabase(item);

                        SubscribeSubscriptionChanged(item);

                        item.IsDeleted = false;
                    }
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
                    // TODO: 購読グループの優先度変更に対応する
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                    foreach (var item in arg.OldItems.Cast <Subscription>())
                    {
                        RemoveFromSubscriptionDatabase(item);

                        UnsubscribeSubscriptionChanged(item);

                        item.IsDeleted = true;
                    }
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                    break;

                default:
                    break;
                }
            });

            foreach (var firstItem in storedSubscriptions)
            {
                SubscribeSubscriptionChanged(firstItem);
            }
        }