Пример #1
0
        private RssItem setHosoInfo(RssItem item)
        {
            for (var i = 0; i < 10; i++)
            {
                var hig = new HosoInfoGetter();
                var r   = hig.get("https://live.nicovideo.jp/watch/" + item.lvId, check.container);
                if (!r)
                {
                    Thread.Sleep(3000);
                    continue;
                }

                var _isFollow = false;
                var lvid      = item.lvId.StartsWith("lv") ? item.lvId : ("lv" + item.lvId);
                var ri        = new RssItem(hig.title, lvid, hig.dt.ToString(),
                                            hig.description,
                                            util.getCommunityName(hig.communityId, out _isFollow, null),
                                            hig.communityId,
                                            "",
                                            hig.thumbnail, "false", "");
                ri.type      = hig.type;
                ri.tags      = hig.tags;
                ri.pubDateDt = hig.openDt;
                if (!string.IsNullOrEmpty(hig.userName))
                {
                    ri.hostName = hig.userName;
                }
                return(ri);
            }
            return(null);
        }
Пример #2
0
        void GetInfoFromHosoIdBtnClick(object sender, EventArgs e)
        {
            var lvid = util.getRegGroup(lvidText.Text, "(lv\\d+)");

            if (lvid == null)
            {
                return;
            }
            lvidText.Text = lvid;

            var hig = new HosoInfoGetter();

            if (hig.get(lvidText.Text, form.check.container))
            {
                var t = "";

                if (hig.title != null)
                {
                    t += hig.title;
                }
                var isFollow = false;
                if (hig.communityId != null)
                {
                    var comName = util.getCommunityName(hig.communityId, out isFollow, form.check.container);
                    if (comName != null)
                    {
                        t += (t == "" ? "" : " ") + comName;
                    }
                }
                if (hig.userId != null)
                {
                    var userName = util.getUserName(hig.userId, out isFollow, form.check.container, false, form.config);
                    if (userName != null)
                    {
                        t += (t == "" ? "" : " ") + userName;
                    }
                }
                if (hig.dt != DateTime.MinValue)
                {
                    t              += (t == "" ? "" : " ") + hig.dt.ToString("yyyy/MM/dd HH:mm:ss");
                    yearList.Text   = hig.dt.Year.ToString(); monthList.Text = hig.dt.Month.ToString();
                    dayList.Text    = hig.dt.Day.ToString(); hourList.Text = hig.dt.Hour.ToString();
                    minuteList.Text = hig.dt.Minute.ToString(); secondList.Text = hig.dt.Second.ToString();
                }
                memoText.Text = t;
            }
            else
            {
                MessageBox.Show(hig.type == "official a" ? "公式放送でした" : "しっぱい");
            }
        }
