Пример #1
0
        public void TianXuan()
        {
            //获取直播的分区
            List <AreaDto> areaList = _liveApi.GetAreaList()
                                      .GetAwaiter().GetResult()
                                      .Data.Data;

            //遍历分区
            int count = 0;

            foreach (var area in areaList)
            {
                _logger.LogInformation("【扫描分区】{area}..." + Environment.NewLine, area.Name);

                string defaultSort = "";
                //每个分区下搜索5页
                for (int i = 1; i < 6; i++)
                {
                    var reData = _liveApi.GetList(area.Id, i, sortType: defaultSort)
                                 .GetAwaiter().GetResult()
                                 .Data;
                    foreach (var item in reData.List ?? new List <ListItemDto>())
                    {
                        if (item.Pendant_info == null || item.Pendant_info.Count == 0)
                        {
                            continue;
                        }
                        var suc = item.Pendant_info.TryGetValue("2", out var pendant);
                        if (!suc)
                        {
                            continue;
                        }
                        if (pendant.Pendent_id != 504)
                        {
                            continue;
                        }

                        _targetTianXuanList.Add(item);
                        count++;

                        TryJoinTianXuan(item);
                    }
                    if (reData.Has_more != 1)
                    {
                        break;
                    }
                    defaultSort = reData.New_tags.FirstOrDefault()?.Sort_type ?? "";
                }
                defaultSort = "";
            }
            if (count == 0)
            {
                _logger.LogInformation("未搜索到直播间");
            }
        }
Пример #2
0
        /// <summary>
        /// 天选抽奖
        /// </summary>
        public void TianXuan()
        {
            _tianXuanFollowed = new List <ListItemDto>();

            if (_liveLotteryTaskOptions.AutoGroupFollowings)
            {
                //获取此时最后一个关注的up,此后再新增的关注,与参与成功的抽奖,取交集,就是本地新增的天选关注
                _lastFollowUpId = GetLastFollowUpId();
            }

            //获取直播的分区
            List <AreaDto> areaList = _liveApi.GetAreaList()
                                      .GetAwaiter().GetResult()
                                      .Data.Data;

            //遍历分区
            int count = 0;

            foreach (var area in areaList)
            {
                _logger.LogInformation("【扫描分区】{area}..." + Environment.NewLine, area.Name);

                string defaultSort = "";
                //每个分区下搜索5页
                for (int i = 1; i < 6; i++)
                {
                    var reData = _liveApi.GetList(area.Id, i, sortType: defaultSort)
                                 .GetAwaiter().GetResult()
                                 .Data;
                    foreach (var item in reData.List ?? new List <ListItemDto>())
                    {
                        if (item.Pendant_info == null || item.Pendant_info.Count == 0)
                        {
                            continue;
                        }
                        var suc = item.Pendant_info.TryGetValue("2", out var pendant);
                        if (!suc)
                        {
                            continue;
                        }
                        if (pendant.Pendent_id != 504)
                        {
                            continue;
                        }
                        count++;

                        TryJoinTianXuan(item);
                    }
                    if (reData.Has_more != 1)
                    {
                        break;
                    }
                    defaultSort = reData.New_tags.FirstOrDefault()?.Sort_type ?? "";
                }
                defaultSort = "";
            }

            if (count == 0)
            {
                _logger.LogInformation("未搜索到直播间");
                return;
            }
        }