예제 #1
0
 /// <summary>
 /// 更新直播状态
 /// </summary>
 /// <param name="groupId">群号</param>
 /// <param name="biliUserId">B站用户ID</param>
 /// <param name="newStatus">新状态</param>
 public bool UpdateLiveStatus(long groupId, long biliUserId, LiveStatusType newStatus)
 {
     using SqlSugarClient dbClient = SugarUtils.CreateSqlSugarClient(DBPath);
     //查找是否有历史记录
     if (!dbClient.Queryable <BiliLiveSubscription>()
         .Where(biliLive => biliLive.SubscriptionId == biliUserId &&
                biliLive.Gid == groupId)
         .Any())
     {
         //没有记录插入新行
         return(dbClient.Insertable(new BiliLiveSubscription()
         {
             Gid = groupId,
             SubscriptionId = biliUserId,
             LiveStatus = newStatus
         }).ExecuteCommand() > 0);
     }
     else
     {
         //有记录更新时间
         return(dbClient.Updateable <BiliLiveSubscription>(biliLive =>
                                                           biliLive.LiveStatus == newStatus)
                .Where(biliDynamic => biliDynamic.SubscriptionId == biliUserId &&
                       biliDynamic.Gid == groupId)
                .ExecuteCommandHasChange());
     }
 }
예제 #2
0
        public static LiveSuggestion Make(this LiveStatusType liveStatus, NicoLiveVideo liveVideo, PageManager pageManager)
        {
            string title = liveStatus.ToString();

            List <SuggestAction> actions = new List <SuggestAction>();

            switch (liveStatus)
            {
            case LiveStatusType.NotFound:
                title = "放送が見つかりませんでした";
                break;

            case LiveStatusType.Closed:
                title = "放送は終了しました";
                break;

            case LiveStatusType.ComingSoon:
                title = "放送はもうすぐ始まります";
                break;

            case LiveStatusType.Maintenance:
                title = "現在メンテナンス中です";
                break;

            case LiveStatusType.CommunityMemberOnly:
                title = "この放送はコミュニティメンバー限定です";
                actions.Add(new SuggestAction("コミュニティページを開く", () =>
                {
                    pageManager.OpenPage(HohoemaPageType.Community, liveVideo.BroadcasterCommunityId);
                }));
                break;

            case LiveStatusType.Full:
                title = "満員です";
                break;

            case LiveStatusType.PremiumOnly:
                title = "この放送はプレミアム会員限定です";
                break;

            case LiveStatusType.NotLogin:
                title = "視聴するには「ニコニコ」にログインが必要です";
                actions.Add(new SuggestAction("ログイン", async() =>
                {
                    var dialog = new Dialogs.NiconicoLoginDialog();
                    var result = await dialog.ShowAsync();
                    if (result == Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
                    {
                        await liveVideo.StartLiveWatchingSessionAsync();
                    }
                }));
                break;

            default:
                break;
            }


            return(new LiveSuggestion(title, actions.ToArray()));
        }
예제 #3
0
        public async Task <LiveStatusType> GetLiveViewingFailedReason()
        {
            LiveStatusType type = LiveStatusType.Unknown;

            try
            {
                var playerStatus = await NicoLiveProvider.GetPlayerStatusAsync(LiveId);

                if (playerStatus.Program.IsLive)
                {
                    type = Live.LiveStatusType.OnAir;
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == NiconicoHResult.ELiveNotFound)
                {
                    type = Live.LiveStatusType.NotFound;
                }
                else if (ex.HResult == NiconicoHResult.ELiveClosed)
                {
                    type = Live.LiveStatusType.Closed;
                }
                else if (ex.HResult == NiconicoHResult.ELiveComingSoon)
                {
                    type = Live.LiveStatusType.ComingSoon;
                }
                else if (ex.HResult == NiconicoHResult.EMaintenance)
                {
                    type = Live.LiveStatusType.Maintenance;
                }
                else if (ex.HResult == NiconicoHResult.ELiveCommunityMemberOnly)
                {
                    type = Live.LiveStatusType.CommunityMemberOnly;
                }
                else if (ex.HResult == NiconicoHResult.ELiveFull)
                {
                    type = Live.LiveStatusType.Full;
                }
                else if (ex.HResult == NiconicoHResult.ELivePremiumOnly)
                {
                    type = Live.LiveStatusType.PremiumOnly;
                }
                else if (ex.HResult == NiconicoHResult.ENotSigningIn)
                {
                    type = Live.LiveStatusType.NotLogin;
                }
                else
                {
                    type = LiveStatusType.Unknown;
                }
            }

            return(type);
        }
예제 #4
0
        public static LiveSuggestion Make(this LiveStatusType liveStatus, NicoLiveVideo liveVideo, Services.PageManager pageManager, NiconicoSession niconicoSession)
        {
            string title = liveStatus.ToString();

            List <SuggestAction> actions = new List <SuggestAction>();

            switch (liveStatus)
            {
            case LiveStatusType.NotFound:
                title = "放送が見つかりませんでした";
                break;

            case LiveStatusType.Closed:
                title = "放送は終了しました";
                break;

            case LiveStatusType.ComingSoon:
                title = "放送はもうすぐ始まります";
                break;

            case LiveStatusType.Maintenance:
                title = "現在メンテナンス中です";
                break;

            case LiveStatusType.CommunityMemberOnly:
                title = "この放送はコミュニティメンバー限定です";
                actions.Add(new SuggestAction("コミュニティページを開く", () =>
                {
                    pageManager.OpenPageWithId(HohoemaPageType.Community, liveVideo.BroadcasterCommunityId);
                }));
                break;

            case LiveStatusType.Full:
                title = "満員です";
                break;

            case LiveStatusType.PremiumOnly:
                title = "この放送はプレミアム会員限定です";
                break;

            case LiveStatusType.NotLogin:
                title = "視聴するには「ニコニコ」にログインが必要です";

                break;

            default:
                break;
            }


            return(new LiveSuggestion(title, actions.ToArray()));
        }
예제 #5
0
 public LiveSuggestion(LiveStatusType status, string title, params SuggestAction[] actions)
 {
     Status  = status;
     Title   = title;
     Actions = actions.ToList();
 }