Пример #3
0
        private bool isReserveAiLive(TimelineItem o, string lvid, HosoInfoGetter hig, List <AlartInfo> aiList, out RssItem ri)
        {
            string desc = "", comName = "", comId = "", hostName = "",
                   isMemberOnly = "false";
            bool isPayment      = false;

            if (hig != null)
            {
                desc         = hig.description;
                comName      = hig.group;
                comId        = hig.communityId;
                hostName     = o.actor.name;
                isMemberOnly = hig.isMemberOnly.ToString();
                isPayment    = hig.isPayment;
            }
            ri = new RssItem([email protected], lvid, hig.openDt.ToString(), desc, comName, comId, hostName, "", isMemberOnly, "", isPayment);
            if (hig != null)
            {
                ri.setUserId(hig.userId);
                ri.setTag(hig.tags);
                ri.category = hig.category;
                ri.type     = hig.type;
            }
            foreach (var ai in aiList)
            {
                if (!ai.isAutoReserve)
                {
                    continue;
                }

                var isSuccessAccess = true;
                var isAlart         = check.isAlartItem(ri, ai, out isSuccessAccess);
                if (isAlart || !isSuccessAccess)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #4
0
        private void addLiveListDay(string url, List <TanzakuItem> openTimeList)
        {
            try
            {
                var res = util.getPageSource(url);
                if (res == null)
                {
                    return;
                }

                var list = JsonConvert.DeserializeObject <timelineTop>(res);
                foreach (var l in list.timeline.stream_list)
                {
                    if (l.provider_type != "official")
                    {
                        continue;
                    }

                    l.startTime = DateTime.Parse(l.start_date + " " + l.start_time);
                    if ((l.status == "onair" || l.startTime > DateTime.Now.AddHours(-2)))
                    {
                        var listRi = timeTableList.Find(n => n.lvId == "lv" + l.id);
                        //if (((isAllCheck && l.status == "onair") || l.startTime > DateTime.Now.AddHours(-2)) && liveList.Find(n => n.lvId == l.id) == null) {

                        RssItem ri           = null;
                        var     opentimeItem = openTimeList.Find(x => x.id == "lv" + l.id);
                        if (opentimeItem != null)
                        {
                            ri = new RssItem(l.title, "lv" + l.id, opentimeItem.showTime.beginAt.ToString(),
                                             opentimeItem.description,
                                             opentimeItem.contentOwner.name,
                                             opentimeItem.socialGroupId,
                                             "",
                                             opentimeItem.thumbnailUrl, opentimeItem.isMemberOnly.ToString(), "");
                            ri.type      = "official";
                            ri.tags      = new string[] { "" };
                            ri.pubDateDt = opentimeItem.onAirTime.beginAt;
                            //if (!string.IsNullOrEmpty(hig.userName)) ri.hostName = hig.userName;
                            //if (hig.openDt != hig.dt) util.debugWriteLine("hig open start tigau " + hig.openDt + " " + hig.dt);
                            //else util.debugWriteLine("hig open start onaji " + hig.openDt + " " + hig.dt);
                        }
                        else
                        {
                            var hig = new HosoInfoGetter();
                            for (var i = 0; i < 2; i++)
                            {
#if DEBUG
                                if (i > 0)
                                {
                                    check.form.addLogText("timetable higget false " + l.id + " " + i);
                                }
#endif
                                var r = hig.get("https://live.nicovideo.jp/watch/lv" + l.id, check.container);
                                if (r)
                                {
                                    break;
                                }
                                Thread.Sleep(2000);
                            }
                            var _isFollow = false;
                            ri = new RssItem(l.title, "lv" + l.id, hig.dt.ToString(),
                                             hig.description,
                                             util.getCommunityName(hig.communityId, out _isFollow, null),
                                             hig.communityId,
                                             "",
                                             hig.thumbnail, "false", "");
                            ri.type      = hig.type;
                            ri.tags      = hig.tags;
                            ri.pubDateDt = hig.openDt;
                            if (!string.IsNullOrEmpty(hig.userName))
                            {
                                ri.hostName = hig.userName;
                            }
                            if (hig.openDt != hig.dt)
                            {
                                util.debugWriteLine("hig open start tigau " + hig.openDt + " " + hig.dt + " " + ri.lvId);
                            }
                            else
                            {
                                util.debugWriteLine("hig open start onaji " + hig.openDt + " " + hig.dt + " " + ri.lvId);
                            }
                        }

                        /*
                         * if (hig.openDt == DateTime.MinValue) {
                         *      if (ceCommingSoonRes == null) {
                         *              ceCommingSoonRes = util.getPageSource("http://api.ce.nicovideo.jp/liveapi/v1/video.comingsoon?__format=xml&from=0&limit=148&pt=official");
                         *              //ceCommingSoonRes = util.getPageSource("http://api.ce.nicovideo.jp/liveapi/v1/video.onairlist?__format=xml&from=0&limit=148&pt=official");
                         *              if (ceCommingSoonRes == null) continue;
                         *              ceCommingSoonRes = WebUtility.HtmlDecode(ceCommingSoonRes);
                         *      }
                         *      hig = new HosoInfoGetter();
                         *      var openDt = getOpenDt(l.id, ceCommingSoonRes);
                         *      if (l.startTime < DateTime.Now || openDt == DateTime.MinValue)
                         *              hig.openDt = l.startTime;
                         *      else hig.openDt = openDt;
                         * }
                         */


                        if (listRi == null)
                        {
                            timeTableList.Add(ri);
                        }
                        else
                        {
#if DEBUG
                            if (listRi.pubDateDt != ri.pubDateDt)
                            {
                                check.form.addLogText("timetable pubDateDt change " + DateTime.Now + " " + listRi.lvId + " " + listRi.pubDateDt + " " + ri.pubDateDt);
                                util.debugWriteLine("timetable pubDateDt change " + listRi.lvId + " " + listRi.pubDateDt + " " + ri.pubDateDt + " " + res);
                            }
#endif
                            listRi.pubDateDt = ri.pubDateDt;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
            }
        }
Пример #5
0
        void GetInfoFromHosoIdBtnClick(object sender, EventArgs e)
        {
            util.debugWriteLine("getInfoFromHosoIdBtnClick " + hosoIdText.Text);
            if (hosoIdText.Text == "")
            {
                return;
            }

            var    t  = hosoIdText.Text;
            string id = null;
            var    lv = util.getRegGroup(t, "(lv\\d+)");

            if (lv != null)
            {
                id = lv;
            }
            else
            {
                var coch = util.getRegGroup(t, "(c[oh]\\d+)");
                if (coch != null)
                {
                    id = coch;
                }
                else
                {
                    var user = util.getRegGroup(t, "user/(\\d+)");
                    if (user != null)
                    {
                        id = user;
                    }
                }
            }
            hosoIdText.Text = id;
            if (id == null || (!id.StartsWith("l") && !id.StartsWith("c")))
            {
                MessageBox.Show("しっぱい");
            }

            communityId.Text              = communityNameText.Text =
                userIdText.Text           = userNameText.Text = "";
            communityFollowChkBox.Checked = userFollowChkBox.Checked = false;

            var url = "https://live2.nicovideo.jp/watch/" + id;
            var hig = new HosoInfoGetter();

            hig.get(url, form.check.container);

            communityId.Text = hig.communityId;
            userIdText.Text  = hig.userId;
            GetCommunityInfoBtnClick(null, null);
            GetUserInfoBtnClick(null, null);

            try {
                if (hig.communityId == null && hig.userId == null)
                {
                    MessageBox.Show(hig.type == "official" ? "公式放送でした" : "しっぱい");
                }

                inputLvidItem = new RssItem(hig.title, id, hig.openDt.ToString(), hig.description, hig.group, hig.communityId, hig.userName, hig.thumbnail, hig.isMemberOnly.ToString(), "", hig.isPayment);
                inputLvidItem.setUserId(hig.userId);
                inputLvidItem.setTag(hig.tags);
                inputLvidItem.category  = hig.category;
                inputLvidItem.type      = hig.type;
                inputLvidItem.pubDateDt = hig.openDt;
                isInputLvidItemClosed   = hig.isClosed;
            } catch (Exception ee) {
                util.debugWriteLine(ee.Message + ee.Source + ee.Source + ee.StackTrace + ee.TargetSite);
            }

            /*
             * if (id.StartsWith("c")) {
             *      if (hig.communityId != null) {
             *              var isFollow = false;
             *              var name = util.getCommunityName(hig.communityId, out isFollow, form.check.container);
             *              communityId.Text = hig.communityId;
             *              if (name != null)
             *                      communityNameText.Text = name;
             *      }
             *      if (hig.userId != null) {
             *              var isFollow = false;
             *              var name = util.getUserName(hig.userId, out isFollow, form.check.container);
             *              if (name != null)
             *                      userNameText.Text = name;
             *      }
             * } else {
             *      communityId.Text = hig.communityId;
             *      userIdText.Text = hig.userId;
             *      GetCommunityInfoBtnClick(null, null);
             *      GetUserInfoBtnClick(null, null);
             *
             *      if (hig.communityId == null && hig.userId == null)
             *              MessageBox.Show(hig.type == "official" ? "公式放送でした" : "しっぱい");
             * }
             */
        }
Пример #6
0
        private void addLiveListDay(string url, List <TanzakuItem> openTimeList)
        {
            try {
                var            isAutoReserve = bool.Parse(check.form.config.get("IsAutoReserve"));
                var            aiList        = check.form.alartListDataSource.ToList();
                TimeLineInfo[] list          = null;
                string         res           = null;
                var            isNew         = true;
                if (isNew)
                {
                    url = "https://live.nicovideo.jp/timetable?date=" + url.Substring(url.IndexOf("=") + 1).Replace("-", "");
                    res = util.getPageSource(url);
                    if (res == null)
                    {
                        util.debugWriteLine("timetable zerotimeline res null");
                        check.form.addLogText("公式番組表からデータが取得できませんでした2 " + url);
                        return;
                    }
                    list = getNewTimeLineList(res);
                }
                else
                {
                    res = util.getPageSource(url);
                    if (res == null)
                    {
                        util.debugWriteLine("timetable zerotimeline res null");
                        //check.form.addLogText("公式番組表からデータが取得できませんでした " + url);
                        return;
                    }

                    list = JsonConvert.DeserializeObject <timelineTop>(res).timeline.stream_list;
                }

                foreach (var l in list)
                {
                    if (l.provider_type != "official")
                    {
                        continue;
                    }

                    l.startTime = DateTime.Parse(l.start_date + " " + l.start_time);
                    if ((l.status != "onair" && l.startTime < DateTime.Now.AddHours(-2)))
                    {
                        continue;
                    }

                    //if ((l.status == "onair" || l.startTime > DateTime.Now.AddHours(-2))) {
                    var listRi = timeTableList.Find(n => n.lvId == "lv" + l.id);
                    //if (((isAllCheck && l.status == "onair") || l.startTime > DateTime.Now.AddHours(-2)) && liveList.Find(n => n.lvId == l.id) == null) {

                    RssItem ri           = null;
                    var     opentimeItem = openTimeList.Find(x => x.id == "lv" + l.id);
                    if (opentimeItem != null)
                    {
                        ri = new RssItem(l.title, "lv" + l.id, opentimeItem.showTime.beginAt.ToString("yyyy/MM/dd HH:mm:ss"),
                                         opentimeItem.description,
                                         opentimeItem.contentOwner.name,
                                         opentimeItem.socialGroupId,
                                         "",
                                         opentimeItem.thumbnailUrl, opentimeItem.isMemberOnly.ToString(), "", l.isPayment);
                        ri.type      = "official";
                        ri.tags      = new string[] { "" };
                        ri.pubDateDt = opentimeItem.onAirTime.beginAt;
                        //if (!string.IsNullOrEmpty(hig.userName)) ri.hostName = hig.userName;
                        //if (hig.openDt != hig.dt) util.debugWriteLine("hig open start tigau " + hig.openDt + " " + hig.dt);
                        //else util.debugWriteLine("hig open start onaji " + hig.openDt + " " + hig.dt);
                    }
                    else
                    {
                        var hig = new HosoInfoGetter();
                        for (var i = 0; i < 2; i++)
                        {
                                                                #if DEBUG
                            if (i > 0)
                            {
                                check.form.addLogText("timetable higget false " + l.id + " " + i);
                            }
                                                                #endif
                            var r = hig.get("https://live.nicovideo.jp/watch/lv" + l.id, check.container);
                            if (r)
                            {
                                break;
                            }
                            Thread.Sleep(2000);
                        }
                        if (hig.openDt != DateTime.MinValue)
                        {
                            var _isFollow = false;
                            ri = new RssItem(l.title, "lv" + l.id, hig.dt.ToString("yyyy/MM/dd HH:mm:ss"),
                                             hig.description,
                                             util.getCommunityName(hig.communityId, out _isFollow, null),
                                             hig.communityId,
                                             "",
                                             hig.thumbnail, "false", "", hig.isPayment);
                            ri.type      = hig.type;
                            ri.tags      = hig.tags;
                            ri.pubDateDt = hig.openDt;
                            if (!string.IsNullOrEmpty(hig.userName))
                            {
                                ri.hostName = hig.userName;
                            }
                            if (hig.openDt != hig.dt)
                            {
                                util.debugWriteLine("hig open start tigau " + hig.openDt + " " + hig.dt + " " + ri.lvId);
                            }
                            else
                            {
                                util.debugWriteLine("hig open start onaji " + hig.openDt + " " + hig.dt + " " + ri.lvId);
                            }
                        }
                        else
                        {
                            util.debugWriteLine("not found time and page");
                            var dt = DateTime.Parse(l.start_date + " " + l.start_time);
                            ri = new RssItem(l.title, "lv" + l.id, dt.ToString("yyyy/MM/dd HH:mm:ss"),
                                             l.description,
                                             "",
                                             "",
                                             "",
                                             l.thumbnail_url, "false", "", l.isPayment);
                            ri.type      = l.provider_type;
                            ri.tags      = new string[] { "" };
                            ri.pubDateDt = dt;
                            //if (!string.IsNullOrEmpty(hig.userName)) ri.hostName = hig.userName;
                            //if (hig.openDt != hig.dt) util.debugWriteLine("hig open start tigau " + hig.openDt + " " + hig.dt + " " + ri.lvId);
                            //else util.debugWriteLine("hig open start onaji " + hig.openDt + " " + hig.dt + " " + ri.lvId);
                        }
                    }

                    /*
                     * if (hig.openDt == DateTime.MinValue) {
                     *      if (ceCommingSoonRes == null) {
                     *              ceCommingSoonRes = util.getPageSource("http://api.ce.nicovideo.jp/liveapi/v1/video.comingsoon?__format=xml&from=0&limit=148&pt=official");
                     *              //ceCommingSoonRes = util.getPageSource("http://api.ce.nicovideo.jp/liveapi/v1/video.onairlist?__format=xml&from=0&limit=148&pt=official");
                     *              if (ceCommingSoonRes == null) continue;
                     *              ceCommingSoonRes = WebUtility.HtmlDecode(ceCommingSoonRes);
                     *      }
                     *      hig = new HosoInfoGetter();
                     *      var openDt = getOpenDt(l.id, ceCommingSoonRes);
                     *      if (l.startTime < DateTime.Now || openDt == DateTime.MinValue)
                     *              hig.openDt = l.startTime;
                     *      else hig.openDt = openDt;
                     * }
                     */


                    if (listRi == null)
                    {
                        timeTableList.Add(ri);
                    }
                    else
                    {
                                                        #if DEBUG
                        if (listRi.pubDateDt != ri.pubDateDt)
                        {
                            check.form.addLogText("timetable pubDateDt change " + DateTime.Now + " " + listRi.lvId + " " + listRi.pubDateDt + " " + ri.pubDateDt);
                            util.debugWriteLine("timetable pubDateDt change " + listRi.lvId + " " + listRi.pubDateDt + " " + ri.pubDateDt + " " + res);
                        }
                                                        #endif
                        listRi.pubDateDt = ri.pubDateDt;
                    }

                    if (isAutoReserve)
                    {
                        foreach (var ai in aiList)
                        {
                            if (ai.isAutoReserve && ri.pubDateDt > DateTime.Now)
                            {
                                var isSuccessAccess = true;
                                var isAlart         = check.isAlartItem(ri, ai, out isSuccessAccess);
                                if (isAlart || !isSuccessAccess)
                                {
                                    var ret = new Reservation(check.container, ri.lvId, config).live2Reserve(bool.Parse(config.get("IsOverwriteOldReserve")));
                                    if (ret == "ok")
                                    {
                                        check.form.addLogText(ri.lvId + " " + ri.comName + (string.IsNullOrEmpty(ri.comName) ? (ri.title) : (ri.comName + "(" + ri.title + ")")) + "のタイムシフトを予約しました");
                                    }
                                    else
                                    {
                                        if (ret != "既に予約済みです。")
                                        {
                                            check.form.addLogText(ri.lvId + "(" + ri.comName + ")のタイムシフトの予約に失敗しました " + ret);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //}
                }
            } catch (Exception e) {
                util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
            }
        }
Пример #7
0
        private void process(List <string> lvList, TwitterInfo ti)
        {
            foreach (var lv in lvList)
            {
                try {
                    var     hig = new HosoInfoGetter();
                    RssItem item;
                    if (hig.get("https://live2.nicovideo.jp/watch/" + lv, form.check.container))
                    {
                        item = new RssItem(hig.title, lv, hig.openDt.ToString(), hig.description, hig.group, hig.communityId, hig.userName, null, hig.isMemberOnly ? "限定" : "", "", hig.isPayment);
                        item.setUserId(hig.userId);
                        item.setTag(hig.tags);
                        item.category = hig.category;
                        item.type     = hig.type;
                        if (hig.openDt < startTime || hig.openDt > DateTime.Now + TimeSpan.FromMinutes(3))
                        {
                            return;
                        }
                    }
                    else
                    {
                        item = new RssItem(lv, lv, DateTime.Now.ToString(), "", "", "",
                                           "", "", "", "", false);
                    }



                    form.check.checkedLvIdList.Add(item);
                    form.check.processedLvidList.Add(item.lvId);

                    if (ti.appliA && !form.notifyOffList[7])
                    {
                        var appliAPath = form.config.get("appliAPath");
                        var args       = form.config.get("appliAArgs");
                        TaskCheck.appliProcess(appliAPath, lv, args);
                    }
                    if (ti.appliB && !form.notifyOffList[8])
                    {
                        var appliBPath = form.config.get("appliBPath");
                        var args       = form.config.get("appliBArgs");
                        TaskCheck.appliProcess(appliBPath, lv, args);
                    }
                    if (ti.appliC && !form.notifyOffList[9])
                    {
                        var appliCPath = form.config.get("appliCPath");
                        var args       = form.config.get("appliCArgs");
                        TaskCheck.appliProcess(appliCPath, lv, args);
                    }
                    if (ti.appliD && !form.notifyOffList[10])
                    {
                        var appliDPath = form.config.get("appliDPath");
                        var args       = form.config.get("appliDArgs");
                        TaskCheck.appliProcess(appliDPath, lv, args);
                    }
                    if (ti.appliE && !form.notifyOffList[11])
                    {
                        var appliEPath = form.config.get("appliEPath");
                        var args       = form.config.get("appliEArgs");
                        TaskCheck.appliProcess(appliEPath, lv, args);
                    }
                    if (ti.appliF && !form.notifyOffList[12])
                    {
                        var appliFPath = form.config.get("appliFPath");
                        var args       = form.config.get("appliFArgs");
                        TaskCheck.appliProcess(appliFPath, lv, args);
                    }
                    if (ti.appliG && !form.notifyOffList[13])
                    {
                        var appliGPath = form.config.get("appliGPath");
                        var args       = form.config.get("appliGArgs");
                        TaskCheck.appliProcess(appliGPath, lv, args);
                    }
                    if (ti.appliH && !form.notifyOffList[14])
                    {
                        var appliHPath = form.config.get("appliHPath");
                        var args       = form.config.get("appliHArgs");
                        TaskCheck.appliProcess(appliHPath, lv, args);
                    }
                    if (ti.appliI && !form.notifyOffList[15])
                    {
                        var appliIPath = form.config.get("appliIPath");
                        var args       = form.config.get("appliIArgs");
                        TaskCheck.appliProcess(appliIPath, lv, args);
                    }
                    if (ti.appliJ && !form.notifyOffList[16])
                    {
                        var appliJPath = form.config.get("appliJPath");
                        var args       = form.config.get("appliJArgs");
                        TaskCheck.appliProcess(appliJPath, lv, args);
                    }
                    if (ti.popup && !form.notifyOffList[2])
                    {
                        TaskCheck.displayPopup(item, form);
                    }
                    if (ti.baloon && !form.notifyOffList[3])
                    {
                        TaskCheck.displayBaloon(item, form);
                    }
                    if (ti.browser && !form.notifyOffList[4])
                    {
                        TaskCheck.openBrowser(item, form);
                    }
                    if (ti.mail && !form.notifyOffList[5])
                    {
                        form.check.mail(item);
                    }
                    if (ti.sound && !form.notifyOffList[6])
                    {
                        TaskCheck.sound(form);
                    }
                    var hi = new HistoryInfo(item, null);
                    form.addHistoryList(hi);
                } catch (Exception e) {
                    util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                }
            }
        }
Пример #8
0
        private void checkTimeline()
        {
            util.debugWriteLine("auto reserve checktimeline");
            var    url            = "https://public.api.nicovideo.jp/v1/timelines/nicolive/last-1-month/my/android/entries.json";
            string min            = null;
            var    recentUpdateDt = DateTime.MinValue;
            var    aiList         = check.form.alartListDataSource.ToList();

            aiList.AddRange(check.form.userAlartListDataSource.ToList());
            for (var i = 0; i < 5; i++)
            {
                try {
                    util.debugWriteLine("autoreserve i " + i);
                    var _url = url + (min == null ? "" : ("?untilId=" + min));
                    var res  = util.getPageSource(_url, check.container);
                    if (res == null)
                    {
                        break;
                    }

                    var timelineObj = Newtonsoft.Json.JsonConvert.DeserializeObject <ActivityTimeline>(res);
                    if (timelineObj.meta.status != "200")
                    {
                        util.debugWriteLine("auto reserve check timeline not status 200 " + res);
                        break;
                    }
                    if (!string.IsNullOrEmpty(timelineObj.meta.minId))
                    {
                        min = timelineObj.meta.minId;
                    }
                    foreach (var o in timelineObj.data)
                    {
                        if (o.updated > recentUpdateDt)
                        {
                            recentUpdateDt = o.updated;
                        }
                        if (o.updated <= lastCheckedItemTime)
                        {
                            i = 5;
                            continue;
                        }

                        if (o.title.EndsWith("予約しました"))
                        {
                            util.debugWriteLine("autoreserve data item opentime " + o.updated + " " + o.title);
                            var lvid = util.getRegGroup([email protected], "(lv\\d+)");
                            if (lvid == null)
                            {
                                continue;
                            }
                            var pageUrl  = "https://live.nicovideo.jp/watch/" + lvid;
                            var hig      = new HosoInfoGetter();
                            var higGetOk = hig.get(pageUrl, check.container);
                            if ((higGetOk && hig.openDt > DateTime.Now) || !higGetOk)
                            {
                                RssItem ri = null;
                                if (!isReserveAiLive(o, lvid, higGetOk ? hig : null, aiList, out ri))
                                {
                                    continue;
                                }

                                var ret = new Reservation(check.container, lvid, config).live2Reserve(bool.Parse(config.get("IsOverwriteOldReserve")));
                                if (ret == "ok")
                                {
                                    check.form.addLogText(lvid + " " + o.actor.name + "(" + hig.title + ")のタイムシフトを予約しました");
                                    var hi = new HistoryInfo(ri);
                                    check.form.addReserveHistoryList(hi);
                                }
                                else
                                {
                                    if (ret != "既に予約済みです。")
                                    {
                                        check.form.addLogText(lvid + " " + o.actor.name + "(" + hig.title + ")のタイムシフトの予約に失敗しました " + ret);
                                    }
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                }
            }
            if (recentUpdateDt > lastCheckedItemTime)
            {
                lastCheckedItemTime = recentUpdateDt;
            }
        }
Пример #9
0
        void GetInfoFromHosoIdBtnClick(object sender, EventArgs e)
        {
            if (hosoIdText.Text == "")
            {
                return;
            }

            var    t  = hosoIdText.Text;
            string id = null;
            var    lv = util.getRegGroup(t, "(lv\\d+)");

            if (lv != null)
            {
                id = lv;
            }
            else
            {
                var coch = util.getRegGroup(t, "(c[oh]\\d+)");
                if (coch != null)
                {
                    id = coch;
                }
                else
                {
                    var user = util.getRegGroup(t, "user/(\\d+)");
                    if (user != null)
                    {
                        id = user;
                    }
                }
            }
            hosoIdText.Text = id;
            if (id == null || (!id.StartsWith("l") && !id.StartsWith("c")))
            {
                MessageBox.Show("しっぱい");
            }

            communityId.Text              = communityNameText.Text =
                userIdText.Text           = userNameText.Text = "";
            communityFollowChkBox.Checked = userFollowChkBox.Checked = false;

            var url = "https://live2.nicovideo.jp/watch/" + id;
            var hig = new HosoInfoGetter();

            hig.get(url, form.check.container);

            communityId.Text = hig.communityId;
            userIdText.Text  = hig.userId;
            GetCommunityInfoBtnClick(null, null);
            GetUserInfoBtnClick(null, null);

            if (hig.communityId == null && hig.userId == null)
            {
                MessageBox.Show(hig.type == "official" ? "公式放送でした" : "しっぱい");
            }

            /*
             * if (id.StartsWith("c")) {
             *      if (hig.communityId != null) {
             *              var isFollow = false;
             *              var name = util.getCommunityName(hig.communityId, out isFollow, form.check.container);
             *              communityId.Text = hig.communityId;
             *              if (name != null)
             *                      communityNameText.Text = name;
             *      }
             *      if (hig.userId != null) {
             *              var isFollow = false;
             *              var name = util.getUserName(hig.userId, out isFollow, form.check.container);
             *              if (name != null)
             *                      userNameText.Text = name;
             *      }
             * } else {
             *      communityId.Text = hig.communityId;
             *      userIdText.Text = hig.userId;
             *      GetCommunityInfoBtnClick(null, null);
             *      GetUserInfoBtnClick(null, null);
             *
             *      if (hig.communityId == null && hig.userId == null)
             *              MessageBox.Show(hig.type == "official" ? "公式放送でした" : "しっぱい");
             * }
             */
        }
Пример #10
0
        private List <LiveInfo> getOfficialLiveItems()
        {
            try {
                var r = util.getPageSource("https://live.nicovideo.jp/focus");
                if (r == null)
                {
                    foreach (var li in form.liveListDataSource)
                    {
                        if (li.type == "official")
                        {
                            li.lastExistTime = DateTime.Now;
                        }
                    }
                    foreach (var li in form.liveListDataReserve)
                    {
                        if (li.type == "official")
                        {
                            li.lastExistTime = DateTime.Now;
                        }
                    }
                    return(new List <LiveInfo>());
                }
                var m   = new Regex("id&quot;:&quot;(lv\\d+)").Matches(r);
                var ret = new List <LiveInfo>();
                foreach (Match _m in m)
                {
                    var lvid    = _m.Groups[1].Value;
                    var isAdded = false;
                    foreach (var li in form.liveListDataSource)
                    {
                        if (li.type != "official" && li.lvId == lvid)
                        {
                            li.lastExistTime = DateTime.Now;
                            isAdded          = true;
                        }
                    }
                    foreach (var li in form.liveListDataReserve)
                    {
                        if (li.type == "official" && li.lvId == lvid)
                        {
                            li.lastExistTime = DateTime.Now;
                            isAdded          = true;
                        }
                    }
                    if (isAdded)
                    {
                        continue;
                    }

                    var hig = new HosoInfoGetter();
                    var _r  = hig.get(lvid, null);
                    if (!_r)
                    {
                        continue;
                    }
                    if (hig.type != "official" || hig.openDt > DateTime.Now || hig.isClosed)
                    {
                        continue;
                    }

                    var ri = new RssItem(hig.title, lvid, hig.openDt.ToString(), hig.description, hig.group, hig.communityId, hig.userName, hig.thumbnail, hig.isMemberOnly.ToString(), "", hig.isPayment);
                    ri.type = "official";
                    ri.setUserId(hig.userId);
                    ri.tags      = new string[] { "" };
                    ri.pubDateDt = DateTime.Parse(ri.pubDate);
                    var _li = new LiveInfo(ri, form.alartListDataSource.ToArray(), form.config, form.userAlartListDataSource.ToArray());
                    ret.Add(_li);
                }
                return(ret);
            } catch (Exception e) {
                util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                return(new List <LiveInfo>());
            }
        }