internal async Task Initialize() { IsInitialized = false; Debug.Write($"ダウンロードリクエストの復元を開始"); // キャッシュリクエストファイルのアクセサーを初期化 var videoSaveFolder = await HohoemaApp.GetApplicationLocalDataFolder(); _CacheRequestedItemsFileAccessor = new FileAccessor <IList <NicoVideoCacheRequest> >(videoSaveFolder, CACHE_REQUESTED_FILENAME); // ダウンロード待機中のアイテムを復元 await RestoreCacheRequestedItems(); // ダウンロードバックグラウンドタスクの情報を復元 await RestoreBackgroundDownloadTask(); IsInitialized = true; // ダウンロードリクエストされたものが削除済み動画だった場合に対応 // 削除されたDLリクエストを反映 await SaveDownloadRequestItems(); await TryNextCacheRequestedVideoDownload(); }
public override async Task <IEnumerable <FeedItem> > GetLatestItems(HohoemaApp hohoemaApp) { var items = await hohoemaApp.ContentProvider.GetUserVideos(uint.Parse(this.Id), 1); if (items?.Items != null) { var feedItems = items.Items.Select(x => new FeedItem() { Title = x.Title, VideoId = x.VideoId, SubmitDate = x.SubmitTime, }) .ToList(); /* * foreach (var item in feedItems) * { * var nicoVideo = await hohoemaApp.MediaManager.GetNicoVideo(item.VideoId); * if (nicoVideo != null) * { * var thumbnail = await nicoVideo.GetThumbnailResponse(); * item.SubmitDate = thumbnail?.PostedAt.DateTime ?? DateTime.MinValue; * item.IsDeleted = nicoVideo.IsDeleted; * } * } */ return(feedItems); } else { return(new List <FeedItem>()); } }
public async Task <bool> RemoveFeedGroup(IFeedGroup group) { var removeTarget = FeedGroups.SingleOrDefault(x => x.Id == group.Id); if (removeTarget != null) { _FeedGroupUpdaters.Remove(group); var fileAccessor = FeedGroupDict[removeTarget]; // フィードソース一覧ファイルを同期から削除 var file = await fileAccessor.TryGetFile(); await HohoemaApp.RoamingDataRemoved(file); // ローカルのフィードソース・ファイルを削除 await fileAccessor.Delete(StorageDeleteOption.PermanentDelete); // フィードの動画一覧ファイルを削除 var feedStreamFileAccesssor = FeedStreamFileAccessors[group.Id]; await feedStreamFileAccesssor.Delete(StorageDeleteOption.PermanentDelete); return(FeedGroupDict.Remove(removeTarget)); } else { return(false); } }
public FeedManager(HohoemaApp hohoemaApp) { HohoemaApp = hohoemaApp; FeedGroupDict = new Dictionary <IFeedGroup, FileAccessor <FeedGroup2> >(); FeedStreamFileAccessors = new Dictionary <Guid, FileAccessor <List <FeedItem> > >(); _FeedGroupUpdaters = new Dictionary <IFeedGroup, BackgroundUpdateScheduleHandler>(); }
public async Task Save(LocalMylist playlist) { var fileAccessor = _PlaylistFileAccessorMap[playlist.Id]; await fileAccessor.Save(playlist); await HohoemaApp.PushToRoamingData(await fileAccessor.TryGetFile()); }
public FollowInfoGroupBase(HohoemaApp hohoemaApp) { HohoemaApp = hohoemaApp; _FollowInfoList = new ObservableCollection <FollowItemInfo>(); FollowInfoItems = new ReadOnlyObservableCollection <FollowItemInfo>(_FollowInfoList); }
public static async Task <FollowManager> Create(HohoemaApp hohoemaApp, uint userId) { var followManager = new FollowManager(hohoemaApp, userId); await followManager.Initialize(); return(followManager); }
static internal Task <NiconicoMediaManager> Create(HohoemaApp app) { var man = new NiconicoMediaManager(app); // await man.RetrieveCacheCompletedVideos(); return(Task.FromResult(man)); }
public PageManager(HohoemaApp hohoemaApp, INavigationService ns, AppearanceSettings appearanceSettings, HohoemaPlaylist playlist) { HohoemaApp = hohoemaApp; NavigationService = ns; AppearanceSettings = appearanceSettings; HohoemaPlaylist = playlist; CurrentPageType = HohoemaPageType.RankingCategoryList; }
public VideoDownloadManager(HohoemaApp hohoemaApp, VideoCacheManager mediaManager) { HohoemaApp = hohoemaApp; MediaManager = mediaManager; // ダウンロード完了をバックグラウンドで処理 CoreApplication.BackgroundActivated += CoreApplication_BackgroundActivated; CoreApplication.Suspending += CoreApplication_Suspending; }
public NicoVideo(HohoemaApp app, string rawVideoid, NiconicoMediaManager manager) { HohoemaApp = app; RawVideoId = rawVideoid; _NiconicoMediaManager = manager; _InterfaceByQuality = new Dictionary <NicoVideoQuality, DividedQualityNicoVideo>(); QualityDividedVideos = new ReadOnlyObservableCollection <DividedQualityNicoVideo>(_QualityDividedVideos); CommentClient = new CommentClient(HohoemaApp, RawVideoId); }
public UserMylistManager(HohoemaApp app) { HohoemaApp = app; _UserMylists = new ObservableCollection <MylistGroupInfo>(); UserMylists = new ReadOnlyObservableCollection <MylistGroupInfo>(_UserMylists); app.OnSignin += App_OnSignin; app.OnSignout += App_OnSignout; }
public MylistGroupInfo(string groupId, HohoemaApp hohoemaApp, UserMylistManager mylistManager) { GroupId = groupId; IsDeflist = GroupId == "0"; HohoemaApp = hohoemaApp; MylistManager = mylistManager; _PlaylistItems = new ObservableCollection <PlaylistItem>(); PlaylistItems = new ReadOnlyObservableCollection <PlaylistItem>(_PlaylistItems); _VideoIdToThreadIdMap = new Dictionary <string, string>(); }
static internal async Task <VideoCacheManager> Create(HohoemaApp app) { var man = new VideoCacheManager(app); await man.Initialize(); // await man.RetrieveCacheCompletedVideos(); return(man); }
internal FollowManager(HohoemaApp hohoemaApp, uint userId) { _HohoemaApp = hohoemaApp; UserId = userId; Tag = new TagFollowInfoGroup(_HohoemaApp); Mylist = new MylistFollowInfoGroup(_HohoemaApp); User = new UserFollowInfoGroup(_HohoemaApp); Community = new CommunityFollowInfoGroup(_HohoemaApp); }
public PageManager(HohoemaApp hohoemaApp, INavigationService ns, AppearanceSettings appearanceSettings, HohoemaPlaylist playlist, HohoemaViewManager viewMan, HohoemaDialogService dialogService) { HohoemaApp = hohoemaApp; NavigationService = ns; AppearanceSettings = appearanceSettings; HohoemaPlaylist = playlist; HohoemaViewManager = viewMan; _HohoemaDialogService = dialogService; CurrentPageType = HohoemaPageType.RankingCategoryList; }
public VideoDownloadManager(HohoemaApp hohoemaApp, NiconicoMediaManager mediaManager) { HohoemaApp = hohoemaApp; MediaManager = mediaManager; _CacheDownloadPendingVideos = new ObservableCollection <NicoVideoCacheRequest>(); CacheDownloadPendingVideos = new ReadOnlyObservableCollection <NicoVideoCacheRequest>(_CacheDownloadPendingVideos); HohoemaApp.OnSignin += HohoemaApp_OnSignin; // ダウンロード完了をバックグラウンドで処理 CoreApplication.BackgroundActivated += CoreApplication_BackgroundActivated; }
private async Task _Save(KeyValuePair <IFeedGroup, FileAccessor <FeedGroup2> > feedItem, bool isSkipSyncRoaming = false) { var fileAccessor = feedItem.Value; await fileAccessor.Save(feedItem.Key as FeedGroup2, FeedGroupSerializerSettings); var feedStreamFileAccessor = FeedStreamFileAccessors[feedItem.Key.Id]; await feedStreamFileAccessor.Save(feedItem.Key.FeedItems); if (!isSkipSyncRoaming) { var file = await fileAccessor.TryGetFile(); await HohoemaApp.PushToRoamingData(file); } }
public async Task Save(LocalMylist playlist) { if (_PlaylistFileAccessorMap.ContainsKey(playlist.Id)) { var fileAccessor = _PlaylistFileAccessorMap[playlist.Id]; await fileAccessor.Save(playlist); var file = await fileAccessor.TryGetFile(); if (file != null) { await HohoemaApp.PushToRoamingData(file); } } }
public static async Task <IPlayableList> GetPlayableList(this HohoemaApp hohoemaApp, string id, PlaylistOrigin?origin) { if (!origin.HasValue) { if (hohoemaApp.UserMylistManager.HasMylistGroup(id)) { origin = PlaylistOrigin.LoginUser; } else if (HohoemaPlaylist.WatchAfterPlaylistId == id) { origin = PlaylistOrigin.Local; } else if (hohoemaApp.Playlist.Playlists.FirstOrDefault(x => x.Id == id) != null) { origin = PlaylistOrigin.Local; } else { origin = PlaylistOrigin.OtherUser; } } switch (origin.Value) { case PlaylistOrigin.LoginUser: // ログインユーザーのマイリスト return(hohoemaApp.UserMylistManager.GetMylistGroup(id)); case PlaylistOrigin.Local: // ローカルマイリスト if (id == HohoemaPlaylist.WatchAfterPlaylistId) { return(hohoemaApp.Playlist.DefaultPlaylist); } else { return(hohoemaApp.Playlist.Playlists.FirstOrDefault(x => x.Id == id)); } case PlaylistOrigin.OtherUser: // 他ユーザーのマイリスト return(await hohoemaApp.OtherOwneredMylistManager.GetMylist(id)); default: throw new Exception("not found mylist:" + id); } }
private NiconicoMediaManager(HohoemaApp app) { _HohoemaApp = app; VideoDownloadManager = new VideoDownloadManager(_HohoemaApp, this); VideoDownloadManager.Requested += VideoDownloadManager_Requested; VideoDownloadManager.RequestCanceled += VideoDownloadManager_RequestCanceled; VideoDownloadManager.DownloadStarted += VideoDownloadManager_DownloadStarted; VideoDownloadManager.DownloadCompleted += VideoDownloadManager_DownloadCompleted; VideoDownloadManager.DownloadCanceled += VideoDownloadManager_DownloadCanceled; _VideoIdToNicoVideo = new Dictionary <string, NicoVideo>(); _CacheVideos = new ObservableCollection <NicoVideo>(); CacheVideos = new ReadOnlyObservableCollection <NicoVideo>(_CacheVideos); _HohoemaApp.OnSignin += _HohoemaApp_OnSignin; }
private VideoCacheManager(HohoemaApp app) { _HohoemaApp = app; _HohoemaApp.OnSignin += _HohoemaApp_OnSignin; Observable.Merge( _DownloadOperations.ObserveRemoveChanged().ToUnit(), _CacheDownloadPendingVideos.ObserveAddChanged().ToUnit() ) .Throttle(TimeSpan.FromSeconds(1)) .Subscribe(_ => { TryNextCacheRequestedVideoDownload().ConfigureAwait(false); }); }
internal async void RenamePlaylist(LocalMylist playlist, string newName) { var fileAccessor = _PlaylistFileAccessorMap[playlist.Id]; // 古いファイルを同期から削除 var oldFile = await fileAccessor.TryGetFile(); await HohoemaApp.RoamingDataRemoved(oldFile); // ファイル名を変更して保存 var newFileName = Util.FilePathHelper.ToSafeFilePath(Path.ChangeExtension(newName, ".json")); await fileAccessor.Rename(newFileName, forceReplace : true); playlist.Name = newName; await Save(playlist); }
public async Task RemovePlaylist(LocalMylist playlist) { if (_Playlists.Contains(playlist)) { _Playlists.Remove(playlist); var fileAccessor = _PlaylistFileAccessorMap[playlist.Id]; var file = await fileAccessor.TryGetFile(); await HohoemaApp.RoamingDataRemoved(file); await fileAccessor.Delete().ConfigureAwait(false); _PlaylistFileAccessorMap.Remove(playlist.Id); playlist.Dispose(); } }
internal FollowManager(HohoemaApp hohoemaApp, uint userId) { _HohoemaApp = hohoemaApp; UserId = userId; Tag = new TagFollowInfoGroup(_HohoemaApp); Mylist = new MylistFollowInfoGroup(_HohoemaApp); User = new UserFollowInfoGroup(_HohoemaApp); Community = new CommunityFollowInfoGroup(_HohoemaApp); Channel = new ChannelFollowInfoGroup(_HohoemaApp); _FollowGroupsMap = new Dictionary <FollowItemType, IFollowInfoGroup>(); _FollowGroupsMap.Add(FollowItemType.Tag, Tag); _FollowGroupsMap.Add(FollowItemType.Mylist, Mylist); _FollowGroupsMap.Add(FollowItemType.User, User); _FollowGroupsMap.Add(FollowItemType.Community, Community); _FollowGroupsMap.Add(FollowItemType.Channel, Channel); }
public override async Task <IEnumerable <FeedItem> > GetLatestItems(HohoemaApp hohoemaApp) { var items = await hohoemaApp.ContentFinder.GetTagSearch(this.Id, 0, 32); if (items?.VideoInfoItems != null) { return(items.VideoInfoItems.Select(x => new FeedItem() { Title = x.Video.Title, VideoId = x.Video.Id, CheckedTime = DateTime.MinValue, SubmitDate = x.Video.FirstRetrieve, IsDeleted = x.Video.IsDeleted, }) .ToList()); } else { return(new List <FeedItem>()); } }
public static async Task <HohoemaApp> Create(IEventAggregator ea) { HohoemaApp.UIDispatcher = Window.Current.CoreWindow.Dispatcher; var app = new HohoemaApp(ea); app.MediaManager = await NiconicoMediaManager.Create(app); await app.LoadUserSettings(); await app.FeedManager.Initialize(); var folder = ApplicationData.Current.LocalFolder; var playlistFolder = await folder.CreateFolderAsync(PlaylistSaveFolderName, CreationCollisionOption.OpenIfExists); app.Playlist = new HohoemaPlaylist(MediaPlayer, app.UserSettings.PlaylistSettings, playlistFolder); await app.Playlist.Load(); app.RagistrationBackgroundUpdateHandle(); return(app); }
internal async Task <bool> RenameFeedGroup(IFeedGroup group, string newLabel) { var target = FeedGroups.SingleOrDefault(x => x.Id == group.Id); if (target != null) { var fileAccessor = FeedGroupDict[target]; var file = await fileAccessor.TryGetFile(); await HohoemaApp.RoamingDataRemoved(file); await fileAccessor.Rename(newLabel + ".json"); await HohoemaApp.PushToRoamingData(file); return(true); } else { return(false); } }
public HohoemaPlaylist(HohoemaApp hohoemaApp, PlaylistSettings playlistSettings, StorageFolder playlistSaveFolder, HohoemaViewManager viewMan) { HohoemaApp = hohoemaApp; PlaylistSettings = playlistSettings; PlaylistsSaveFolder = playlistSaveFolder; Player = new PlaylistPlayer(this, playlistSettings); _SecondaryView = viewMan; Playlists = new ReadOnlyObservableCollection <LocalMylist>(_Playlists); MakeDefaultPlaylist(); CurrentPlaylist = DefaultPlaylist; if (ApplicationData.Current.LocalSettings.Values.TryGetValue(nameof(PlayerDisplayType), out var showInMainView)) { try { _PlayerDisplayType = (bool)showInMainView ? PlayerDisplayType.PrimaryView : PlayerDisplayType.SecondaryView; } catch { } } Player.PlayRequested += Player_PlayRequested; }
public async Task Load(IReadOnlyList <StorageFile> files) { var feedGroupFolder = await GetFeedGroupFolder(); var feedStreamDataFolder = await GetFeedStreamDataFolder(); var legacyFeedSettingsFolder = await HohoemaApp.GetFeedSettingsFolder(); foreach (var file in files) { if (file.FileType == ".json") { var fileName = file.Name; var fileAccessor = new FileAccessor <FeedGroup2>(feedGroupFolder, fileName); try { var item = await fileAccessor.Load(FeedGroupSerializerSettings); bool isLoadFromLegacyFile = false; if (item == null) { var legacyFeedGroupFileAccessor = new FileAccessor <FeedGroup>(legacyFeedSettingsFolder, fileName); var item_legacy = await legacyFeedGroupFileAccessor.Load(FeedGroupSerializerSettings); if (item_legacy != null) { item = new FeedGroup2(item_legacy); isLoadFromLegacyFile = true; } } if (item != null) { item.HohoemaApp = this.HohoemaApp; item.FeedManager = this; FeedGroupDict.Add(item, fileAccessor); var itemId = item.Id.ToString(); var streamFileAccessor = new FileAccessor <List <FeedItem> >(feedStreamDataFolder, $"{itemId}.json"); FeedStreamFileAccessors.Add(item.Id, streamFileAccessor); await item.LoadFeedStream(streamFileAccessor); // 古いファイルは新しいフォーマットで上書きして消しておく if (isLoadFromLegacyFile) { await SaveOne(item, isSkipSyncRoaming : true); } // FeedGroupの更新処理情報を構築 _FeedGroupUpdaters.Add(item, HohoemaApp.BackgroundUpdater.RegistrationBackgroundUpdateScheduleHandler( item, item.Label, nameof(FeedGroup), label: $"FeedGroup:{item.Label}") ); Debug.WriteLine($"FeedManager: [Sucesss] load {item.Label}"); } else { Debug.WriteLine($"FeedManager: [?] .json but not FeedGroup file < {fileName}"); } } catch { Debug.WriteLine($"FeedManager: [Failed] load {file.Path}"); } } } }