From 4cfc3fa7c061587e7ecf3e5b81e4bda91d07d739 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Thu, 8 Aug 2024 22:56:14 +0900 Subject: [PATCH] =?UTF-8?q?#968=20=E3=83=8B=E3=82=B3=E3=83=AC=E3=83=9D?= =?UTF-8?q?=E3=81=AE=E5=BB=83=E6=AD=A2=E3=81=8A=E3=82=88=E3=81=B3=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=AD=E3=83=BC=E6=96=B0=E7=9D=80=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=E3=80=82=E3=83=81=E3=83=A3=E3=83=B3=E3=83=8D=E3=83=AB?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E3=81=8C=E4=BB=8A=E5=BE=8C=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E3=81=AB=E3=81=AA=E3=82=8B=E3=81=8B=E3=82=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hohoema.Core/Hohoema.Core.csproj | 4 +- .../Models/Application/BackupManager.cs | 14 +- .../LoginUser/LoginUserNicoRepoProvider.cs | 19 - .../Niconico/NicoRepo/NicoRepoSettings.cs | 24 - .../Video/LoginUserHistoryProvider.cs | 8 +- .../Models/PageNavigation/HohoemaPageType.cs | 2 +- .../Player/Video/Comment/CommentClient.cs | 8 +- .../Player/Video/NicoVideoSessionProvider.cs | 28 +- .../DomandStreamingSession.cs | 32 +- .../Models/VideoCache/VideoCacheManager.cs | 9 +- Hohoema/App.xaml.cs | 4 +- Hohoema/Hohoema.csproj | 8 +- Hohoema/Locales/en-US.txt | 53 +- Hohoema/Locales/ja-JP.txt | 53 +- Hohoema/Locales/zh-CHS.txt | 53 +- Hohoema/Package.appxmanifest | 2 +- .../Player/Videos/VideoEndedRecommendation.cs | 2 +- .../VideoListItemControlViewModel.cs | 2 +- .../LiveMenuSubPageContent.cs | 2 +- .../VideoMenuSubPageContent.cs | 2 +- .../EditSubscriptionGroupDialog.xaml.cs | 2 +- .../FollowingsActivityPage.xaml} | 119 ++-- .../FollowingsActivityPage.xaml.cs} | 38 +- .../FollowingsActivityPageViewModel.cs | 477 ++++++++++++++++ .../NicoRepo/NicoRepoPageViewModel.cs | 507 ------------------ .../Video/VideoInfomationPageViewModel.cs | 4 +- .../Views.Player/VideoPlayerPageViewModel.cs | 4 +- .../VideoPlayerUI/DesktopPlayerUI.xaml.cs | 2 +- .../Converters/PageTypeToIconConverter.cs | 2 +- .../Views/PrimaryWindowCoreLayoutViewModel.cs | 4 +- Hohoema/Views/SettingsPageViewModel.cs | 8 +- 31 files changed, 673 insertions(+), 823 deletions(-) delete mode 100644 Hohoema.Core/Models/Niconico/NicoRepo/LoginUser/LoginUserNicoRepoProvider.cs delete mode 100644 Hohoema.Core/Models/Niconico/NicoRepo/NicoRepoSettings.cs rename Hohoema/Views.Niconico/{NicoRepo/NicoRepoPage.xaml => FollowingsActivity/FollowingsActivityPage.xaml} (65%) rename Hohoema/Views.Niconico/{NicoRepo/NicoRepoPage.xaml.cs => FollowingsActivity/FollowingsActivityPage.xaml.cs} (69%) create mode 100644 Hohoema/Views.Niconico/FollowingsActivity/FollowingsActivityPageViewModel.cs delete mode 100644 Hohoema/Views.Niconico/NicoRepo/NicoRepoPageViewModel.cs diff --git a/Hohoema.Core/Hohoema.Core.csproj b/Hohoema.Core/Hohoema.Core.csproj index 1ef992ce..2f082218 100644 --- a/Hohoema.Core/Hohoema.Core.csproj +++ b/Hohoema.Core/Hohoema.Core.csproj @@ -188,8 +188,6 @@ - - @@ -377,7 +375,7 @@ 2.7.2 - 0.6.2 + 0.6.5 7.12.0 diff --git a/Hohoema.Core/Models/Application/BackupManager.cs b/Hohoema.Core/Models/Application/BackupManager.cs index b8e768e0..8218e2a7 100644 --- a/Hohoema.Core/Models/Application/BackupManager.cs +++ b/Hohoema.Core/Models/Application/BackupManager.cs @@ -2,7 +2,6 @@ using CommunityToolkit.Mvvm.Messaging.Messages; using Hohoema.Contracts.Subscriptions; using Hohoema.Models.LocalMylist; -using Hohoema.Models.Niconico.NicoRepo; using Hohoema.Models.Niconico.Video; using Hohoema.Models.PageNavigation; using Hohoema.Models.Pins; @@ -12,7 +11,6 @@ using Hohoema.Models.Subscriptions; using LiteDB; using NiconicoToolkit.Live.WatchSession; -using NiconicoToolkit.NicoRepo; using NiconicoToolkit.Ranking.Video; using NiconicoToolkit.Video; using System; @@ -48,7 +46,6 @@ public sealed class BackupManager private readonly VideoFilteringSettings _videoFilteringSettings; private readonly PlayerSettings _playerSettings; private readonly AppearanceSettings _appearanceSettings; - private readonly NicoRepoSettings _nicoRepoSettings; private readonly CommentFliteringRepository _commentFliteringRepository; private readonly JsonSerializerOptions _options; @@ -64,7 +61,6 @@ public BackupManager(LocalMylistRepository playlistRepository, VideoFilteringSettings videoFilteringSettings, PlayerSettings playerSettings, AppearanceSettings appearanceSettings, - NicoRepoSettings nicoRepoSettings, CommentFliteringRepository commentFliteringRepository ) { @@ -76,8 +72,7 @@ CommentFliteringRepository commentFliteringRepository _videoRankingSettings = videoRankingSettings; _videoFilteringSettings = videoFilteringSettings; _playerSettings = playerSettings; - _appearanceSettings = appearanceSettings; - _nicoRepoSettings = nicoRepoSettings; + _appearanceSettings = appearanceSettings; _commentFliteringRepository = commentFliteringRepository; _options = new JsonSerializerOptions() { @@ -213,11 +208,6 @@ public async Task BackupAsync(StorageFile storageFile, CancellationToken ct = de ApplicationTheme = _appearanceSettings.ApplicationTheme.ToString() }, - NicoRepoSettings = new NicoRepoSettingsBackupEntry - { - DisplayNicoRepoMuteContextTriggers = _nicoRepoSettings.DisplayNicoRepoMuteContextTriggers.Select(x => x.ToString()).ToArray() - }, - CommentSettingsBackupEntry = new CommentSettingsBackupEntry { ShareNGScore = _commentFliteringRepository.ShareNGScore, @@ -477,7 +467,7 @@ public void RestoreNicoRepoSettings(BackupContainer backup) if (backup.NicoRepoSettings.DisplayNicoRepoMuteContextTriggers?.Any() ?? false) { - _nicoRepoSettings.DisplayNicoRepoMuteContextTriggers = backup.NicoRepoSettings.DisplayNicoRepoMuteContextTriggers.Select(x => Enum.TryParse(x, out NicoRepoMuteContextTrigger type) ? type : default(NicoRepoMuteContextTrigger?)).Where(x => x != null).Select(x => x.Value).ToList(); + //_nicoRepoSettings.DisplayNicoRepoMuteContextTriggers = backup.NicoRepoSettings.DisplayNicoRepoMuteContextTriggers.Select(x => Enum.TryParse(x, out NicoRepoMuteContextTrigger type) ? type : default(NicoRepoMuteContextTrigger?)).Where(x => x != null).Select(x => x.Value).ToList(); } } diff --git a/Hohoema.Core/Models/Niconico/NicoRepo/LoginUser/LoginUserNicoRepoProvider.cs b/Hohoema.Core/Models/Niconico/NicoRepo/LoginUser/LoginUserNicoRepoProvider.cs deleted file mode 100644 index 57ee5a7a..00000000 --- a/Hohoema.Core/Models/Niconico/NicoRepo/LoginUser/LoginUserNicoRepoProvider.cs +++ /dev/null @@ -1,19 +0,0 @@ -#nullable enable -using Hohoema.Infra; -using NiconicoToolkit.NicoRepo; -using System.Threading.Tasks; - -namespace Hohoema.Models.Niconico.NicoRepo.LoginUser; - -public sealed class LoginUserNicoRepoProvider : ProviderBase -{ - public LoginUserNicoRepoProvider(NiconicoSession niconicoSession) - : base(niconicoSession) - { - } - - public Task GetLoginUserNicoRepoAsync(NicoRepoType type, NicoRepoDisplayTarget target, NicoRepoEntriesResponse prevRes = null) - { - return _niconicoSession.ToolkitContext.NicoRepo.GetLoginUserNicoRepoEntriesAsync(type, target, prevRes?.Meta?.MinId); - } -} diff --git a/Hohoema.Core/Models/Niconico/NicoRepo/NicoRepoSettings.cs b/Hohoema.Core/Models/Niconico/NicoRepo/NicoRepoSettings.cs deleted file mode 100644 index 00147472..00000000 --- a/Hohoema.Core/Models/Niconico/NicoRepo/NicoRepoSettings.cs +++ /dev/null @@ -1,24 +0,0 @@ -#nullable enable -using Hohoema.Infra; -using NiconicoToolkit.NicoRepo; -using System.Collections.Generic; - -namespace Hohoema.Models.Niconico.NicoRepo; - -public class NicoRepoSettings : FlagsRepositoryBase -{ - [System.Obsolete] - public NicoRepoSettings() - { - DisplayNicoRepoMuteContextTriggers = Read(new List(), nameof(DisplayNicoRepoMuteContextTriggers)); - } - - private List _DisplayNicoRepoMuteContextTriggers; - - [System.Obsolete] - public List DisplayNicoRepoMuteContextTriggers - { - get => _DisplayNicoRepoMuteContextTriggers; - set => SetProperty(ref _DisplayNicoRepoMuteContextTriggers, value); - } -} diff --git a/Hohoema.Core/Models/Niconico/Video/LoginUserHistoryProvider.cs b/Hohoema.Core/Models/Niconico/Video/LoginUserHistoryProvider.cs index 916f424c..f721c517 100644 --- a/Hohoema.Core/Models/Niconico/Video/LoginUserHistoryProvider.cs +++ b/Hohoema.Core/Models/Niconico/Video/LoginUserHistoryProvider.cs @@ -31,7 +31,7 @@ VideoWatchedRepository videoWatchedRepository throw new HohoemaException("Failed get login user video watch history. Require LogIn."); } - VideoWatchHistory res = await _niconicoSession.ToolkitContext.Activity.VideoWachHistory.GetWatchHistoryAsync(page, pageSize); + VideoWatchHistory res = await _niconicoSession.ToolkitContext.History.VideoWachHistory.GetWatchHistoryAsync(page, pageSize); if (res.Meta.IsSuccess is false) { throw new HohoemaException("Failed get login user video watch history"); } @@ -46,19 +46,19 @@ VideoWatchedRepository videoWatchedRepository public async Task RemoveAllHistoriesAsync() { - VideoWatchHistoryDeleteResult res = await _niconicoSession.ToolkitContext.Activity.VideoWachHistory.DeleteAllWatchHistoriesAsync(); + VideoWatchHistoryDeleteResult res = await _niconicoSession.ToolkitContext.History.VideoWachHistory.DeleteAllWatchHistoriesAsync(); return res.IsSuccess; } public async Task RemoveHistoryAsync(VideoId videoId) { - VideoWatchHistoryDeleteResult res = await _niconicoSession.ToolkitContext.Activity.VideoWachHistory.DeleteWatchHistoriesAsync(videoId); + VideoWatchHistoryDeleteResult res = await _niconicoSession.ToolkitContext.History.VideoWachHistory.DeleteWatchHistoriesAsync(videoId); return res.IsSuccess; } public async Task RemoveHistoryAsync(IEnumerable videoIdList) { - VideoWatchHistoryDeleteResult res = await _niconicoSession.ToolkitContext.Activity.VideoWachHistory.DeleteWatchHistoriesAsync(videoIdList); + VideoWatchHistoryDeleteResult res = await _niconicoSession.ToolkitContext.History.VideoWachHistory.DeleteWatchHistoriesAsync(videoIdList); return res.IsSuccess; } } diff --git a/Hohoema.Core/Models/PageNavigation/HohoemaPageType.cs b/Hohoema.Core/Models/PageNavigation/HohoemaPageType.cs index a36d1577..d9a6b6c3 100644 --- a/Hohoema.Core/Models/PageNavigation/HohoemaPageType.cs +++ b/Hohoema.Core/Models/PageNavigation/HohoemaPageType.cs @@ -45,7 +45,7 @@ public enum HohoemaPageType Splash, VideoPlayer, - NicoRepo, + FollowingsActivity, Recommend, ChannelInfo, diff --git a/Hohoema.Core/Models/Player/Video/Comment/CommentClient.cs b/Hohoema.Core/Models/Player/Video/Comment/CommentClient.cs index 2cc71e7d..0d3e1ed3 100644 --- a/Hohoema.Core/Models/Player/Video/Comment/CommentClient.cs +++ b/Hohoema.Core/Models/Player/Video/Comment/CommentClient.cs @@ -34,7 +34,7 @@ public CommentClient(NiconicoSession niconicoSession, string rawVideoid) public string RawVideoId { get; } public string VideoOwnerId => _watchApiData!.Owner.Id.ToString(); - internal NicoVideoWatchApiResponse.Response? _watchApiData { get; set; } + internal WatchResponse? _watchApiData { get; set; } private readonly NiconicoSession _niconicoSession; @@ -48,7 +48,7 @@ public async Task SubmitComment(string comment, TimeSpan posi Guard.IsNotNull(_watchApiData); VideoId videoId = _watchApiData.Video.Id; - NiconicoToolkit.Video.Watch.NicoVideoWatchApiResponse.Thread mainThread = _watchApiData.Comment.Threads.First(x => x.ForkLabel == ThreadTargetForkConstants.Main); + NiconicoToolkit.Video.Watch.Thread mainThread = _watchApiData.Comment.Threads.First(x => x.ForkLabel == ThreadTargetForkConstants.Main); string threadId = mainThread.Id.ToString(); bool isPostCompleted = false; @@ -154,7 +154,7 @@ private async Task GetPostKeyLatestAsync(string threadForkLabel, Cancell if (threadForkLabel == ThreadTargetForkConstants.Main) { Guard.IsNotNull(_watchApiData); - NiconicoToolkit.Video.Watch.NicoVideoWatchApiResponse.Thread thread = _watchApiData.Comment.Threads.First(x => x.ForkLabel == ThreadTargetForkConstants.Main); + NiconicoToolkit.Video.Watch.Thread thread = _watchApiData.Comment.Threads.First(x => x.ForkLabel == ThreadTargetForkConstants.Main); ThreadPostKeyResponse res = await _nvCommentApi.GetPostKeyAsync(thread.Id.ToString(), ct); Guard.IsTrue(res.IsSuccess); @@ -163,7 +163,7 @@ private async Task GetPostKeyLatestAsync(string threadForkLabel, Cancell else if (threadForkLabel == ThreadTargetForkConstants.Easy) { Guard.IsNotNull(_watchApiData); - NiconicoToolkit.Video.Watch.NicoVideoWatchApiResponse.Thread thread = _watchApiData.Comment.Threads.First(x => x.ForkLabel == ThreadTargetForkConstants.Easy); + NiconicoToolkit.Video.Watch.Thread thread = _watchApiData.Comment.Threads.First(x => x.ForkLabel == ThreadTargetForkConstants.Easy); ThreadEasyPostKeyResponse res = await _nvCommentApi.GetEasyPostKeyAsync(thread.Id.ToString(), ct); Guard.IsTrue(res.IsSuccess); diff --git a/Hohoema.Core/Models/Player/Video/NicoVideoSessionProvider.cs b/Hohoema.Core/Models/Player/Video/NicoVideoSessionProvider.cs index 2bcc7f24..e130c514 100644 --- a/Hohoema.Core/Models/Player/Video/NicoVideoSessionProvider.cs +++ b/Hohoema.Core/Models/Player/Video/NicoVideoSessionProvider.cs @@ -44,9 +44,9 @@ public interface INicoVideoDetails : IVideoDetail public class DmcVideoDetails : INicoVideoDetails { - private readonly Response _res; + private readonly WatchResponse _res; - internal DmcVideoDetails(Response dmcWatchData) + internal DmcVideoDetails(WatchResponse dmcWatchData) { _res = dmcWatchData; Tags = _res.Tag.Items.Select(x => new NicoVideoTag(x.Name)).ToArray(); @@ -92,7 +92,7 @@ public double LoudnessCorrectionValue } else if (_res.Media.Domand != null) { - return _res.Media.Domand.Audios.FirstOrDefault(x => x.IsAvailable ?? false)?.LoudnessCollection[0].Value ?? 1; + return _res.Media.Domand.Audios.FirstOrDefault(x => x.IsAvailable)?.LoudnessCollection[0].Value ?? 1; } } catch { } @@ -148,7 +148,7 @@ public class PreparePlayVideoResult : INiconicoVideoSessionProvider, INiconicoCo public ImmutableArray AvailableQualities { get; } private readonly NicoVideoSessionOwnershipManager _ownershipManager; - private readonly Response _dmcWatchData; + private readonly WatchResponse _dmcWatchData; private readonly bool _isForceDmc; private readonly NiconicoSession _niconicoSession; @@ -166,7 +166,7 @@ public PreparePlayVideoResult(VideoId contentId, NiconicoSession niconicoSession IsSuccess = false; } - public PreparePlayVideoResult(VideoId contentId, NiconicoSession niconicoSession, PreparePlayVideoFailedReason failedReason, Response dmcWatchData = null) + public PreparePlayVideoResult(VideoId contentId, NiconicoSession niconicoSession, PreparePlayVideoFailedReason failedReason, WatchResponse dmcWatchData = null) : this(contentId, niconicoSession) { AvailableQualities = ImmutableArray.Empty; @@ -175,7 +175,7 @@ public PreparePlayVideoResult(VideoId contentId, NiconicoSession niconicoSession _dmcWatchData = dmcWatchData; } - public PreparePlayVideoResult(VideoId contentId, NiconicoSession niconicoSession, NicoVideoSessionOwnershipManager ownershipManager, Response dmcWatchData, bool isForceDmc) + public PreparePlayVideoResult(VideoId contentId, NiconicoSession niconicoSession, NicoVideoSessionOwnershipManager ownershipManager, WatchResponse dmcWatchData, bool isForceDmc) : this(contentId, niconicoSession) { _ownershipManager = ownershipManager; @@ -186,19 +186,19 @@ public PreparePlayVideoResult(VideoId contentId, NiconicoSession niconicoSession if (_isForceDmc && _dmcWatchData?.Media.Delivery is not null) { AvailableQualities = _dmcWatchData.Media.Delivery.Movie.Videos - .Select(x => new NicoVideoQualityEntity(x.IsAvailable.Value, QualityIdToNicoVideoQuality(x.Id), x.Id, (int)x.BitRate.Value, (int)x.Width, (int)x.Height) { Label = x.Label }) + .Select(x => new NicoVideoQualityEntity(x.IsAvailable, QualityIdToNicoVideoQuality(x.Id), x.Id, (int)x.BitRate, (int)x.Width, (int)x.Height) { Label = x.Label }) .ToImmutableArray(); } else if (_dmcWatchData?.Media.Domand is { } domand) { AvailableQualities = domand.Videos - .Select(x => new NicoVideoQualityEntity(x.IsAvailable ?? false, QualityIdToNicoVideoQuality(x.Id), x.Id, x.BitRate, x.Width, x.Height) { Label = x.Label }) + .Select(x => new NicoVideoQualityEntity(x.IsAvailable, QualityIdToNicoVideoQuality(x.Id), x.Id, x.BitRate, x.Width, x.Height) { Label = x.Label }) .ToImmutableArray(); } else if (_dmcWatchData?.Media.Delivery is { } delivery) { AvailableQualities = delivery.Movie.Videos - .Select(x => new NicoVideoQualityEntity(x.IsAvailable.Value, QualityIdToNicoVideoQuality(x.Id), x.Id, (int)x.BitRate.Value, (int)x.Width, (int)x.Height) { Label = x.Label }) + .Select(x => new NicoVideoQualityEntity(x.IsAvailable, QualityIdToNicoVideoQuality(x.Id), x.Id, (int)x.BitRate, (int)x.Width, (int)x.Height) { Label = x.Label }) .ToImmutableArray(); } else @@ -279,10 +279,10 @@ public Task> CreateCommentSessionAsync() return _dmcWatchData != null ? CreateCommentSession(ContentId, _dmcWatchData) : throw new NotSupportedException(); } - private Task> CreateCommentSession(string contentId, Response watchData) + private Task> CreateCommentSession(string contentId, WatchResponse watchData) { CommentClient commentClient = new(_niconicoSession, contentId); - Response dmcRes = watchData; + WatchResponse dmcRes = watchData; //commentClient.CommentServerInfo = new CommentServerInfo() //{ // ServerUrl = dmcRes.Comment.Threads[0].Server.OriginalString, @@ -660,7 +660,7 @@ public class NiconicoContent public static class DmcWatchSessionExtension { - public static NicoVideoQuality ToNicoVideoQuality(this Response dmcWatchData, string qualityId) + public static NicoVideoQuality ToNicoVideoQuality(this WatchResponse dmcWatchData, string qualityId) { if (dmcWatchData.Media.Domand is { } domand && domand.Videos.FirstOrDefault(x => x.Id == qualityId) is { } videoQuality @@ -677,10 +677,10 @@ public static NicoVideoQuality ToNicoVideoQuality(this Response dmcWatchData, st }; } - NicoVideoWatchApiResponse.Video dmcVideoContent = dmcWatchData?.Media.Delivery.Movie.Videos.FirstOrDefault(x => x.Id == qualityId); + VideoContent dmcVideoContent = dmcWatchData?.Media.Delivery.Movie.Videos.FirstOrDefault(x => x.Id == qualityId); if (dmcVideoContent != null) { - NicoVideoWatchApiResponse.Video[] qualities = dmcWatchData.Media.Delivery.Movie.Videos; + VideoContent[] qualities = dmcWatchData.Media.Delivery.Movie.Videos; int index = Array.IndexOf(qualities, dmcVideoContent); // DmcInfo.Quality の要素数は動画によって1~5個まで様々である diff --git a/Hohoema.Core/Models/Player/Video/VideoStreamingSession/DomandStreamingSession.cs b/Hohoema.Core/Models/Player/Video/VideoStreamingSession/DomandStreamingSession.cs index 81e385b1..a336389d 100644 --- a/Hohoema.Core/Models/Player/Video/VideoStreamingSession/DomandStreamingSession.cs +++ b/Hohoema.Core/Models/Player/Video/VideoStreamingSession/DomandStreamingSession.cs @@ -18,12 +18,12 @@ namespace Hohoema.Models.Player.Video; public sealed class DomandStreamingSession : VideoStreamingSession { private readonly NiconicoContext _context; - private readonly Response _watchApiData; - private readonly Domand _domand; + private readonly WatchResponse _watchApiData; + private readonly WatchDomand _domand; public DomandStreamingSession( - Response watchApiData, - Domand domand, + WatchResponse watchApiData, + WatchDomand domand, NiconicoSession niconicoSession, NicoVideoSessionOwnershipManager.VideoSessionOwnership videoSessionOwnership) : base(niconicoSession, videoSessionOwnership) @@ -31,8 +31,8 @@ public DomandStreamingSession( _context = niconicoSession.ToolkitContext; _watchApiData = watchApiData; _domand = domand; - VideoQuality = _domand.Videos.Where(x => x.IsAvailable ?? false).Last(); - AudioQuality = _domand.Audios.Where(x => x.IsAvailable ?? false).Last(); + VideoQuality = _domand.Videos.Where(x => x.IsAvailable).Last(); + AudioQuality = _domand.Audios.Where(x => x.IsAvailable).Last(); QualityId = VideoQuality.Id; Quality = _watchApiData.ToNicoVideoQuality(QualityId); @@ -41,11 +41,11 @@ public DomandStreamingSession( public override string QualityId { get; protected set; } public override NicoVideoQuality Quality { get; protected set; } - public NicoVideoWatchApiResponse.Audio AudioQuality { get; set; } - public NicoVideoWatchApiResponse.Video VideoQuality { get; set; } + public AudioContent AudioQuality { get; set; } + public VideoContent VideoQuality { get; set; } - public List GetVideoQualities() => _watchApiData.Media.Domand.Videos; - public List GetAudioQualities() => _watchApiData.Media.Domand.Audios; + public List GetVideoQualities() => _watchApiData.Media.Domand.Videos; + public List GetAudioQualities() => _watchApiData.Media.Domand.Audios; public void SetQuality(NicoVideoQuality quality) { @@ -59,25 +59,25 @@ public void SetQuality(NicoVideoQuality quality) _ => 0, }; - if (_watchApiData.Media.Domand.Videos.Where(x => (x.IsAvailable ?? false) && ((x.QualityLevel ?? 0) == requireQualityLevel)).FirstOrDefault() is { } requireQuality) + if (_watchApiData.Media.Domand.Videos.Where(x => (x.IsAvailable) && ((x.QualityLevel) == requireQualityLevel)).FirstOrDefault() is { } requireQuality) { VideoQuality = requireQuality; } else { - VideoQuality = _watchApiData.Media.Domand.Videos.Where(x => x.IsAvailable ?? false).First(); + VideoQuality = _watchApiData.Media.Domand.Videos.Where(x => x.IsAvailable).First(); } Debug.WriteLine($"audio qualities: {string.Join(',', _watchApiData.Media.Domand.Audios.Select(x => x.Id))}"); - var recommendedAudioQuality = _watchApiData.Media.Domand.Audios.First(x => (x.QualityLevel ?? 0) == VideoQuality.RecommendedHighestAudioQualityLevel); - if (recommendedAudioQuality.IsAvailable ?? false) + var recommendedAudioQuality = _watchApiData.Media.Domand.Audios.First(x => (x.QualityLevel) == VideoQuality.RecommendedHighestAudioQualityLevel); + if (recommendedAudioQuality.IsAvailable) { AudioQuality = recommendedAudioQuality; } else { - AudioQuality = _watchApiData.Media.Domand.Audios.First(x => x.IsAvailable ?? false); + AudioQuality = _watchApiData.Media.Domand.Audios.First(x => x.IsAvailable); } Debug.WriteLine($"Set Quality Video: {VideoQuality.Id}, Audio: {AudioQuality.Id}"); @@ -98,7 +98,7 @@ protected override async Task GetPlyaingVideoMediaSource() if (res.IsSuccess is false) { - var lowAudio = _domand.Audios.First(x => x.IsAvailable ?? false); + var lowAudio = _domand.Audios.First(x => x.IsAvailable); Debug.WriteLine($"can't use Audio Level {AudioQuality.Id}, so fallback to {lowAudio.Id}"); res = await _context.Video.VideoWatch.GetDomandHlsAccessRightAsync( _watchApiData.Video.Id, diff --git a/Hohoema.Core/Models/VideoCache/VideoCacheManager.cs b/Hohoema.Core/Models/VideoCache/VideoCacheManager.cs index da301dff..0e92dd4c 100644 --- a/Hohoema.Core/Models/VideoCache/VideoCacheManager.cs +++ b/Hohoema.Core/Models/VideoCache/VideoCacheManager.cs @@ -6,6 +6,7 @@ using Hohoema.Models.Player.Video; using Microsoft.Toolkit.Uwp.Helpers; using NiconicoToolkit.Video; +using NiconicoToolkit.Video.Watch; using System; using System.Collections; using System.Collections.Generic; @@ -323,8 +324,8 @@ public async Task GetCacheVideoMediaSource(VideoCacheItem item) } // require watch permission - NiconicoToolkit.Video.Watch.NicoVideoWatchApiResponse watchData = await _niconicoSession.ToolkitContext.Video.VideoWatch.GetWatchDataAsync(item.VideoId); - NiconicoToolkit.Video.Watch.NicoVideoWatchApiResponse.Response watchApiData = watchData.Data.Response; + NicoVideoWatchApiResponse watchData = await _niconicoSession.ToolkitContext.Video.VideoWatch.GetWatchDataAsync(item.VideoId); + WatchResponse watchApiData = watchData.Data.Response; if (watchApiData?.Media?.Delivery is null) { throw new VideoCacheException("VideoCacheItem is can not play, require content access permission. reason : " + watchApiData?.OkReason); @@ -689,8 +690,8 @@ internal async ValueTask CreateDownlo try { - NiconicoToolkit.Video.Watch.NicoVideoWatchApiResponse watchData = await _niconicoSession.ToolkitContext.Video.VideoWatch.GetWatchDataAsync(item.VideoId); - NiconicoToolkit.Video.Watch.NicoVideoWatchApiResponse.Response watchApiData = watchData.Data.Response; + NicoVideoWatchApiResponse watchData = await _niconicoSession.ToolkitContext.Video.VideoWatch.GetWatchDataAsync(item.VideoId); + WatchResponse watchApiData = watchData.Data.Response; if (watchApiData is null) { diff --git a/Hohoema/App.xaml.cs b/Hohoema/App.xaml.cs index a04c1c09..2c6f7b6c 100644 --- a/Hohoema/App.xaml.cs +++ b/Hohoema/App.xaml.cs @@ -13,7 +13,6 @@ using Hohoema.Infra; using Hohoema.Models.Application; using Hohoema.Models.Niconico; -using Hohoema.Models.Niconico.NicoRepo; using Hohoema.Models.Niconico.Video; using Hohoema.Models.Pins; using Hohoema.Models.Player; @@ -301,7 +300,7 @@ private void RegisterRequiredTypes(IContainer container) viewLocator.RegisterForNavigation(); viewLocator.RegisterForNavigation(); viewLocator.RegisterForNavigation(); - viewLocator.RegisterForNavigation(); + viewLocator.RegisterForNavigation(); viewLocator.RegisterForNavigation(); viewLocator.RegisterForNavigation(); viewLocator.RegisterForNavigation(); @@ -389,7 +388,6 @@ public void RegisterTypes(IContainer container) container.Register(reuse: Reuse.Singleton); container.Register(reuse: Reuse.Singleton); container.Register(reuse: Reuse.Singleton); - container.Register(reuse: Reuse.Singleton); container.Register(reuse: Reuse.Singleton); container.Register(reuse: Reuse.Singleton); diff --git a/Hohoema/Hohoema.csproj b/Hohoema/Hohoema.csproj index 766e1d51..10035dc1 100644 --- a/Hohoema/Hohoema.csproj +++ b/Hohoema/Hohoema.csproj @@ -321,7 +321,7 @@ - + @@ -479,8 +479,8 @@ FollowManagePage.xaml - - NicoRepoPage.xaml + + FollowingsActivityPage.xaml TimeshiftPage.xaml @@ -1035,7 +1035,7 @@ MSBuild:Compile Designer - + MSBuild:Compile Designer diff --git a/Hohoema/Locales/en-US.txt b/Hohoema/Locales/en-US.txt index 055b213a..9943198f 100644 --- a/Hohoema/Locales/en-US.txt +++ b/Hohoema/Locales/en-US.txt @@ -82,7 +82,7 @@ HohoemaPageType.FeedGroup = Feed group HohoemaPageType.FeedGroupManage = New videos HohoemaPageType.FeedVideoList = Video list of the feed HohoemaPageType.FollowManage = Follow -HohoemaPageType.NicoRepo = Nicorepo +HohoemaPageType.FollowingsActivity = Followings New HohoemaPageType.RankingCategory = Category ranking HohoemaPageType.RankingCategoryList = Ranking list HohoemaPageType.Recommend = Recommended video @@ -710,47 +710,16 @@ FollowInfoIsRequireLogIn = You must be logged in to see follow information FollowerCount = Follower MylistVideoCountDesc = {0} videos -#### Nicorepo #### -NicoRepoDisplayOptions = Display conditions -NicoRepoType.All = All -NicoRepoType.Video = Video posting -NicoRepoType.Program = Live broadcast started -NicoRepoType.Image = Illustration posting -NicoRepoType.ComicStory = Manga post -NicoRepoType.Article = Article posting -NicoRepoType.Game = Game -NicoRepoDisplayTarget.All = All -NicoRepoDisplayTarget.Self = Myself -NicoRepoDisplayTarget.User = User -NicoRepoDisplayTarget.Channel = Channel -NicoRepoDisplayTarget.Community = Community -NicoRepoDisplayTarget.Mylist = Mylist - -NicoRepoItemTopic.Unknown = unknown -NicoRepoItemTopic.Live_Channel_Program_Onairs = Start live broadcasting (channel) -NicoRepoItemTopic.Live_Channel_Program_Reserve = Live Broadcast Reservation (Channel) -NicoRepoItemTopic.Live_User_Program_OnAirs = Start live broadcast (user) -NicoRepoItemTopic.Live_User_Program_Reserve = Live broadcast reservation (user) -NicoRepoItemTopic.NicoVideo_Channel_Blomaga_Upload = Buromaga Post -NicoRepoItemTopic.NicoVideo_Channel_Video_Upload = Channel Video Post -NicoRepoItemTopic.NicoVideo_Community_Level_Raise = Raising the community level -NicoRepoItemTopic.NicoVideo_User_Community_Video_Add = Register the video as a community -NicoRepoItemTopic.NicoVideo_User_Mylist_Add_Video = Add video to Mylist -NicoRepoItemTopic.NicoVideo_User_Video_Advertise = User video was advertised -NicoRepoItemTopic.NicoVideo_User_Video_Kiriban_Play = Number of plays -NicoRepoItemTopic.NicoVideo_User_Video_UpdateHighestRankings = Top ranking update -NicoRepoItemTopic.NicoVideo_User_Video_Upload = User video posting - -NicorepoNoItems = There is no Nirekopo that can be displayed - -NicoRepo_Video_UserVideoUpload = {0} posted a video -NicoRepo_Video_UserMylistAddVideo = {0} added a video to Mylist -NicoRepo_Video_CommunityAddVideo = Add video to {0} (community) -NicoRepo_Video_ChannelVideoUpload = {0} posted a video -NicoRepo_Live_UserProgramOnAirs = {0} starts live broadcast -NicoRepo_Live_UserProgramReserve = {0} booked live -NicoRepo_Live_ChannelProgramOnAirs = {0} starts live broadcast -NicoRepo_Live_ChannelProgramReserve = {0} reserves live broadcast +#### Followings Activity #### +FollowingsActivityDisplayOptions = New arrival display target +ActivityType.All = All +ActivityType.Video = Video posting +ActivityType.Live = Live broadcast starts +ActivityType.Publish = Content post + + +FollowingsActivityNoItems = There is no Nirekopo that can be displayed + LiveStreamingStartAtWithDateTime = {0} Start broadcasting diff --git a/Hohoema/Locales/ja-JP.txt b/Hohoema/Locales/ja-JP.txt index 812f9866..f0333d24 100644 --- a/Hohoema/Locales/ja-JP.txt +++ b/Hohoema/Locales/ja-JP.txt @@ -82,7 +82,7 @@ HohoemaPageType.FeedGroup = フィードグループ HohoemaPageType.FeedGroupManage = 新着動画 HohoemaPageType.FeedVideoList = フィードの動画一覧 HohoemaPageType.FollowManage = フォロー -HohoemaPageType.NicoRepo = ニコレポ +HohoemaPageType.FollowingsActivity = フォロー新着 HohoemaPageType.RankingCategory = カテゴリランキング HohoemaPageType.RankingCategoryList = ランキング一覧 HohoemaPageType.Recommend = オススメ動画 @@ -710,47 +710,16 @@ FollowInfoIsRequireLogIn = フォローを確認するにはログインして FollowerCount = フォロワー MylistVideoCountDesc = {0}件の動画 -#### Nicorepo #### -NicoRepoDisplayOptions = 表示条件 -NicoRepoType.All = すべて -NicoRepoType.Video = 動画投稿 -NicoRepoType.Program = 生放送開始 -NicoRepoType.Image = イラスト投稿 -NicoRepoType.ComicStory = マンガ投稿 -NicoRepoType.Article = 記事投稿 -NicoRepoType.Game = ゲーム -NicoRepoDisplayTarget.All = すべて -NicoRepoDisplayTarget.Self = 自分 -NicoRepoDisplayTarget.User = ユーザー -NicoRepoDisplayTarget.Channel = チャンネル -NicoRepoDisplayTarget.Community = コミュニティ -NicoRepoDisplayTarget.Mylist = マイリスト - -NicoRepoItemTopic.Unknown = 不明 -NicoRepoItemTopic.Live_Channel_Program_Onairs = 生放送開始(チャンネル) -NicoRepoItemTopic.Live_Channel_Program_Reserve = 生放送の予約(チャンネル) -NicoRepoItemTopic.Live_User_Program_OnAirs = 生放送開始(ユーザー) -NicoRepoItemTopic.Live_User_Program_Reserve = 生放送の予約(ユーザー) -NicoRepoItemTopic.NicoVideo_Channel_Blomaga_Upload = ブロマガ投稿 -NicoRepoItemTopic.NicoVideo_Channel_Video_Upload = チャンネルの動画投稿 -NicoRepoItemTopic.NicoVideo_Community_Level_Raise = コミュニティレベルの上昇 -NicoRepoItemTopic.NicoVideo_User_Community_Video_Add = 動画をコミュニティ登録 -NicoRepoItemTopic.NicoVideo_User_Mylist_Add_Video = 動画をマイリスト登録 -NicoRepoItemTopic.NicoVideo_User_Video_Advertise = ユーザー動画が広告された -NicoRepoItemTopic.NicoVideo_User_Video_Kiriban_Play = 再生数キリ番 -NicoRepoItemTopic.NicoVideo_User_Video_UpdateHighestRankings = ランキング最高順位更新 -NicoRepoItemTopic.NicoVideo_User_Video_Upload = ユーザーの動画投稿 - -NicorepoNoItems = 表示可能なニレコポがありません - -NicoRepo_Video_UserVideoUpload = {0} さんが動画を投稿 -NicoRepo_Video_UserMylistAddVideo = {0} さんがマイリストに動画を追加 -NicoRepo_Video_CommunityAddVideo = {0} (コミュニティ)に動画を追加 -NicoRepo_Video_ChannelVideoUpload = {0} が動画を投稿 -NicoRepo_Live_UserProgramOnAirs = {0} さんが生放送を開始 -NicoRepo_Live_UserProgramReserve = {0} さんが生放送を予約 -NicoRepo_Live_ChannelProgramOnAirs = {0} が生放送を開始 -NicoRepo_Live_ChannelProgramReserve = {0} が生放送を予約 +#### Followings Activity #### +FollowingsActivityDisplayOptions = 新着表示対象 +ActivityType.All = すべて +ActivityType.Video = 動画投稿 +ActivityType.Live = 生放送開始 +ActivityType.Publish = コンテンツ投稿 + + +FollowingsActivityNoItems = 表示可能な新着コンテンツがありません + LiveStreamingStartAtWithDateTime = {0} 放送開始 diff --git a/Hohoema/Locales/zh-CHS.txt b/Hohoema/Locales/zh-CHS.txt index 40a5e1d8..6b8d6072 100644 --- a/Hohoema/Locales/zh-CHS.txt +++ b/Hohoema/Locales/zh-CHS.txt @@ -82,7 +82,7 @@ HohoemaPageType.FeedGroup = Feed流群组 HohoemaPageType.FeedGroupManage = Mylist更新 HohoemaPageType.FeedVideoList = Feed流视频一览 HohoemaPageType.FollowManage = 关注 -HohoemaPageType.NicoRepo = Nico动态 +HohoemaPageType.FollowingsActivity = 关注新品 HohoemaPageType.RankingCategory = 分类排行 HohoemaPageType.RankingCategoryList = 排行一览 HohoemaPageType.Recommend = 推荐视频 @@ -710,47 +710,16 @@ FollowInfoIsRequireLogIn = 您需要登录才能查看关注信息 FollowerCount = 追随者 MylistVideoCountDesc = {0}个视频 -#### Nicorepo #### -NicoRepoDisplayOptions = 显示条件 -NicoRepoType.All = 所有 -NicoRepoType.Video = 影片发布 -NicoRepoType.Program = 直播开始 -NicoRepoType.Image = 发布插图 -NicoRepoType.ComicStory = 漫画贴 -NicoRepoType.Article = 文章发布 -NicoRepoType.Game = 游戏 -NicoRepoDisplayTarget.All = 所有 -NicoRepoDisplayTarget.Self = 我 -NicoRepoDisplayTarget.User = 用户 -NicoRepoDisplayTarget.Channel = 渠道 -NicoRepoDisplayTarget.Community = 社区 -NicoRepoDisplayTarget.Mylist = 我的列表 - -NicoRepoItemTopic.Unknown = 不明 -NicoRepoItemTopic.Live_Channel_Program_Onairs = 直播开始(频道) -NicoRepoItemTopic.Live_Channel_Program_Reserve = 直播预定(频道) -NicoRepoItemTopic.Live_User_Program_OnAirs = 直播开始(用户) -NicoRepoItemTopic.Live_User_Program_Reserve = 直播预定(用户) -NicoRepoItemTopic.NicoVideo_Channel_Blomaga_Upload = Blomaga邮政 -NicoRepoItemTopic.NicoVideo_Channel_Video_Upload = 频道视频发布 -NicoRepoItemTopic.NicoVideo_Community_Level_Raise = 社区水平上升 -NicoRepoItemTopic.NicoVideo_User_Community_Video_Add = 视频的社区注册 -NicoRepoItemTopic.NicoVideo_User_Mylist_Add_Video = 在我的列表中注册视频 -NicoRepoItemTopic.NicoVideo_User_Video_Advertise = 用户视频已发布 -NicoRepoItemTopic.NicoVideo_User_Video_Kiriban_Play = 播放编号 -NicoRepoItemTopic.NicoVideo_User_Video_UpdateHighestRankings = 排名最新 -NicoRepoItemTopic.NicoVideo_User_Video_Upload = 用户视频发布 - -NicorepoNoItems = 没有可显示的Nirekopo - -NicoRepo_Video_UserVideoUpload = {0}发布了一个视频 -NicoRepo_Video_UserMylistAddVideo = {0}已将视频添加到“我的列表”中 -NicoRepo_Video_CommunityAddVideo = 将视频添加到{0}(社区) -NicoRepo_Video_ChannelVideoUpload = {0}发布了一个视频 -NicoRepo_Live_UserProgramOnAirs = {0}已开始直播 -NicoRepo_Live_UserProgramReserve = {0}已预订直播 -NicoRepo_Live_ChannelProgramOnAirs = {0}已开始直播 -NicoRepo_Live_ChannelProgramReserve = {0}已预订直播 +#### Followings Activity #### +FollowingsActivityDisplayOptions = 新到货展示目标 +ActivityType.All = 全部 +ActivityType.Video = 视频发布 +ActivityType.Live = 直播开始 +ActivityType.Publish = 内容帖子 + + +FollowingsActivityNoItems = 没有可显示的Nirekopo + LiveStreamingStartAtWithDateTime = {0}广播开始 diff --git a/Hohoema/Package.appxmanifest b/Hohoema/Package.appxmanifest index 4bf68e32..6404a7f0 100644 --- a/Hohoema/Package.appxmanifest +++ b/Hohoema/Package.appxmanifest @@ -1,6 +1,6 @@  - + Hohoema diff --git a/Hohoema/Services/Player/Videos/VideoEndedRecommendation.cs b/Hohoema/Services/Player/Videos/VideoEndedRecommendation.cs index 4a4ae76a..293b99c4 100644 --- a/Hohoema/Services/Player/Videos/VideoEndedRecommendation.cs +++ b/Hohoema/Services/Player/Videos/VideoEndedRecommendation.cs @@ -7,7 +7,7 @@ using Hohoema.Models.Player; using Hohoema.Models.Player.Video; using Hohoema.Models.Playlist; -using NiconicoToolkit.NicoRepo; +using NiconicoToolkit.FollowingsActivity; using NiconicoToolkit.Video; using NiconicoToolkit.Video.Watch; using Reactive.Bindings; diff --git a/Hohoema/ViewModels/Niconico.Video/VideoListItemControlViewModel.cs b/Hohoema/ViewModels/Niconico.Video/VideoListItemControlViewModel.cs index c56b89b7..e4f50bf7 100644 --- a/Hohoema/ViewModels/Niconico.Video/VideoListItemControlViewModel.cs +++ b/Hohoema/ViewModels/Niconico.Video/VideoListItemControlViewModel.cs @@ -418,7 +418,7 @@ public string ProviderName - public string ProviderIconUrl { get; private set; } + public string ProviderIconUrl { get; protected set; } public OwnerType ProviderType { get; init; } diff --git a/Hohoema/ViewModels/PrimaryWindowCoreLayout/LiveMenuSubPageContent.cs b/Hohoema/ViewModels/PrimaryWindowCoreLayout/LiveMenuSubPageContent.cs index 89b6691f..6034cf89 100644 --- a/Hohoema/ViewModels/PrimaryWindowCoreLayout/LiveMenuSubPageContent.cs +++ b/Hohoema/ViewModels/PrimaryWindowCoreLayout/LiveMenuSubPageContent.cs @@ -32,7 +32,7 @@ private void ResetItems() if (NiconicoSession.IsLoggedIn) { MenuItems.Add(new NavigateAwareMenuItemViewModel(HohoemaPageType.Timeshift.Translate(), HohoemaPageType.Timeshift)); - MenuItems.Add(new NavigateAwareMenuItemViewModel(HohoemaPageType.NicoRepo.Translate(), HohoemaPageType.NicoRepo)); + MenuItems.Add(new NavigateAwareMenuItemViewModel(HohoemaPageType.FollowingsActivity.Translate(), HohoemaPageType.FollowingsActivity)); MenuItems.Add(new NavigateAwareMenuItemViewModel(HohoemaPageType.FollowManage.Translate(), HohoemaPageType.FollowManage)); } diff --git a/Hohoema/ViewModels/PrimaryWindowCoreLayout/VideoMenuSubPageContent.cs b/Hohoema/ViewModels/PrimaryWindowCoreLayout/VideoMenuSubPageContent.cs index 9674248c..6e448882 100644 --- a/Hohoema/ViewModels/PrimaryWindowCoreLayout/VideoMenuSubPageContent.cs +++ b/Hohoema/ViewModels/PrimaryWindowCoreLayout/VideoMenuSubPageContent.cs @@ -60,7 +60,7 @@ private void ResetMenuItems() if (NiconicoSession.IsLoggedIn) { MenuItems.Add(new NavigateAwareMenuItemViewModel(HohoemaPageType.RankingCategoryList.Translate(), HohoemaPageType.RankingCategoryList)); - MenuItems.Add(new NavigateAwareMenuItemViewModel(HohoemaPageType.NicoRepo.Translate(), HohoemaPageType.NicoRepo)); + MenuItems.Add(new NavigateAwareMenuItemViewModel(HohoemaPageType.FollowingsActivity.Translate(), HohoemaPageType.FollowingsActivity)); MenuItems.Add(new NavigateAwareMenuItemViewModel(HohoemaPageType.FollowManage.Translate(), HohoemaPageType.FollowManage)); MenuItems.Add(new NavigateAwareMenuItemViewModel(HohoemaPageType.WatchHistory.Translate(), HohoemaPageType.WatchHistory)); MenuItems.Add(new SeparatorMenuItemViewModel()); diff --git a/Hohoema/Views.Hohoema/Subscription/EditSubscriptionGroupDialog.xaml.cs b/Hohoema/Views.Hohoema/Subscription/EditSubscriptionGroupDialog.xaml.cs index ef6a99f6..2b7459ed 100644 --- a/Hohoema/Views.Hohoema/Subscription/EditSubscriptionGroupDialog.xaml.cs +++ b/Hohoema/Views.Hohoema/Subscription/EditSubscriptionGroupDialog.xaml.cs @@ -1,6 +1,6 @@ #nullable enable using Hohoema.Contracts.Subscriptions; -using NiconicoToolkit.NicoRepo; +using NiconicoToolkit.FollowingsActivity; using System; using System.Collections.Generic; using System.IO; diff --git a/Hohoema/Views.Niconico/NicoRepo/NicoRepoPage.xaml b/Hohoema/Views.Niconico/FollowingsActivity/FollowingsActivityPage.xaml similarity index 65% rename from Hohoema/Views.Niconico/NicoRepo/NicoRepoPage.xaml rename to Hohoema/Views.Niconico/FollowingsActivity/FollowingsActivityPage.xaml index b81bde41..e68c30bd 100644 --- a/Hohoema/Views.Niconico/NicoRepo/NicoRepoPage.xaml +++ b/Hohoema/Views.Niconico/FollowingsActivity/FollowingsActivityPage.xaml @@ -1,10 +1,10 @@  - + - - + + - + + + + + + + + - + - - - + + + - - - - - + + + + + + + - + - - + + @@ -83,14 +108,14 @@ - - + + @@ -116,20 +141,19 @@ - - - : + + + - - - - - - - + + + @@ -149,10 +173,13 @@ + + + - /// それ自体で使用できる空白ページまたはフレーム内に移動できる空白ページ。 /// -public sealed partial class NicoRepoPage : Page +public sealed partial class FollowingsActivityPage : Page { public double ScrollPosition @@ -26,7 +27,7 @@ public double ScrollPosition // Using a DependencyProperty as the backing store for ScrollPosition. This enables animation, styling, binding, etc... public static readonly DependencyProperty ScrollPositionProperty = - DependencyProperty.Register("ScrollPosition", typeof(double), typeof(NicoRepoPage), new PropertyMetadata(0.0)); + DependencyProperty.Register("ScrollPosition", typeof(double), typeof(FollowingsActivityPage), new PropertyMetadata(0.0)); public void ResetScrollPosition() @@ -37,17 +38,17 @@ public void ResetScrollPosition() - public NicoRepoPage() + public FollowingsActivityPage() { this.InitializeComponent(); - DataContext = _vm = Ioc.Default.GetRequiredService(); + DataContext = _vm = Ioc.Default.GetRequiredService(); _layoutManager = Ioc.Default.GetRequiredService(); _appearanceSettings = Ioc.Default.GetRequiredService(); - Loaded += NicoRepoPage_Loaded; + Loaded += FollowingsActivityPage_Loaded; } - private void NicoRepoPage_Loaded(object sender, RoutedEventArgs e) + private void FollowingsActivityPage_Loaded(object sender, RoutedEventArgs e) { if ((_layoutManager.IsMouseInteractionDefault || _layoutManager.IsTouchInteractionDefault) && _appearanceSettings.IsVideoListItemDoubleClickOrDoubleTapToPlayEnabled @@ -70,28 +71,33 @@ private void NicoRepoPage_Loaded(object sender, RoutedEventArgs e) private void ItemsList_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { if (e.OriginalSource is FrameworkElement fe - && _vm.OpenNicoRepoItemCommand.CanExecute(fe.DataContext)) + && _vm.OpenFollowingsActivityItemCommand.CanExecute(fe.DataContext)) { - _vm.OpenNicoRepoItemCommand.Execute(fe.DataContext); + _vm.OpenFollowingsActivityItemCommand.Execute(fe.DataContext); e.Handled = true; } } private void ItemsList_ItemClick(object sender, ItemClickEventArgs e) { - if (_vm.OpenNicoRepoItemCommand.CanExecute(e.ClickedItem)) + if (_vm.OpenFollowingsActivityItemCommand.CanExecute(e.ClickedItem)) { - _vm.OpenNicoRepoItemCommand.Execute(e.ClickedItem); + _vm.OpenFollowingsActivityItemCommand.Execute(e.ClickedItem); } } - private readonly NicoRepoPageViewModel _vm; + private readonly FollowingsActivityPageViewModel _vm; private readonly ApplicationLayoutManager _layoutManager; private readonly AppearanceSettings _appearanceSettings; + + private void ActivityTypeSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + _vm.SelectedActivityType = (ActivityType)e.AddedItems[0]; + } } -public sealed class NicoRepoTimelineItemTemplateSelector : DataTemplateSelector +public sealed class FollowingsActivityTimelineItemTemplateSelector : DataTemplateSelector { public DataTemplate VideoItem { get; set; } public DataTemplate LiveItem { get; set; } @@ -105,8 +111,8 @@ protected override DataTemplate SelectTemplateCore(object item, DependencyObject { return item switch { - NicoRepoVideoTimeline => VideoItem, - NicoRepoLiveTimeline => LiveItem, + FollowingsActivityVideoTimeline => VideoItem, + FollowingsActivityLiveTimeline => LiveItem, _ => throw new NotSupportedException(), }; } diff --git a/Hohoema/Views.Niconico/FollowingsActivity/FollowingsActivityPageViewModel.cs b/Hohoema/Views.Niconico/FollowingsActivity/FollowingsActivityPageViewModel.cs new file mode 100644 index 00000000..2f8b5267 --- /dev/null +++ b/Hohoema/Views.Niconico/FollowingsActivity/FollowingsActivityPageViewModel.cs @@ -0,0 +1,477 @@ +#nullable enable +using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Messaging; +using Hohoema.Contracts.Playlist; +using Hohoema.Models.Niconico.Live; +using Hohoema.Models.Niconico.Video; +using Hohoema.Models.Playlist; +using Hohoema.Models.Subscriptions; +using Hohoema.Services; +using Hohoema.Services.VideoCache.Events; +using Hohoema.ViewModels.Niconico.Live; +using Hohoema.ViewModels.Niconico.Video.Commands; +using Hohoema.ViewModels.VideoListPage; +using I18NPortable; +using Microsoft.Extensions.Logging; +using Microsoft.Toolkit.Collections; +using NiconicoToolkit.Live; +using NiconicoToolkit.FollowingsActivity; +using NiconicoToolkit.Video; +using Reactive.Bindings; +using Reactive.Bindings.Extensions; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Reactive.Concurrency; +using System.Reactive.Linq; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Input; +using Windows.UI.Xaml.Navigation; +using CommunityToolkit.Mvvm.ComponentModel; +using NiconicoToolkit; +using Hohoema.Models.Niconico; +using System.Diagnostics; + +namespace Hohoema.ViewModels.Pages.Niconico.FollowingsActivity; + +public sealed partial class FollowingsActivityPageViewModel + : HohoemaListingPageViewModelBase + , IRecipient + , IRecipient + , IRecipient + , IRecipient + , IRecipient +{ + private readonly IMessenger _messenger; + private readonly NiconicoSession _niconicoSession; + private readonly NicoVideoProvider _nicoVideoProvider; + private readonly OpenLiveContentCommand _openLiveContentCommand; + public ApplicationLayoutManager ApplicationLayoutManager { get; } + public SubscriptionManager SubscriptionManager { get; } + public VideoPlayWithQueueCommand VideoPlayWithQueueCommand { get; } + + + bool _FollowingsActivityMuteContextTriggersChanged; + + public ImmutableArray FollowingsActivityTypeList { get; } = new[] + { + ActivityType.Publish, + ActivityType.Video, + ActivityType.Live, + ActivityType.All, + } + .ToImmutableArray(); + + [ObservableProperty] + ActivityType _selectedActivityType; + + partial void OnSelectedActivityTypeChanged(ActivityType value) + { + ResetList(); + } + + [ObservableProperty] + NiconicoActivityActor? _selectedActor; + + partial void OnSelectedActorChanged(NiconicoActivityActor? value) + { + ResetList(); + } + + public FollowingsActivityPageViewModel( + IMessenger messenger, + ILoggerFactory loggerFactory, + NiconicoSession niconicoSession, + ApplicationLayoutManager applicationLayoutManager, + NicoVideoProvider nicoVideoProvider, + SubscriptionManager subscriptionManager, + OpenLiveContentCommand openLiveContentCommand, + VideoPlayWithQueueCommand videoPlayWithQueueCommand + ) + : base(loggerFactory.CreateLogger(), disposeItemVM: false) + { + _messenger = messenger; + _niconicoSession = niconicoSession; + ApplicationLayoutManager = applicationLayoutManager; + _nicoVideoProvider = nicoVideoProvider; + SubscriptionManager = subscriptionManager; + _openLiveContentCommand = openLiveContentCommand; + VideoPlayWithQueueCommand = videoPlayWithQueueCommand; + } + + + public override void OnNavigatedTo(INavigationParameters parameters) + { + if (parameters.TryGetValue("type", out string showType)) + { + SelectedActivityType = Enum.Parse(showType); + } + else + { + SelectedActivityType = ActivityType.Publish; + } + + _messenger.Register(this); + _messenger.Register(this); + _messenger.Register(this); + _messenger.Register(this); + _messenger.Register(this); + + try + { + base.OnNavigatedTo(parameters); + } + catch + { + _messenger.Unregister(this); + _messenger.Unregister(this); + _messenger.Unregister(this); + _messenger.Unregister(this); + _messenger.Unregister(this); + + throw; + } + } + + public override void OnNavigatedFrom(INavigationParameters parameters) + { + _messenger.Unregister(this); + _messenger.Unregister(this); + _messenger.Unregister(this); + _messenger.Unregister(this); + _messenger.Unregister(this); + + // ニレコポ表示設定をニコレポの設定に書き戻し + // ActivityFeedSettings.DisplayFollowingsActivityMuteContextTriggers = DisplayFollowingsActivityMuteContextTriggers.Distinct().ToList(); + + base.OnNavigatedFrom(parameters); + } + + protected override bool CheckNeedUpdateOnNavigateTo(NavigationMode mode, INavigationParameters parameters) + { + /* + if (!ActivityFeedSettings.DisplayFollowingsActivityMuteContextTriggers.All(x => DisplayFollowingsActivityMuteContextTriggers.Any(y => x == y))) + { + DisplayFollowingsActivityMuteContextTriggers.Clear(); + DisplayFollowingsActivityMuteContextTriggers.AddRange(ActivityFeedSettings.DisplayFollowingsActivityMuteContextTriggers); + + _FollowingsActivityMuteContextTriggersChanged = false; + return true; + } + */ + + return base.CheckNeedUpdateOnNavigateTo(mode, parameters); + } + + protected override (int, IIncrementalSource) GenerateIncrementalSource() + { + return (LoginUserFollowingsActivityTimelineSource.OneTimeLoadCount, + new LoginUserFollowingsActivityTimelineSource(_niconicoSession, _nicoVideoProvider, SubscriptionManager, SelectedActivityType, SelectedActor) + ); + } + + + static IEnumerable ToVideoItemVMEnumerable(IEnumerable items) + { + foreach (var item in items) + { + if (item is VideoItemViewModel videoItemVM) + { + yield return videoItemVM; + } + } + } + + void IRecipient.Receive(VideoWatchedMessage message) + { + if (ItemsView == null) { return; } + foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) + { + videoItemVM.OnWatched(message); + } + } + + void IRecipient.Receive(PlaylistItemAddedMessage message) + { + if (ItemsView == null) { return; } + foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) + { + videoItemVM.OnPlaylistItemAdded(message); + } + } + + void IRecipient.Receive(PlaylistItemRemovedMessage message) + { + if (ItemsView == null) { return; } + foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) + { + videoItemVM.OnPlaylistItemRemoved(message); + } + } + + void IRecipient.Receive(ItemIndexUpdatedMessage message) + { + if (ItemsView == null) { return; } + foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) + { + videoItemVM.OnQueueItemIndexUpdated(message); + } + } + + void IRecipient.Receive(VideoCacheStatusChangedMessage message) + { + if (ItemsView == null) { return; } + foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) + { + videoItemVM.OnCacheStatusChanged(message); + } + } + + + [RelayCommand] + void OpenFollowingsActivityItem(object item) + { + if (item is FollowingsActivityVideoTimeline videoItem) + { + var command = VideoPlayWithQueueCommand as ICommand; + if (command.CanExecute(videoItem)) + { + command.Execute(videoItem); + } + } + else if (item is FollowingsActivityLiveTimeline liveItem) + { + var command = _openLiveContentCommand as ICommand; + if (command.CanExecute(liveItem)) + { + command.Execute(liveItem); + } + } + } +} + + +public class FollowingsActivityLiveTimeline : LiveInfoListItemViewModel, ILiveContent, IFollowingsActivityItem +{ + public NiconicoToolkit.FollowingsActivity.Activity Activity { get; } + + public string OptionText { get; } + + public string Title { get; } + + public FollowingsActivityLiveTimeline(NiconicoToolkit.FollowingsActivity.Activity activity) + : base(activity.Content.Id) + { + Activity = activity; + ItemTopic = activity.Kind; + LiveTitle = activity.Content.Title; + StartTime = activity.CreatedAt; + + OptionText = "LiveStreamingStartAtWithDateTime".Translate(Activity.Content.StartedAt.ToString("f")); + + Title = Activity.Label.Text; + ThumbnailUrl = Activity.ThumbnailUrl; + CommunityThumbnail = Activity.Actor.IconUrl; + CommunityGlobalId = Activity.Actor.Id; + CommunityName = Activity.Actor.Name; + + ItempTopicDescription = Activity.Message.Text; + } + + public string ItempTopicDescription { get; } + + public string ItemTopic { get; } + + public string BroadcasterId => CommunityGlobalId.ToString(); +} + +public interface IFollowingsActivityItem +{ + string ItemTopic { get; } +} + +public class FollowingsActivityVideoTimeline : VideoListItemControlViewModel, IVideoContent, IFollowingsActivityItem +{ + private readonly NiconicoToolkit.FollowingsActivity.Activity _activity; + + public FollowingsActivityVideoTimeline(NiconicoToolkit.FollowingsActivity.Activity activity) + : base(activity.Content.Id, activity.Content.Title, activity.ThumbnailUrl, TimeSpan.Zero, activity.Content.StartedAt) + { + _activity = activity; + ItemTopic = activity.Kind; + + ProviderName = activity.Actor.Name; + ProviderId = activity.Actor.Id; + ProviderType = activity.Actor.Type switch + { + NiconicoToolkit.FollowingsActivity.Actor.ActorType_User => OwnerType.User, + NiconicoToolkit.FollowingsActivity.Actor.ActorType_Channel => OwnerType.Channel, + }; + ProviderIconUrl = activity.Actor.IconUrl; + + ItempTopicDescription = _activity.Message.Text; + } + + public string ItempTopicDescription { get; } + + public string ItemTopic { get; private set; } +} + + +public static class FollowingsActivityTimelineVM +{ + + //public static string ItemTopictypeToDescription(FollowingsActivityMuteContextTrigger topicType, FollowingsActivityEntry timelineItem) + //{ + // switch (topicType) + // { + // case FollowingsActivityMuteContextTrigger.Unknown: + // return "Unknown".Translate(); + // case FollowingsActivityMuteContextTrigger.NicoVideo_User_Video_Upload: + // return "FollowingsActivity_Video_UserVideoUpload".Translate(timelineItem.Actor.Name); + // case FollowingsActivityMuteContextTrigger.NicoVideo_User_Mylist_Add_Video: + // return "FollowingsActivity_Video_UserMylistAddVideo".Translate(timelineItem.Actor.Name); + // case FollowingsActivityMuteContextTrigger.NicoVideo_User_Community_Video_Add: + // return "FollowingsActivity_Video_CommunityAddVideo".Translate(timelineItem.Actor.Name); + // case FollowingsActivityMuteContextTrigger.NicoVideo_Channel_Video_Upload: + // return "FollowingsActivity_Video_ChannelVideoUpload".Translate(timelineItem.Actor.Name); + // case FollowingsActivityMuteContextTrigger.Live_User_Program_OnAirs: + // return "FollowingsActivity_Live_UserProgramOnAirs".Translate(timelineItem.Actor.Name); + // case FollowingsActivityMuteContextTrigger.Live_User_Program_Reserve: + // return "FollowingsActivity_Live_UserProgramReserve".Translate(timelineItem.Actor.Name); + // case FollowingsActivityMuteContextTrigger.Live_Channel_Program_Onairs: + // return "FollowingsActivity_Live_ChannelProgramOnAirs".Translate(timelineItem.Actor.Name); + // case FollowingsActivityMuteContextTrigger.Live_Channel_Program_Reserve: + // return "FollowingsActivity_Live_ChannelProgramReserve".Translate(timelineItem.Actor.Name); + // default: + // return string.Empty; + // } + //} + + + /* + private string _OwnerUserId; + public string ProviderId => _OwnerUserId; + + public string ProviderName { get; private set; } + + public UserType ProviderType { get; private set; } + + public string Id => TimelineItem.Video?.Id ?? TimelineItem.Program.Id; + */ +} + + +public class LoginUserFollowingsActivityTimelineSource : IIncrementalSource +{ + // 通常10だが、ニコレポの表示フィルタを掛けた場合に + // 追加読み込み時に表示対象が見つからない場合 + // 追加読み込みが途絶えるため、多めに設定している + public const int OneTimeLoadCount = 25; + + public SubscriptionManager SubscriptionManager { get; } + public ActivityType ActivityType { get; } + public NiconicoActivityActor? ActivityActor { get; } + + public LoginUserFollowingsActivityTimelineSource( + NiconicoSession niconicoSession, + NicoVideoProvider nicoVideoProvider, + SubscriptionManager subscriptionManager, + ActivityType activityType, + NiconicoActivityActor? activityActor + ) + { + _niconicoSession = niconicoSession; + _nicoVideoProvider = nicoVideoProvider; + SubscriptionManager = subscriptionManager; + ActivityType = activityType; + ActivityActor = activityActor; + } + + DateTime NiconamaDisplayTime = DateTime.Now - TimeSpan.FromHours(6); + private readonly NiconicoContext _niconicoContext; + private readonly NiconicoSession _niconicoSession; + private readonly NicoVideoProvider _nicoVideoProvider; + + FollowingsActivityResponse _prevRes; + + //public static bool IsLiveTopic(FollowingsActivityMuteContextTrigger topic) + //{ + // return topic + // is FollowingsActivityMuteContextTrigger.Live_User_Program_OnAirs + // or FollowingsActivityMuteContextTrigger.Live_User_Program_Reserve + // or FollowingsActivityMuteContextTrigger.Live_Channel_Program_Onairs + // or FollowingsActivityMuteContextTrigger.Live_Channel_Program_Reserve + // ; + //} + + //public static bool IsVideoTopic(FollowingsActivityMuteContextTrigger topic) + //{ + // return topic + // is FollowingsActivityMuteContextTrigger.NicoVideo_User_Video_Upload + // or FollowingsActivityMuteContextTrigger.NicoVideo_User_Mylist_Add_Video + // or FollowingsActivityMuteContextTrigger.NicoVideo_Channel_Video_Upload + // ; + //} + + async Task> IIncrementalSource.GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken ct) + { + if (_prevRes != null && _prevRes.NextCursor == null) + { + return []; + } + + var res = await _niconicoSession.ToolkitContext.FollowingsActivity.GetFollowingsActivityAsync(ActivityType, ActivityActor, _prevRes?.NextCursor, ct); + + ct.ThrowIfCancellationRequested(); + + if (res.IsOk is false) { return Enumerable.Empty(); } + + _prevRes = res; +#if DEBUG + List triggers = new List(); +#endif + + Debug.WriteLine(string.Join(" / ", res.Activities.Select(X => X.Kind).Distinct())); + + return res.Activities.Select(item => + { + try + { + if (item.Content.Type == Content.ContentType_LiveProgram) + { + return new FollowingsActivityLiveTimeline(item) as IFollowingsActivityItem; + } + else if (item.Content.Type == Content.ContentType_Video) + { + return new FollowingsActivityVideoTimeline(item) as IFollowingsActivityItem; + } + else + { + return null; + } + } + catch + { + return null; + } + }) + .Where(x => x != null) + .ToArray()// Note: IncrementalLoadingSourceが複数回呼び出すためFreezeしたい + ; + +#if DEBUG + //Debug.WriteLine(string.Join(" ", triggers)); +#endif + } +} + + + +//public class SelectableFollowingsActivityMuteContextTrigger +//{ +// public FollowingsActivityMuteContextTrigger Topic { get; set; } +//} diff --git a/Hohoema/Views.Niconico/NicoRepo/NicoRepoPageViewModel.cs b/Hohoema/Views.Niconico/NicoRepo/NicoRepoPageViewModel.cs deleted file mode 100644 index cab80212..00000000 --- a/Hohoema/Views.Niconico/NicoRepo/NicoRepoPageViewModel.cs +++ /dev/null @@ -1,507 +0,0 @@ -#nullable enable -using CommunityToolkit.Mvvm.Input; -using CommunityToolkit.Mvvm.Messaging; -using Hohoema.Contracts.Playlist; -using Hohoema.Models.Niconico.Live; -using Hohoema.Models.Niconico.NicoRepo; -using Hohoema.Models.Niconico.NicoRepo.LoginUser; -using Hohoema.Models.Niconico.Video; -using Hohoema.Models.Playlist; -using Hohoema.Models.Subscriptions; -using Hohoema.Services; -using Hohoema.Services.VideoCache.Events; -using Hohoema.ViewModels.Niconico.Live; -using Hohoema.ViewModels.Niconico.Video.Commands; -using Hohoema.ViewModels.VideoListPage; -using I18NPortable; -using Microsoft.Extensions.Logging; -using Microsoft.Toolkit.Collections; -using NiconicoToolkit.Live; -using NiconicoToolkit.NicoRepo; -using NiconicoToolkit.Video; -using Reactive.Bindings; -using Reactive.Bindings.Extensions; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Reactive.Concurrency; -using System.Reactive.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Input; -using Windows.UI.Xaml.Navigation; - -namespace Hohoema.ViewModels.Pages.Niconico.NicoRepo; - -public sealed partial class NicoRepoPageViewModel - : HohoemaListingPageViewModelBase - , IRecipient - , IRecipient - , IRecipient - , IRecipient - , IRecipient -{ - private readonly IMessenger _messenger; - private readonly NicoVideoProvider _nicoVideoProvider; - private readonly OpenLiveContentCommand _openLiveContentCommand; - public ApplicationLayoutManager ApplicationLayoutManager { get; } - public NicoRepoSettings ActivityFeedSettings { get; } - public LoginUserNicoRepoProvider LoginUserNicoRepoProvider { get; } - public SubscriptionManager SubscriptionManager { get; } - public VideoPlayWithQueueCommand VideoPlayWithQueueCommand { get; } - - - bool _NicoRepoMuteContextTriggersChanged; - - public ImmutableArray NicoRepoTypeList { get; } = new[] - { - NiconicoToolkit.NicoRepo.NicoRepoType.All, - NiconicoToolkit.NicoRepo.NicoRepoType.Video, - NiconicoToolkit.NicoRepo.NicoRepoType.Program, - } - .ToImmutableArray(); - - public ReactiveProperty NicoRepoType { get; } - public ReactiveProperty NicoRepoDisplayTarget { get; } - - - public NicoRepoPageViewModel( - IMessenger messenger, - ILoggerFactory loggerFactory, - ApplicationLayoutManager applicationLayoutManager, - NicoVideoProvider nicoVideoProvider, - NicoRepoSettings activityFeedSettings, - LoginUserNicoRepoProvider loginUserNicoRepoProvider, - SubscriptionManager subscriptionManager, - OpenLiveContentCommand openLiveContentCommand, - VideoPlayWithQueueCommand videoPlayWithQueueCommand - ) - : base(loggerFactory.CreateLogger(), disposeItemVM: false) - { - _messenger = messenger; - ApplicationLayoutManager = applicationLayoutManager; - _nicoVideoProvider = nicoVideoProvider; - ActivityFeedSettings = activityFeedSettings; - LoginUserNicoRepoProvider = loginUserNicoRepoProvider; - SubscriptionManager = subscriptionManager; - _openLiveContentCommand = openLiveContentCommand; - VideoPlayWithQueueCommand = videoPlayWithQueueCommand; - NicoRepoType = new ReactiveProperty(NiconicoToolkit.NicoRepo.NicoRepoType.Video, mode:ReactivePropertyMode.DistinctUntilChanged); - NicoRepoDisplayTarget = new ReactiveProperty(mode: ReactivePropertyMode.DistinctUntilChanged); - - new[] - { - NicoRepoType.ToUnit(), - NicoRepoDisplayTarget.ToUnit() - } - .Merge() - .Subscribe(_ => - { - ResetList(); - }) - .AddTo(_CompositeDisposable); - } - - - public override void OnNavigatedTo(INavigationParameters parameters) - { - if (parameters.TryGetValue("type", out string showType)) - { - NicoRepoType.Value = Enum.Parse(showType); - } - - _messenger.Register(this); - _messenger.Register(this); - _messenger.Register(this); - _messenger.Register(this); - _messenger.Register(this); - - try - { - base.OnNavigatedTo(parameters); - } - catch - { - _messenger.Unregister(this); - _messenger.Unregister(this); - _messenger.Unregister(this); - _messenger.Unregister(this); - _messenger.Unregister(this); - - throw; - } - } - - public override void OnNavigatedFrom(INavigationParameters parameters) - { - _messenger.Unregister(this); - _messenger.Unregister(this); - _messenger.Unregister(this); - _messenger.Unregister(this); - _messenger.Unregister(this); - - // ニレコポ表示設定をニコレポの設定に書き戻し - // ActivityFeedSettings.DisplayNicoRepoMuteContextTriggers = DisplayNicoRepoMuteContextTriggers.Distinct().ToList(); - - base.OnNavigatedFrom(parameters); - } - - protected override bool CheckNeedUpdateOnNavigateTo(NavigationMode mode, INavigationParameters parameters) - { - /* - if (!ActivityFeedSettings.DisplayNicoRepoMuteContextTriggers.All(x => DisplayNicoRepoMuteContextTriggers.Any(y => x == y))) - { - DisplayNicoRepoMuteContextTriggers.Clear(); - DisplayNicoRepoMuteContextTriggers.AddRange(ActivityFeedSettings.DisplayNicoRepoMuteContextTriggers); - - _NicoRepoMuteContextTriggersChanged = false; - return true; - } - */ - - return base.CheckNeedUpdateOnNavigateTo(mode, parameters); - } - - protected override (int, IIncrementalSource) GenerateIncrementalSource() - { - return (LoginUserNicoRepoTimelineSource.OneTimeLoadCount, new LoginUserNicoRepoTimelineSource(LoginUserNicoRepoProvider, _nicoVideoProvider, SubscriptionManager, NicoRepoType.Value, NicoRepoDisplayTarget.Value)); - } - - - static IEnumerable ToVideoItemVMEnumerable(IEnumerable items) - { - foreach (var item in items) - { - if (item is VideoItemViewModel videoItemVM) - { - yield return videoItemVM; - } - } - } - - void IRecipient.Receive(VideoWatchedMessage message) - { - if (ItemsView == null) { return; } - foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) - { - videoItemVM.OnWatched(message); - } - } - - void IRecipient.Receive(PlaylistItemAddedMessage message) - { - if (ItemsView == null) { return; } - foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) - { - videoItemVM.OnPlaylistItemAdded(message); - } - } - - void IRecipient.Receive(PlaylistItemRemovedMessage message) - { - if (ItemsView == null) { return; } - foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) - { - videoItemVM.OnPlaylistItemRemoved(message); - } - } - - void IRecipient.Receive(ItemIndexUpdatedMessage message) - { - if (ItemsView == null) { return; } - foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) - { - videoItemVM.OnQueueItemIndexUpdated(message); - } - } - - void IRecipient.Receive(VideoCacheStatusChangedMessage message) - { - if (ItemsView == null) { return; } - foreach (var videoItemVM in ToVideoItemVMEnumerable(ItemsView.SourceCollection)) - { - videoItemVM.OnCacheStatusChanged(message); - } - } - - - [RelayCommand] - void OpenNicoRepoItem(object item) - { - if (item is NicoRepoVideoTimeline videoItem) - { - var command = VideoPlayWithQueueCommand as ICommand; - if (command.CanExecute(videoItem)) - { - command.Execute(videoItem); - } - } - else if (item is NicoRepoLiveTimeline liveItem) - { - var command = _openLiveContentCommand as ICommand; - if (command.CanExecute(liveItem)) - { - command.Execute(liveItem); - } - } - } -} - - -public class NicoRepoLiveTimeline : LiveInfoListItemViewModel, ILiveContent, INicoRepoItem -{ - private readonly NicoRepoEntry _nicoRepoEntry; - - public string OptionText { get; } - - public string Title { get; } - - public NicoRepoLiveTimeline(NicoRepoEntry nicoRepoEntry, NicoRepoMuteContextTrigger itemTopic) - : base(nicoRepoEntry.GetContentId()) - { - _nicoRepoEntry = nicoRepoEntry; - ItemTopic = itemTopic; - LiveTitle = nicoRepoEntry.Object.Name; - StartTime = _nicoRepoEntry.Updated.LocalDateTime; - - OptionText = "LiveStreamingStartAtWithDateTime".Translate(_nicoRepoEntry.Updated.ToString("f")); - - Title = _nicoRepoEntry.Title; - ThumbnailUrl = _nicoRepoEntry.Object.Image.OriginalString; - CommunityThumbnail = _nicoRepoEntry.Actor.Icon.OriginalString; - CommunityGlobalId = _nicoRepoEntry.MuteContext.Sender.Id; - CommunityName = _nicoRepoEntry.Actor.Name; - - this.CommunityType = _nicoRepoEntry.MuteContext.Sender.IdType switch - { - SenderIdTypeEnum.User => ProviderType.Community, - SenderIdTypeEnum.Channel => ProviderType.Channel, - _ => throw new NotSupportedException() - }; - - ItempTopicDescription = NicoRepoTimelineVM.ItemTopictypeToDescription(ItemTopic, _nicoRepoEntry); - } - - public string ItempTopicDescription { get; } - - public NicoRepoMuteContextTrigger ItemTopic { get; private set; } - - public string BroadcasterId => CommunityGlobalId.ToString(); -} - -public interface INicoRepoItem -{ - NicoRepoMuteContextTrigger ItemTopic { get; } -} - -public class NicoRepoVideoTimeline : VideoListItemControlViewModel, IVideoContent, INicoRepoItem -{ - private readonly NicoRepoEntry _nicoRepoEntry; - - public NicoRepoVideoTimeline(NicoRepoEntry nicoRepoEntry, NicoRepoMuteContextTrigger itemType) - : base(nicoRepoEntry.GetContentId(), nicoRepoEntry.Object.Name, nicoRepoEntry.Object.Image.OriginalString, TimeSpan.Zero, nicoRepoEntry.Updated.DateTime) - { - _nicoRepoEntry = nicoRepoEntry; - ItemTopic = itemType; - - if (_nicoRepoEntry.Actor != null) - { - if (_nicoRepoEntry.Actor.Url.OriginalString.StartsWith("https://ch.nicovideo.jp/")) - { - - // チャンネル - ProviderName = _nicoRepoEntry.Actor.Name; - - try - { - var iconFileName = _nicoRepoEntry.Actor.Icon.Segments.Last(); - ProviderId = new String(iconFileName.TakeWhile(c => c != '.').ToArray()); - } - catch - { - ProviderId = _nicoRepoEntry.Actor.Url.Segments.Last(); - } - - ProviderType = OwnerType.Channel; - } - else - { - ProviderName = _nicoRepoEntry.Actor.Name; - ProviderId = _nicoRepoEntry.Actor.Url.Segments.Last(); - ProviderType = OwnerType.User; - } - } - - //SetLength(nicoVideo.Length); - ItempTopicDescription = NicoRepoTimelineVM.ItemTopictypeToDescription(ItemTopic, _nicoRepoEntry); - } - - public string ItempTopicDescription { get; } - - public NicoRepoMuteContextTrigger ItemTopic { get; private set; } -} - - -public static class NicoRepoTimelineVM -{ - - public static string ItemTopictypeToDescription(NicoRepoMuteContextTrigger topicType, NicoRepoEntry timelineItem) - { - switch (topicType) - { - case NicoRepoMuteContextTrigger.Unknown: - return "Unknown".Translate(); - case NicoRepoMuteContextTrigger.NicoVideo_User_Video_Upload: - return "NicoRepo_Video_UserVideoUpload".Translate(timelineItem.Actor.Name); - case NicoRepoMuteContextTrigger.NicoVideo_User_Mylist_Add_Video: - return "NicoRepo_Video_UserMylistAddVideo".Translate(timelineItem.Actor.Name); - case NicoRepoMuteContextTrigger.NicoVideo_User_Community_Video_Add: - return "NicoRepo_Video_CommunityAddVideo".Translate(timelineItem.Actor.Name); - case NicoRepoMuteContextTrigger.NicoVideo_Channel_Video_Upload: - return "NicoRepo_Video_ChannelVideoUpload".Translate(timelineItem.Actor.Name); - case NicoRepoMuteContextTrigger.Live_User_Program_OnAirs: - return "NicoRepo_Live_UserProgramOnAirs".Translate(timelineItem.Actor.Name); - case NicoRepoMuteContextTrigger.Live_User_Program_Reserve: - return "NicoRepo_Live_UserProgramReserve".Translate(timelineItem.Actor.Name); - case NicoRepoMuteContextTrigger.Live_Channel_Program_Onairs: - return "NicoRepo_Live_ChannelProgramOnAirs".Translate(timelineItem.Actor.Name); - case NicoRepoMuteContextTrigger.Live_Channel_Program_Reserve: - return "NicoRepo_Live_ChannelProgramReserve".Translate(timelineItem.Actor.Name); - default: - return string.Empty; - } - } - - - /* - private string _OwnerUserId; - public string ProviderId => _OwnerUserId; - - public string ProviderName { get; private set; } - - public UserType ProviderType { get; private set; } - - public string Id => TimelineItem.Video?.Id ?? TimelineItem.Program.Id; - */ -} - - -public class LoginUserNicoRepoTimelineSource : IIncrementalSource -{ - // 通常10だが、ニコレポの表示フィルタを掛けた場合に - // 追加読み込み時に表示対象が見つからない場合 - // 追加読み込みが途絶えるため、多めに設定している - public const int OneTimeLoadCount = 25; - - public LoginUserNicoRepoProvider LoginUserNicoRepoProvider { get; } - public SubscriptionManager SubscriptionManager { get; } - - public LoginUserNicoRepoTimelineSource( - LoginUserNicoRepoProvider loginUserNicoRepoProvider, - NicoVideoProvider nicoVideoProvider, - SubscriptionManager subscriptionManager, - NicoRepoType nicoRepoType, - NicoRepoDisplayTarget nicoRepoTarget - ) - { - LoginUserNicoRepoProvider = loginUserNicoRepoProvider; - _nicoVideoProvider = nicoVideoProvider; - SubscriptionManager = subscriptionManager; - _nicoRepoType = nicoRepoType; - _nicoRepoDisplayTarget = nicoRepoTarget; - } - - DateTime NiconamaDisplayTime = DateTime.Now - TimeSpan.FromHours(6); - private readonly NicoVideoProvider _nicoVideoProvider; - private readonly NicoRepoType _nicoRepoType; - private readonly NicoRepoDisplayTarget _nicoRepoDisplayTarget; - - NicoRepoEntriesResponse _prevRes; - - public static bool IsLiveTopic(NicoRepoMuteContextTrigger topic) - { - return topic - is NicoRepoMuteContextTrigger.Live_User_Program_OnAirs - or NicoRepoMuteContextTrigger.Live_User_Program_Reserve - or NicoRepoMuteContextTrigger.Live_Channel_Program_Onairs - or NicoRepoMuteContextTrigger.Live_Channel_Program_Reserve - ; - } - - public static bool IsVideoTopic(NicoRepoMuteContextTrigger topic) - { - return topic - is NicoRepoMuteContextTrigger.NicoVideo_User_Video_Upload - or NicoRepoMuteContextTrigger.NicoVideo_User_Mylist_Add_Video - or NicoRepoMuteContextTrigger.NicoVideo_Channel_Video_Upload - ; - } - - async Task> IIncrementalSource.GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken ct) - { - var nicoRepoResponse = await LoginUserNicoRepoProvider.GetLoginUserNicoRepoAsync(_nicoRepoType, _nicoRepoDisplayTarget, _prevRes); - - ct.ThrowIfCancellationRequested(); - - if (nicoRepoResponse.Meta.Status != 200) { return Enumerable.Empty(); } - - _prevRes = nicoRepoResponse; -#if DEBUG - List triggers = new List(); -#endif - - // Note: ニコレポで取得できるチャンネル動画は基本的に動画IDが数字のみで、"so1234567" みたいな形式ではない - // このためアプリ内での扱いを - var topicTypeMapedEntries = nicoRepoResponse.Data.Select(x => (TopicType: x.GetMuteContextTrigger(), Item: x)).ToList(); - var numberIdVideoTopics = topicTypeMapedEntries - .Where(x => IsVideoTopic(x.TopicType)); - - return topicTypeMapedEntries.Select(item => - { -#if DEBUG - if (triggers.Any(x => x == item.Item.MuteContext.Trigger) is false) - { - triggers.Add(item.Item.MuteContext.Trigger); - } -#endif - var topicType = item.TopicType; - if (IsLiveTopic(topicType)) - { - return new NicoRepoLiveTimeline(item.Item, topicType) as INicoRepoItem; - } - else if (IsVideoTopic(topicType)) - { - try - { - var id = item.Item.GetContentId(); - var vm = new NicoRepoVideoTimeline(item.Item, topicType); - return vm as INicoRepoItem; - } - catch - { - return null; - } - } - else - { - return null; - } - }) - .Where(x => x != null) - .ToArray()// Note: IncrementalLoadingSourceが複数回呼び出すためFreezeしたい - ; - -#if DEBUG - //Debug.WriteLine(string.Join(" ", triggers)); -#endif - } -} - - - -public class SelectableNicoRepoMuteContextTrigger -{ - public NicoRepoMuteContextTrigger Topic { get; set; } -} diff --git a/Hohoema/Views.Niconico/Video/VideoInfomationPageViewModel.cs b/Hohoema/Views.Niconico/Video/VideoInfomationPageViewModel.cs index 5557dca8..f00ac9fa 100644 --- a/Hohoema/Views.Niconico/Video/VideoInfomationPageViewModel.cs +++ b/Hohoema/Views.Niconico/Video/VideoInfomationPageViewModel.cs @@ -796,9 +796,9 @@ public class HyperlinkItem public class VideoSeriesViewModel : ISeries { - private readonly NicoVideoWatchApiResponse.WatchApiSeries _userSeries; + private readonly WatchApiSeries _userSeries; - public VideoSeriesViewModel(NicoVideoWatchApiResponse.WatchApiSeries userSeries) + public VideoSeriesViewModel(WatchApiSeries userSeries) { _userSeries = userSeries; } diff --git a/Hohoema/Views.Player/VideoPlayerPageViewModel.cs b/Hohoema/Views.Player/VideoPlayerPageViewModel.cs index cb81211d..2ee2104f 100644 --- a/Hohoema/Views.Player/VideoPlayerPageViewModel.cs +++ b/Hohoema/Views.Player/VideoPlayerPageViewModel.cs @@ -703,9 +703,9 @@ private void SetSidePaneViewModel(PlayerSidePaneContentType sidePaneType) public class VideoSeriesViewModel : ISeries { - private readonly NicoVideoWatchApiResponse.WatchApiSeries _userSeries; + private readonly WatchApiSeries _userSeries; - public VideoSeriesViewModel(NicoVideoWatchApiResponse.WatchApiSeries userSeries) + public VideoSeriesViewModel(WatchApiSeries userSeries) { _userSeries = userSeries; } diff --git a/Hohoema/Views.Player/VideoPlayerUI/DesktopPlayerUI.xaml.cs b/Hohoema/Views.Player/VideoPlayerUI/DesktopPlayerUI.xaml.cs index 5118a2d0..20a3e2d9 100644 --- a/Hohoema/Views.Player/VideoPlayerUI/DesktopPlayerUI.xaml.cs +++ b/Hohoema/Views.Player/VideoPlayerUI/DesktopPlayerUI.xaml.cs @@ -9,7 +9,7 @@ using Hohoema.Views.Helpers; using I18NPortable; using Microsoft.Toolkit.Uwp.Helpers; -using NiconicoToolkit.NicoRepo; +using NiconicoToolkit.FollowingsActivity; using Reactive.Bindings.Extensions; using System; using System.Collections.Generic; diff --git a/Hohoema/Views/Converters/PageTypeToIconConverter.cs b/Hohoema/Views/Converters/PageTypeToIconConverter.cs index afca8fb6..19cfd383 100644 --- a/Hohoema/Views/Converters/PageTypeToIconConverter.cs +++ b/Hohoema/Views/Converters/PageTypeToIconConverter.cs @@ -31,7 +31,7 @@ public object Convert(object value, Type targetType, object parameter, string la HohoemaPageType.Subscription => new SymbolIcon(Symbol.Important), HohoemaPageType.LocalPlaylist => new SymbolIcon(Symbol.List), HohoemaPageType.VideoQueue => new SymbolIcon(Symbol.Play), - HohoemaPageType.NicoRepo => new SymbolIcon(Symbol.Bookmarks), + HohoemaPageType.FollowingsActivity => new SymbolIcon(Symbol.Bookmarks), HohoemaPageType.SubscriptionManagement => new SymbolIcon(Symbol.Globe), HohoemaPageType.SubscVideoList => new SymbolIcon(Symbol.Globe), _ => throw new NotSupportedException(), diff --git a/Hohoema/Views/PrimaryWindowCoreLayoutViewModel.cs b/Hohoema/Views/PrimaryWindowCoreLayoutViewModel.cs index 1598dfc8..20b7c971 100644 --- a/Hohoema/Views/PrimaryWindowCoreLayoutViewModel.cs +++ b/Hohoema/Views/PrimaryWindowCoreLayoutViewModel.cs @@ -165,7 +165,7 @@ OpenPageCommand openPageCommand new SeparatorMenuItemViewModel(), _queueMenuItemViewModel, new NavigateAwareMenuItemViewModel(HohoemaPageType.RankingCategoryList.Translate(), HohoemaPageType.RankingCategoryList), - //new NavigateAwareMenuItemViewModel(HohoemaPageType.NicoRepo.Translate(), HohoemaPageType.NicoRepo, new NavigationParameters("type=Video")), + new NavigateAwareMenuItemViewModel(HohoemaPageType.FollowingsActivity.Translate(), HohoemaPageType.FollowingsActivity, new NavigationParameters("type=Video")), new SubscriptionMenuItemViewModel(_messenger, _subscriptionManager, _queuePlaylist, _notificationService), //new NavigateAwareMenuItemViewModel("WatchAfterMylist".Translate(), HohoemaPageType.Mylist, new NavigationParameters(("id", MylistId.WatchAfterMylistId.ToString()))), new MylistSubMenuMenu(_userMylistManager, OpenPageCommand), @@ -175,7 +175,7 @@ OpenPageCommand openPageCommand new SeparatorMenuItemViewModel(), new LogginUserLiveSummaryItemViewModel(NiconicoSession, _logger, OpenLiveContentCommand), - //new NavigateAwareMenuItemViewModel(HohoemaPageType.NicoRepo.Translate(), HohoemaPageType.NicoRepo, new NavigationParameters("type=Program")), + new NavigateAwareMenuItemViewModel(HohoemaPageType.FollowingsActivity.Translate(), HohoemaPageType.FollowingsActivity, new NavigationParameters("type=Live")), new NavigateAwareMenuItemViewModel(HohoemaPageType.Timeshift.Translate(), HohoemaPageType.Timeshift), }; diff --git a/Hohoema/Views/SettingsPageViewModel.cs b/Hohoema/Views/SettingsPageViewModel.cs index e7341a46..d4da7726 100644 --- a/Hohoema/Views/SettingsPageViewModel.cs +++ b/Hohoema/Views/SettingsPageViewModel.cs @@ -5,7 +5,6 @@ using Hohoema.Helpers; using Hohoema.Models; using Hohoema.Models.Application; -using Hohoema.Models.Niconico.NicoRepo; using Hohoema.Models.Niconico.Video; using Hohoema.Models.PageNavigation; using Hohoema.Models.Player; @@ -59,7 +58,6 @@ public sealed partial class SettingsPageViewModel : HohoemaPageViewModelBase private readonly INotificationService _notificationService; private readonly PlayerSettings PlayerSettings; private readonly VideoRankingSettings RankingSettings; - private readonly NicoRepoSettings ActivityFeedSettings; public AppearanceSettings AppearanceSettings { get; } private readonly VideoCacheSettings VideoCacheSettings; public ApplicationLayoutManager ApplicationLayoutManager { get; } @@ -72,7 +70,6 @@ public SettingsPageViewModel( INotificationService toastService, PlayerSettings playerSettings, VideoRankingSettings rankingSettings, - NicoRepoSettings nicoRepoSettings, AppearanceSettings appearanceSettings, VideoCacheSettings cacheSettings, VideoCacheFolderManager videoCacheFolderManager, @@ -86,7 +83,6 @@ BackupManager backupManager RankingSettings = rankingSettings; _HohoemaDialogService = dialogService; PlayerSettings = playerSettings; - ActivityFeedSettings = nicoRepoSettings; AppearanceSettings = appearanceSettings; VideoCacheSettings = cacheSettings; _videoCacheFolderManager = videoCacheFolderManager; @@ -199,7 +195,7 @@ async Task ClearCacheAsync() public List StartupPageTypeList { get; } = new List() { - HohoemaPageType.NicoRepo, + HohoemaPageType.FollowingsActivity, HohoemaPageType.Search, HohoemaPageType.RankingCategoryList, HohoemaPageType.CacheManagement, @@ -547,7 +543,7 @@ async Task ImportBackupAsync() _backupManager.RestoreVideoFilteringSettings, _backupManager.RestorePlayerSettings, _backupManager.RestoreAppearanceSettings, - _backupManager.RestoreNicoRepoSettings, + //_backupManager.RestoreFollowingsActivitySettings, _backupManager.RestoreCommentSettings, };