Ejemplo n.º 1
0
        public static List <Market> GetMarketsByEvent(long id, WebProxy proxy, CookieContainer cont, string host)
        {
            using (var wc = new PostWebClient(proxy, cont.GetAllCookies()))
            {
                var query = $"{{\"jsonrpc\":\"2.0\",\"method\":\"frontend/market/get\",\"id\":{new Random().Next(100, 9999)},\"params\":{{\"by\":{{\"lang\":\"en\",\"service_id\":1,\"event_id\":{id}}}}}}}";

                var response = wc.UploadString($"{host}frontend_api2/", query);

                var t = JsonConvert.DeserializeObject <FrontendApiResponseWrapper <Market> >(response);

                //foreach (var market in t.Result)
                //{
                //    foreach (var outcome in market.outcomes)
                //    {
                //        ProxyHelper.UpdateFavbetEvents(market.market_name + " | " + market.result_type_name + " | " + outcome.outcome_name + " | " +outcome.outcome_param);
                //    }
                //}

                return(t.Result);
            }
        }
Ejemplo n.º 2
0
        protected override void UpdateLiveLines()
        {
            var lines = new List <LineDTO>();

            try
            {
                var randomProxy = ProxyList.PickRandom();

                string response;

                var cookies = CookieDictionary[randomProxy].GetData().GetAllCookies();

                using (var wc = new PostWebClient(randomProxy, cookies))
                {
                    response = wc.UploadString($"{Host}frontend_api/events_short/", "{\"service_id\":1,\"lang\":\"en\"}");
                }

                var sportids = JsonConvert.DeserializeObject <EventsShort>(response).Events.Select(e => e.sport_id).Distinct().ToList();

                var events = new List <Event>();

                Parallel.ForEach(sportids, sportId =>
                {
                    try
                    {
                        var random = ProxyList.PickRandom();
                        var cook   = CookieDictionary[random].GetData().GetAllCookies();

                        using (var wc = new PostWebClient(random, cook))
                        {
                            response = wc.UploadString($"{Host}frontend_api/events/", $"{{\"service_id\":1,\"lang\":\"en\",\"sport_id\":{sportId}}}");
                            var e    = JsonConvert.DeserializeObject <EventsShort>(response).Events;

                            lock (Lock) events.AddRange(e);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Info("Get event exception");
                    }
                });


                Parallel.ForEach(events, @event =>
                {
                    var task = Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            //убираем запрещенные чемпионаты
                            if (@event.tournament_name.ContainsIgnoreCase(ForbiddenTournaments.ToArray()))
                            {
                                return;
                            }
                            if (@event.event_name.ContainsIgnoreCase(ForbiddenTournaments.ToArray()))
                            {
                                return;
                            }

                            var lns = ParseEvent(@event);

                            lock (Lock) lines.AddRange(lns);
                        }
                        catch (Exception e)
                        {
                            Log.Info($"ERROR FavBet Parse event exception {e.Message} {e.StackTrace}");
                        }
                    });

                    if (!task.Wait(10000))
                    {
                        Log.Info("FavBet Task wait exception");
                    }
                });

                LastUpdatedDiff = DateTime.Now - LastUpdated;

                ConsoleExt.ConsoleWrite(Name, ProxyList.Count, lines.Count(c => c != null), new DateTime(LastUpdatedDiff.Ticks).ToString("mm:ss"));

                ActualLines = lines.ToArray();
            }
            catch (Exception e)
            {
                Log.Info($"ERROR FB {e.Message} {e.StackTrace}");
            }
        }