Beispiel #1
0
        private async Task <ObservableCollectionCustomized <IBroadcastModel> > getSpotvData(DateTime dateTime, string strDayPart, string strChannel, bool isYesterday = false)
        {
            string strParams = "?y=" + dateTime.Year + "&m=" + dateTime.Month + "&d=" + dateTime.Day + "&dayPart=" + strDayPart + "&ch=" + strChannel;
            //HttpResponseMessage response = await client.GetAsync("http://www.spotv.net/data/json/schedule/daily.json2.asp?y=2017&m=2&d=14&dayPart=morning&ch=spotv2");

            string result = await getData(SpotvService.URL_SPOTV + SpotvService.URL_SPOTV_DAILY + strParams, dateTime);

            ObservableCollectionCustomized <IBroadcastModel> listSpotv;

            if (result == "")
            {
                return(new ObservableCollectionCustomized <IBroadcastModel>());
            }

            try
            {
                JArray jarrResult = JArray.Parse(result);

                listSpotv = getNBAPrettyData(this, jarrResult, strChannel, strDayPart, isYesterday);
            }
            catch (Exception e)
            {
                listSpotv = new ObservableCollectionCustomized <IBroadcastModel>();
            }

            return(listSpotv);
        }
Beispiel #2
0
        private ObservableCollectionCustomized <IBroadcastModel> getNBAPrettyData(BroadcastViewModel instance, JArray jarrRaw, string strChannel, string strDayPart, bool isYesterday = false)
        {
            ObservableCollectionCustomized <IBroadcastModel> listRet = new ObservableCollectionCustomized <IBroadcastModel>();

            JObject    jobjRaw;
            SpotvModel model;

            //	"kind": "재방송",
            //"sch_date": "2017-02-14",
            //"sch_hour": 5,
            //"sch_min": "30",
            //"title": "2014 WTA 카타르 토탈 오픈 결승 할렙:커버"

            string title;
            string kind;
            string scheduleDate;
            string scheduleHour;
            string scheduleMinute;

            for (int i = 0; i < jarrRaw.Count; ++i)
            {
                jobjRaw = jarrRaw[i] as JObject;

                title = (string)(jobjRaw["title"]);

                if (!title.Contains("NBA") && !title.Contains("nba"))
                {
                    continue;
                }

                kind           = (string)(jobjRaw["kind"]);
                scheduleDate   = (string)(jobjRaw["sch_date"]);
                scheduleHour   = (string)(jobjRaw["sch_hour"]);
                scheduleMinute = (string)(jobjRaw["sch_min"]);

                if (!getIsValidNightHour(strDayPart, isYesterday, int.Parse(scheduleHour)))
                {
                    continue;
                }

                model = new SpotvModel();

                model.Kind           = kind;
                model.ScheduleDate   = scheduleDate;
                model.ScheduleHour   = scheduleHour;
                model.ScheduleMinute = scheduleMinute;
                model.Title          = title;
                //model.ScheduleDateTime = dateTime;

                model.Channel = strChannel;

                // morning over 12, change to afternoon.
                model.DayPart = SpotvService.getDayPartToDisplay(strDayPart, model.ScheduleHour);

                listRet.Add(model);
            }

            return(listRet);
        }
Beispiel #3
0
        private async Task <BroadcastModelGroup> getSpotvDataByChannel(DateTime dateTime, string strChannel)
        {
            BroadcastModelGroup group = new BroadcastModelGroup();

            group.Channel     = strChannel;
            group.ChannelShow = SpotvService.getChannelToDisplay(strChannel);

            // add yesterday midnight.
            ObservableCollectionCustomized <IBroadcastModel> gotModelList = await getSpotvData(dateTime.AddDays(-1), SpotvService.DAY_PART_NIGHT, strChannel, true);

            group.AddRange(gotModelList);

            gotModelList = await getSpotvData(dateTime, SpotvService.DAY_PART_MORNING, strChannel);

            group.AddRange(gotModelList);
            gotModelList = await getSpotvData(dateTime, SpotvService.DAY_PART_EVENING, strChannel);

            group.AddRange(gotModelList);
            gotModelList = await getSpotvData(dateTime, SpotvService.DAY_PART_NIGHT, strChannel);

            group.AddRange(gotModelList);

            return(group);
        }