public async Task <List <LoginUserMylistGroup> > GetLoginUserMylistGroups() { if (Context == null) { return(null); } if (await Context.GetIsSignedInAsync() != NiconicoSignInStatus.Success) { return(null); } await WaitNicoPageAccess(); return(await ConnectionRetryUtil.TaskWithRetry(() => { return Context.User.GetMylistGroupListAsync(); }) .ContinueWith(prevResult => { return prevResult.Result.Cast <LoginUserMylistGroup>().ToList(); })); }
public async Task <List <LoginUserMylistGroup> > GetLoginUserMylistGroups() { if (_HohoemaApp.NiconicoContext == null) { return(null); } if (!_HohoemaApp.IsLoggedIn) { return(null); } await WaitNicoPageAccess(); return(await ConnectionRetryUtil.TaskWithRetry(() => { return _HohoemaApp.NiconicoContext.User.GetMylistGroupListAsync(); }) .ContinueWith(prevResult => { return prevResult.Result.Cast <LoginUserMylistGroup>().ToList(); })); }
public async Task <UserDetail> GetUserDetail(string userId) { var userDetail = await ConnectionRetryUtil.TaskWithRetry(() => { return(Context.User.GetUserDetail(userId)); }); if (userDetail != null) { var owner = NicoVideoOwnerDb.Get(userId); if (owner == null) { owner = new NicoVideoOwner() { OwnerId = userId, UserType = UserType.User }; } owner.ScreenName = userDetail.Nickname; owner.IconUrl = userDetail.ThumbnailUri; NicoVideoOwnerDb.AddOrUpdate(owner); } return(userDetail); }
public async Task <CommunityDetailResponse> GetCommunityDetail( string communityId ) { if (Context == null) { return(null); } if (await Context.GetIsSignedInAsync() != NiconicoSignInStatus.Success) { return(null); } await WaitNicoPageAccess(); return(await ConnectionRetryUtil.TaskWithRetry(async() => { using (var releaser = await _NicoPageAccessLock.LockAsync()) { return await Context.Community.GetCommunityDetailAsync(communityId); } })); }
public async Task <CommunityDetailResponse> GetCommunityDetail( string communityId ) { if (_HohoemaApp.NiconicoContext == null) { return(null); } if (!_HohoemaApp.IsLoggedIn) { return(null); } await WaitNicoPageAccess(); return(await ConnectionRetryUtil.TaskWithRetry(async() => { using (var releaser = await _NicoPageAccessLock.LockAsync()) { return await _HohoemaApp.NiconicoContext.Community.GetCommunityDetailAsync(communityId); } })); }
public async Task <NicoVideoOwner> GetUser(string userId) { using (var releaser = await _NicoPageAccessLock.LockAsync()) { var userRes = await ConnectionRetryUtil.TaskWithRetry(() => { return(Context.User.GetUserAsync(userId)); }); var owner = NicoVideoOwnerDb.Get(userId); if (userRes.Status == "ok") { var user = userRes.User; if (owner == null) { owner = new NicoVideoOwner() { OwnerId = userId, UserType = UserType.User }; } owner.ScreenName = user.Nickname; owner.IconUrl = user.ThumbnailUrl; NicoVideoOwnerDb.AddOrUpdate(owner); } return(owner); } }
public async Task <NiconicoVideoRss> GetCategoryRanking(RankingCategory category, RankingTarget target, RankingTimeSpan timeSpan) { return(await ConnectionRetryUtil.TaskWithRetry(async() => { return await NiconicoRanking.GetRankingData(target, timeSpan, category); })); }
public async Task <NiconicoSignInStatus> CheckSignedInStatus() { NiconicoSignInStatus result = NiconicoSignInStatus.Failed; try { await _SigninLock.WaitAsync(); if (Util.InternetConnection.IsInternet() && NiconicoContext != null) { result = await ConnectionRetryUtil.TaskWithRetry( () => NiconicoContext.GetIsSignedInAsync() , retryInterval : 1000 ); } } catch { // ログイン処理時には例外を捕捉するが、ログイン状態チェックでは例外は無視する result = NiconicoSignInStatus.Failed; } finally { UpdateServiceStatus(result); _SigninLock.Release(); } return(result); }
public async Task <CommunitySearchResponse> SearchCommunity( string keyword , uint page , CommunitySearchSort sort = CommunitySearchSort.CreatedAt , Order order = Order.Descending , CommunitySearchMode mode = CommunitySearchMode.Keyword ) { if (_HohoemaApp.NiconicoContext == null) { return(null); } if (!_HohoemaApp.IsLoggedIn) { return(null); } return(await ConnectionRetryUtil.TaskWithRetry(async() => { using (var releaser = await _NicoPageAccessLock.LockAsync()) { return await _HohoemaApp.NiconicoContext.Search.CommunitySearchAsync(keyword, page, sort, order, mode); } })); }
public async Task <List <MylistGroupData> > GetUserMylistGroups(string userId) { if (_HohoemaApp.NiconicoContext == null) { return(null); } await WaitNicoPageAccess(); return(await ConnectionRetryUtil.TaskWithRetry(async() => { try { return await _HohoemaApp.NiconicoContext.Mylist.GetUserMylistGroupAsync(userId); } catch (Exception e) when(e.Message.Contains("Forbidden")) { return new List <MylistGroupData>(); } }) .ContinueWith(prevTask => { if (prevTask.IsCompleted && prevTask.Result != null) { _CachedUserMylistGroupDatum = prevTask.Result; return prevTask.Result; } else { return _CachedUserMylistGroupDatum; } })); }
// コメントのキャッシュまたはオンラインからの取得と更新 public async Task <List <Chat> > GetComments() { if (CommentServerInfo == null) { return(new List <Chat>()); } CommentResponse commentRes = null; try { commentRes = await ConnectionRetryUtil.TaskWithRetry(async() => { return(await this.HohoemaApp.NiconicoContext.Video .GetCommentAsync( (int)HohoemaApp.LoginUserId, CommentServerInfo.ServerUrl, CommentServerInfo.DefaultThreadId, CommentServerInfo.ThreadKeyRequired )); }); } catch { } if (commentRes?.Chat.Count == 0) { try { if (CommentServerInfo.CommunityThreadId.HasValue) { commentRes = await ConnectionRetryUtil.TaskWithRetry(async() => { return(await this.HohoemaApp.NiconicoContext.Video .GetCommentAsync( (int)HohoemaApp.LoginUserId, CommentServerInfo.ServerUrl, CommentServerInfo.CommunityThreadId.Value, CommentServerInfo.ThreadKeyRequired )); }); } } catch { } } if (commentRes != null) { CachedCommentResponse = commentRes; CommentDb.AddOrUpdate(RawVideoId, commentRes); } return(commentRes?.Chat); }
public async Task <MylistGroupVideoResponse> GetMylistGroupVideo(string mylistGroupid, uint from = 0, uint limit = 50) { if (_HohoemaApp.NiconicoContext == null) { return(null); } return(await ConnectionRetryUtil.TaskWithRetry(async() => { return await _HohoemaApp.NiconicoContext.Mylist.GetMylistGroupVideoAsync(mylistGroupid, from, limit); })); }
public async Task <MylistGroupDetailResponse> GetMylistGroupDetail(string mylistGroupid) { if (_HohoemaApp.NiconicoContext == null) { return(null); } return(await ConnectionRetryUtil.TaskWithRetry(async() => { return await _HohoemaApp.NiconicoContext.Mylist.GetMylistGroupDetailAsync(mylistGroupid); })); }
public async Task <VideoListingResponse> GetKeywordSearch(string keyword, uint from, uint limit, Sort sort = Sort.FirstRetrieve, Order order = Order.Descending) { if (_HohoemaApp.NiconicoContext == null) { return(null); } return(await ConnectionRetryUtil.TaskWithRetry(async() => { return await _HohoemaApp.NiconicoContext.Search.VideoSearchWithKeywordAsync(keyword, from, limit, sort, order); } , retryInterval : 1000)); }
public async Task <UserDetail> GetUserDetail(string userId) { var userDetail = await ConnectionRetryUtil.TaskWithRetry(() => { return(_HohoemaApp.NiconicoContext.User.GetUserDetail(userId)); }); if (userDetail != null) { await UserInfoDb.AddOrReplaceAsync(userId, userDetail.Nickname, userDetail.ThumbnailUri); } return(userDetail); }
public async Task <HistoriesResponse> GetHistory() { if (_HohoemaApp.NiconicoContext == null) { return(null); } if (!_HohoemaApp.IsLoggedIn) { return(null); } await WaitNicoPageAccess(); return(await ConnectionRetryUtil.TaskWithRetry(async() => { return await _HohoemaApp.NiconicoContext.Video.GetHistoriesAsync(); })); }
public async Task <HistoriesResponse> GetHistory() { if (Context == null) { return(null); } if (await Context.GetIsSignedInAsync() != NiconicoSignInStatus.Success) { return(null); } await WaitNicoPageAccess(); return(await ConnectionRetryUtil.TaskWithRetry(async() => { return await Context.Video.GetHistoriesAsync(); })); }
public async Task <NiconicoVideoRss> GetCommunityVideo( string communityId, uint page ) { if (Context == null) { return(null); } if (await Context.GetIsSignedInAsync() != NiconicoSignInStatus.Success) { return(null); } return(await ConnectionRetryUtil.TaskWithRetry(async() => { return await Context.Community.GetCommunityVideoAsync(communityId, page); })); }
public Task <NiconicoVideoRss> GetCommunityVideo( string communityId, uint page ) { if (_HohoemaApp.NiconicoContext == null) { return(null); } if (!_HohoemaApp.IsLoggedIn) { return(null); } return(ConnectionRetryUtil.TaskWithRetry(async() => { return await _HohoemaApp.NiconicoContext.Community.GetCommunityVideoAsync(communityId, page); })); }
public async Task <UserDetail> GetUserInfo(string userId) { if (_HohoemaApp.NiconicoContext == null) { return(null); } await WaitNicoPageAccess(); var user = await ConnectionRetryUtil.TaskWithRetry(() => { return(_HohoemaApp.NiconicoContext.User.GetUserDetail(userId)); }); if (user != null) { await UserInfoDb.AddOrReplaceAsync(userId, user.Nickname, user.ThumbnailUri); } return(user); }
public async Task <VideoListingResponse> GetTagSearch(string tag, uint from, uint limit, Sort sort = Sort.FirstRetrieve, Order order = Order.Descending) { if (_HohoemaApp.NiconicoContext == null) { return(null); } return(await ConnectionRetryUtil.TaskWithRetry(async() => { return await _HohoemaApp.NiconicoContext.Search.VideoSearchWithTagAsync(tag, from, limit, sort, order) .ContinueWith(prevTask => { if (!prevTask.Result.IsOK) { throw new WebException(); } else { return prevTask.Result; } }); }, retryInterval : 1000)); }
private async Task <List <Chat> > GetComments() { if (CommentServerInfo == null) { return(new List <Chat>()); } CommentResponse commentRes = null; try { commentRes = await ConnectionRetryUtil.TaskWithRetry(async() => { return(await ContextActionAsync(async context => { return await context.Video .GetCommentAsync( (int)CommentServerInfo.ViewerUserId, CommentServerInfo.ServerUrl, CommentServerInfo.DefaultThreadId, CommentServerInfo.ThreadKeyRequired ); })); }); } catch { } if (commentRes?.Chat.Count == 0) { try { if (CommentServerInfo.CommunityThreadId.HasValue) { commentRes = await ConnectionRetryUtil.TaskWithRetry(async() => { return(await ContextActionAsync(async context => { return await context.Video .GetCommentAsync( (int)CommentServerInfo.ViewerUserId, CommentServerInfo.ServerUrl, CommentServerInfo.CommunityThreadId.Value, CommentServerInfo.ThreadKeyRequired ); })); }); } } catch { } } if (commentRes != null) { CachedCommentResponse = commentRes; Database.VideoCommentDb.AddOrUpdate(RawVideoId, commentRes.Chat); } if (commentRes != null && DefaultThreadSubmitInfo == null) { DefaultThreadSubmitInfo = new CommentSubmitInfo(); DefaultThreadSubmitInfo.Ticket = commentRes.Thread.Ticket; if (int.TryParse(commentRes.Thread.CommentCount, out int count)) { DefaultThreadSubmitInfo.CommentCount = count + 1; } } return(commentRes?.Chat); }