Example #1
0
        public void start(bool isOnlyStartTimeCheck = false)
        {
            if (!isOnlyStartTimeCheck)
            {
                check.form.addLogText("カテゴリページからの取得を開始します");
            }
            var isFirst = true;

            while (isRetry)
            {
                //util.debugWriteLine("category check lastlv" + lastLv + " " + DateTime.Now);
                util.debugWriteLine("checked lv list start count " + check.checkedLvIdList.Count);

                try {
                    var items = new List <RssItem>();
                    items = getFoundLvList(isFirst, items, isStartTimeAllCheck);
                    if (isStartTimeAllCheck)
                    {
                        Task.Factory.StartNew(() => {
                            Thread.Sleep(100000);
                            items = getFoundLvList(true, items, true);
                            check.foundLive(items);
                        });
                    }

                    check.foundLive(items);
                    setDescription(items);
                    if (isOnlyStartTimeCheck)
                    {
                        return;
                    }

                    isStartTimeAllCheck = false;
                    isFirst             = false;


                    if (check.checkedLvIdList.Count > 20000)
                    {
                        check.deleteOldCheckedLvIdList();
                    }

                    var _t = int.Parse(config.get("rssUpdateInterval"));
                    if (_t < 15)
                    {
                        _t = 15;
                    }
                    Thread.Sleep(_t * 1000);
                } catch (Exception e) {
                    util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                }
            }
            check.form.addLogText("カテゴリページからの取得を終了します");
        }
Example #2
0
        public Image getThumbnail(string url, config.config config)
        {
            var isSaveCache = bool.Parse(config.get("liveListCacheIcon"));
            var isGetIcon   = bool.Parse(config.get("liveListGetIcon"));
            //return ThumbnailManager.getThumbnailRssUrl(url, isSaveCache);
            var img = ThumbnailManager.getThumbnailRssUrl(url, isSaveCache, isGetIcon);

            if (img == null)
            {
                return(null);
            }
            return(new Bitmap(img, 50, 50));
            //return null;
        }
Example #3
0
 private void sendPlayCommand(bool isDefaultPlayer)
 {
     Environment.SetEnvironmentVariable("SDL_AUDIODRIVER", "directsound", EnvironmentVariableTarget.Process);
     if (form.rec.hlsUrl.IndexOf("reconnecting") > -1 || form.rec.hlsUrl.IndexOf("end") > -1 || form.rec.hlsUrl == null)
     {
         return;
     }
     if (form.rec.hlsUrl.StartsWith("http"))
     {
         playCommand(config.get("anotherPlayerPath"), form.rec.hlsUrl);
     }
     else
     {
         playCommandStd(config.get("anotherPlayerPath"), form.rec.hlsUrl);
     }
 }
Example #4
0
        public RssCheck(Check check, config.config config)
        {
            isStartTimeAllCheck = bool.Parse(config.get("IsStartTimeAllCheck"));

            this.check  = check;
            this.config = config;
        }
Example #5
0
        public void start()
        {
            string pri, pub, _auth;

            pri = pub = _auth = null;

            pri            = config.get("pushPri");
            pub            = config.get("pushPub");
            _auth          = config.get("pushAuth");
            this.uaid      = config.get("pushUa");
            this.channelId = config.get("pushChId");

            if (pri == "" || pub == "" ||
                _auth == "" || uaid == "" ||
                channelId == "")
            {
                privateKey = publicKey = auth = null;
                uaid       = channelId = null;

                clearConfigSetting();

                try
                {
                    pc.generateKey(out privateKey, out publicKey);
                    config.set("pushPri", Convert.ToBase64String(privateKey));
                    config.set("pushPub", Convert.ToBase64String(publicKey));
                }
                catch (Exception e)
                {
                    util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                    return;
                }
                //auth = pc.generateAuth();
                //				config.set("pushAuth", Convert.ToBase64String(auth));
            }
            else
            {
                privateKey = Convert.FromBase64String(pri);
                publicKey  = Convert.FromBase64String(pub);
                auth       = Convert.FromBase64String(_auth);
            }
            connect();
        }
        private void endProcess(int endCode, bool isSameRfu)
        {
            if (endCode == 3 && bool.Parse(cfg.get("IsSoundEnd")))
            {
                util.soundEnd(cfg, form);
            }

            if (isSameRfu)
            {
                isRecording = false;
                rfu         = null;
                setRecModeForm(false);

                if (form.recEndProcess != null && endCode == 3)
                {
                    form.formAction(() =>
                                    util.shutdown(form.recEndProcess));
                }

                util.debugWriteLine("end rec " + rfu);
                if (!isClickedRecBtn && endCode == 3)
                {
                    Environment.ExitCode = 5;

                    if (util.isShowWindow && bool.Parse(cfg.get("IscloseExit")))
                    {
                        form.close();
                    }
                }
                hlsUrl       = null;
                recordingUrl = null;
            }
            if (bool.Parse(cfg.get("IscloseExit")) && endCode == 3)
            {
                rfu = null;
                Environment.ExitCode = 5;
                form.close();
            }
            if (util.isStdIO && (endCode == 0 || endCode == 2 || endCode == 3))
            {
                form.close();
            }
        }
Example #7
0
        public void start()
        {
            var id    = config.get("appPushId");
            var token = config.get("appPushToken");

            if (id == "" || token == "")
            {
                id = token = null;

                clearConfigSetting();

                if (!getOkIdToken(out id, out token))
                {
                    check.form.addLogText("スマホ通知のIDが取得できませんでした");
                    return;
                }
                config.set("appPushId", id);
                config.set("appPushToken", token);
            }
            connect(id, token);
        }
Example #8
0
        public bool add(string t)
        {
            util.debugWriteLine("rlm add");

            var lvid = util.getRegGroup(t, "(lv\\d+(,\\d+)*)");
            //util.setLog(cfg, lv);

            var url = "";

            if (lvid != null)
            {
                url = "https://live2.nicovideo.jp/watch/" + lvid;

                try {
                    if (bool.Parse(cfg.get("IsDuplicateConfirm")))
                    {
                        var delList = new List <RecInfo>();
                        foreach (RecInfo d in recListData)
                        {
                            if (d.id == lvid)
                            {
                                delList.Add(d);
                            }
                        }

                        foreach (var _ri in delList)
                        {
                            if (MessageBox.Show(_ri.id + "はリスト内に含まれています。既にある行を削除しますか?\n[" + _ri.quality + "] [" + _ri.timeShift + "]", "確認", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                form.deleteRow(_ri);
                            }
                        }
                    }
                } catch (Exception e) {
                    util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                }
            }
            else
            {
                MessageBox.Show("not found lvID");
                return(false);
            }
            //if (lvid != null) form.urlText.Text = "https://cas.nicovideo.jp/user/77252622/lv313508832";

            var rdg = new RecDataGetter(this);
            var ri  = new RecInfo(lvid, t, rdg, form.afterConvertModeList.Text, form.setTsConfig, form.setTimeshiftBtn.Text, form.qualityBtn.Text, form.qualityRank, form.recCommmentList.Text, form.isChaseChkBox.Checked);

            Task.Run(() => ri.setHosoInfo(form));

            form.addList(ri);

            return(true);
        }
Example #9
0
        public void play()
        {
            util.debugWriteLine("play");
            isUsePlayer        = bool.Parse(config.get("IsUsePlayer"));
            isUseCommentViewer = bool.Parse(config.get("IsUseCommentViewer"));

            if (form.playerBtn.Text == "視聴")
            {
                form.playerBtn.Text = "視聴停止";
                lastPlayUrl         = null;

                Task.Run(() => {
                    if (!getHlsUrl())
                    {
                        //end();
                        form.Invoke((MethodInvoker) delegate() {
                            setPlayerBtnText("視聴");
                            form.recBtn.Enabled = true;
                        });
                        //form.rec.rfu.isPlayOnlyMode = false;
                        return;
                    }

                    if (isUsePlayer)
                    {
                        videoPlay(true);
                    }
                    if (isUseCommentViewer)
                    {
                        commentPlay(true);
                    }
                });
            }
            else
            {
                end();
            }
        }
Example #10
0
        public CategoryCheck(Check check, config.config config)
        {
            isStartTimeAllCheck = bool.Parse(config.get("IsStartTimeAllCheck"));

            this.check  = check;
            this.config = config;


            urls = new string[4];
            for (var i = 0; i < categoryNames.Length; i++)
            {
                urls[i] = "https://live.nicovideo.jp/front/api/pages/recent/v1/programs?tab=" + categoryNames[i] + "&offset=#&sortOrder=recentDesc";
            }
        }
Example #11
0
        public LiveInfo(RssItem item,
                        SortableBindingList <AlartInfo> alartData,
                        config.config config,
                        SortableBindingList <AlartInfo> userAlartData)
        {
            var ri = item;

            title        = ri.title;
            lvId         = ri.lvId;
            pubDateDt    = DateTime.Parse(ri.pubDate);
            description  = ri.description;
            thumbnail    = getThumbnail(ri.thumbnailUrl, bool.Parse(config.get("liveListCacheIcon")));
            thumbnailUrl = ri.thumbnailUrl;
            comName      = ri.comName;
            comId        = ri.comId;
            memberOnly   = ri.isMemberOnly ? "限定" : "";
            type         = ri.type;
            if (type == "user")
            {
                type = "community";
            }

            category = ri.category != null ? ri.category : new List <string>()
            {
                "一般(その他)"
            };

            hostName = ri.hostName;

            favorite = getFavorite(alartData, ri, favorite);
            favorite = getFavorite(userAlartData, ri, favorite);

            /*
             * var b = (byte[])new ImageConverter().ConvertTo(thumbnail, typeof(byte[]));
             * b = System.Text.Encoding.UTF8.GetBytes("あああああああああああああ");
             * byte[] outb;
             * using (var m = new MemoryStream()) {
             *      //m.Write(b, 0, b.Length);
             *      using (var d = new DeflateStream(m, CompressionMode.Compress, true)) {
             *              d.Write(b, 0, b.Length);
             *              d.Close();
             *              outb = m.ToArray();
             *      }
             *
             * }
             */
        }
Example #12
0
        private TimeShiftConfig getTimeShiftConfig(string host,
                                                   string group, string title, string lvId, string communityNum,
                                                   string userId, config.config cfg, long startTime, bool isChase,
                                                   long openTime)
        {
            var segmentSaveType = cfg.get("segmentSaveType");
            var lastFile        = util.getLastTimeshiftFileName(host,
                                                                group, title, lvId, communityNum, userId, cfg, startTime, isFmp4);

            util.debugWriteLine("timeshift lastfile " + lastFile);
            string[] lastFileTime = util.getLastTimeShiftFileTime(lastFile, segmentSaveType, isFmp4);
            if (lastFileTime == null)
            {
                util.debugWriteLine("timeshift lastfiletime " +
                                    ((lastFileTime == null) ? "null" : string.Join(" ", lastFileTime)));
            }

            try {
                var prepTime = (int)(startTime - openTime);
                var o        = new TimeShiftOptionForm(lastFileTime, segmentSaveType, rm.cfg, isChase, prepTime, isFmp4);


                try {
                    rm.form.formAction(() => {
                        try {
                            o.ShowDialog(rm.form);
                        } catch (Exception e) {
                            util.debugWriteLine("timeshift option form invoke " + e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                        }
                    }, false);
                } catch (Exception e) {
                    util.debugWriteLine("timeshift option form invoke try " + e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                }

                //if (o.ret == null) return null;
                return(o.ret);
            } catch (Exception ee) {
                util.debugWriteLine(ee.Message + " " + ee.StackTrace);
            }
            return(null);
        }
Example #13
0
        async public Task <CookieContainer[]> getHtml5RecordCookie(string url, bool isSub = false)
        {
            CookieContainer cc;

            var num = isSub ? "2" : "";

            cc = await getCookieContainer(cfg.get("BrowserNum" + num),
                                          cfg.get("issecondlogin" + num), cfg.get("accountId" + num),
                                          cfg.get("accountPass" + num), cfg.get("user_session" + num),
                                          cfg.get("user_session_secure" + num), isSub,
                                          url);

            if (cc != null)
            {
                var c        = cc.GetCookies(TargetUrl)["user_session"];
                var secureC  = cc.GetCookies(TargetUrl)["user_session_secure"];
                var age_auth = cc.GetCookies(TargetUrl)["age_auth"];

                var l = new List <KeyValuePair <string, string> >();
                if (c != null)
                {
//						cfg.set("user_session", c.Value);
                    l.Add(new KeyValuePair <string, string>("user_session" + num, c.Value));
                }
                if (secureC != null)
                {
//						cfg.set("user_session_secure", secureC.Value);
                    l.Add(new KeyValuePair <string, string>("user_session_secure" + num, secureC.Value));
                }
                if (age_auth != null)
                {
                    l.Add(new KeyValuePair <string, string>("age_auth", age_auth.Value));
                }
                cfg.set(l);
            }


            var ret = new CookieContainer[] { cc };

            return(ret);
        }
Example #14
0
        private TimeShiftConfig getTimeShiftConfig(string host,
                                                   string group, string title, string lvId, string communityNum,
                                                   string userId, config.config cfg, long _openTime)
        {
            var segmentSaveType = cfg.get("segmentSaveType");
            var lastFile        = util.getLastTimeshiftFileName(host,
                                                                group, title, lvId, communityNum, userId, cfg, _openTime);

            util.debugWriteLine("timeshift lastfile " + lastFile + util.getMainSubStr(isSub, true));
            string[] lastFileTime = util.getLastTimeShiftFileTime(lastFile, segmentSaveType);
            if (lastFileTime == null)
            {
                util.debugWriteLine("timeshift lastfiletime " +
                                    ((lastFileTime == null) ? "null" : string.Join(" ", lastFileTime)));
            }

            try {
                var o = new TimeShiftOptionForm(lastFileTime, segmentSaveType, rm.cfg);

                try {
                    rm.form.Invoke((MethodInvoker) delegate() {
                        try {
                            o.ShowDialog(rm.form);
                        } catch (Exception e) {
                            util.debugWriteLine("timeshift option form invoke " + e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite + util.getMainSubStr(isSub, true));
                        }
                    });
                } catch (Exception e) {
                    util.debugWriteLine("timeshift option form invoke try " + e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite + util.getMainSubStr(isSub, true));
                }

                //if (o.ret == null) return null;
                return(o.ret);
            } catch (Exception ee) {
                util.debugWriteLine(ee.Message + " " + ee.StackTrace + util.getMainSubStr(isSub, true));
            }
            return(null);
        }
Example #15
0
        public void start()
        {
            check.form.addLogText("RSSからの取得を開始します");
            var url = "https://live.nicovideo.jp/recent/rss?tab=&p=";

            while (isRetry)
            {
                util.debugWriteLine("rss check lastlv" + lastLv + " " + DateTime.Now);
                util.debugWriteLine("checked lv list start count " + check.checkedLvIdList.Count);
                var items = new List <RssItem>();
                var end   = 1000;
                for (var i = 1; i < 100 && i < end; i++)
                {
                    util.debugWriteLine("rss page i " + i);
                    var res = util.getPageSource(url + i.ToString(), null);
                    if (res == null)
                    {
                        var t = int.Parse(config.get("rssUpdateInterval"));
                        if (t < 15)
                        {
                            t = 15;
                        }
                        Thread.Sleep(t * 1000);
                        break;
                    }
                    var isEndFile = false;
                    if (!getRssItems(res, ref items, ref isEndFile))
                    {
                        if (end == 1000 &&
                            (!isStartTimeAllCheck || lastLv != null))
                        {
                            end = i + 5;
                        }
//						break;
                    }
                    if (isEndFile)
                    {
                        break;
                    }
                    if (lastLv == null && !isStartTimeAllCheck)
                    {
                        break;
                    }
                }
                if (items.Count > 0)
                {
                    lastLv = items[0].lvId;
                }


                util.debugWriteLine("checked lv list count " + check.checkedLvIdList.Count);
                util.debugWriteLine("get rss items " + items.Count);
                if (items.Count > -1)
                {
                    foreach (RssItem it in items)
                    {
                        util.debugWriteLine(it.lvId + " " + it.comId + " " + it.hostName + " " + it.title + " " + it.pubDate);
                    }
                }

                check.foundLive(items);

                if (check.checkedLvIdList.Count > 20000)
                {
                    check.deleteOldCheckedLvIdList();
                }

                var _t = int.Parse(config.get("rssUpdateInterval"));
                if (_t < 15)
                {
                    _t = 15;
                }
                Thread.Sleep(_t * 1000);
            }
            check.form.addLogText("RSSからの取得を終了します");
        }
Example #16
0
        async public Task <CookieContainer[]> getHtml5RecordCookie(string url, bool isSub)
        {
            this.isSub = isSub;

            CookieContainer cc;

            if (!isSub)
            {
                cc = await getCookieContainer(cfg.get("BrowserNum"),
                                              cfg.get("issecondlogin"), cfg.get("accountId"),
                                              cfg.get("accountPass"), cfg.get("user_session"),
                                              cfg.get("user_session_secure"), false,
                                              url);

                if (cc != null)
                {
                    var c       = cc.GetCookies(TargetUrl)["user_session"];
                    var secureC = cc.GetCookies(TargetUrl)["user_session_secure"];

                    var l = new List <KeyValuePair <string, string> >();
                    if (c != null)
                    {
//						cfg.set("user_session", c.Value);
                        l.Add(new KeyValuePair <string, string>("user_session", c.Value));
                    }
                    if (secureC != null)
                    {
//						cfg.set("user_session_secure", secureC.Value);
                        l.Add(new KeyValuePair <string, string>("user_session_secure", secureC.Value));
                    }
                    cfg.set(l);
                }
            }
            else
            {
                cc = await getCookieContainer(cfg.get("BrowserNum2"),
                                              cfg.get("issecondlogin2"), cfg.get("accountId2"),
                                              cfg.get("accountPass2"), cfg.get("user_session2"),
                                              cfg.get("user_session_secure2"), true,
                                              url);

                if (cc != null)
                {
                    var c       = cc.GetCookies(TargetUrl)["user_session2"];
                    var secureC = cc.GetCookies(TargetUrl)["user_session_secure2"];

                    var l = new List <KeyValuePair <string, string> >();
                    if (c != null)
                    {
//						cfg.set("user_session2", c.Value);
                        l.Add(new KeyValuePair <string, string>("user_session2", c.Value));
                    }
                    if (secureC != null)
                    {
//						cfg.set("user_session_secure2", secureC.Value);
                        l.Add(new KeyValuePair <string, string>("user_session_secure2", secureC.Value));
                    }
                    cfg.set(l);
                }
            }

            var ret = new CookieContainer[] { cc };

            return(ret);
        }
Example #17
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);
            }
        }
Example #18
0
        //byte[] deflateThumb = null;
        //Image testImg = null;

        public LiveInfo(List <KeyValuePair <string, string> > item, SortableBindingList <AlartInfo> alartData, config.config config, SortableBindingList <AlartInfo> userAlartData)
        {
            foreach (var l in item)
            {
                try
                {
                    if (l.Key == "title")
                    {
                        title = l.Value;
                    }
                    else if (l.Key == "guid")
                    {
                        lvId = l.Value;
                    }
                    else if (l.Key == "pubDate")
                    {
                        pubDateDt = DateTime.Parse(l.Value);
                    }
                    else if (l.Key == "description")
                    {
                        description = l.Value;
                    }
                    else if (l.Key == "category")
                    {
                        category.Add(l.Value);
                    }
                    else if (l.Key == "thumbnail")
                    {
                        thumbnail    = getThumbnail(l.Value, bool.Parse(config.get("liveListCacheIcon")));
                        thumbnailUrl = l.Value;
                    }
                    else if (l.Key == "community_name")
                    {
                        comName = l.Value;
                    }
                    else if (l.Key == "community_id")
                    {
                        comId = l.Value;
                    }
                    else if (l.Key == "member_only")
                    {
                        memberOnly = bool.Parse(l.Value) ? "限定" : "";
                    }
                    //else if (l.Key == "community_id") comId = l.Value;
                    else if (l.Key == "type")
                    {
                        type = l.Value;
                        if (type == "user")
                        {
                            type = "community";
                        }
                    }
                    else if (l.Key == "owner_name")
                    {
                        hostName = l.Value;
                    }
                    //else if (l.Key == "type") type = l.Value;
                    else
                    {
                        var pass = new string[] { "creator", "link",
                                                  "num_res", "view" };
                        if (Array.IndexOf(pass, l.Key) > -1)
                        {
                            continue;
                        }
                    }
                }
                catch (Exception e)
                {
                    util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                }
            }
            var ri = new RssItem(title, lvId, "", description, comName, comId, hostName, thumbnailUrl, memberOnly, "");

            favorite = getFavorite(alartData, ri, favorite);
            favorite = getFavorite(userAlartData, ri, favorite);

            if (category == null)
            {
                util.debugWriteLine("not found category 11 " + lvId);
                category = new List <string>()
                {
                    "一般(その他)"
                };
            }

            //thumbnailUrl = getThumbnail(comId);



            //deflateThumb = b;
            //testImg = new Bitmap(thumbnail);
        }
Example #19
0
        /*
         * async Task<int> test(int a) {
         *      //util.debugWriteLine(a);
         *      //c += a;
         *      return a;
         * }
         */
        async public void rec()
        {
            util.debugWriteLine("rm");


            var lv     = util.getRegGroup(form.urlText.Text, "(lv\\d+(,\\d+)*)");
            var wssUrl = util.getRegGroup(form.urlText.Text, "^(wss://[^,\\s]+)");

            util.setLog(cfg, lv);
            util.debugWriteLine(util.versionStr + " " + util.versionDayStr);

            if (rfu == null)
            {
                var arr = form.urlText.Text.Split('|');
//              var arr = "C:\\Users\\zack\\Desktop\\c#project\\nicoNewStreamRecorderKakkoKariRepo2 9.26 tuujou a\\nicoNewStreamRecorderKakkoKari\\namaichi\\bin\\Debug\\rec\\株式会社ジャパンミュージックエージェンシー\\株式会社ジャパンミュージックエージェンシー_0.ts".Split('|');



                var lvid = lv;                //util.getRegGroup(form.urlText.Text, "(lv\\d+(,\\d+)*)", 1);
                if (lvid != null || wssUrl != null)
                {
                    var url = lvid != null ? ("http://live2.nicovideo.jp/watch/" + lvid) : wssUrl;
                    if (isPlayOnlyMode)
                    {
                        form.Invoke((MethodInvoker) delegate() {
                            form.urlText.Text = url;
                        });
                    }
                    else
                    {
                        form.urlText.Text = url;
                    }

//				if (lvid != null) form.urlText.Text = "https://cas.nicovideo.jp/user/77252622/lv313508832";
                }
                else
                {
                    if (isPlayOnlyMode)
                    {
                        form.Invoke((MethodInvoker) delegate() {
                            MessageBox.Show("not found lvid");
                        });
                    }
                    else
                    {
                        MessageBox.Show("not found lvid");
                    }
                    return;
                }

                form.setQualityList(new string[] {}, "");
                var q = form.qualityBox.Items;

                isRecording = true;
                if (isPlayOnlyMode)
                {
                    form.Invoke((MethodInvoker) delegate() {
                        form.recBtn.Text            = "中断";
                        form.urlText.Enabled        = false;
                        form.optionMenuItem.Enabled = false;

                        //form.resetDisplay();
                        recordingUrl = form.urlText.Text;
                    });
                }
                else
                {
                    form.recBtn.Text            = "中断";
                    form.urlText.Enabled        = false;
                    form.optionMenuItem.Enabled = false;

                    //form.resetDisplay();
                    recordingUrl = form.urlText.Text;
                }

                rfu = new RecordFromUrl(this);
                Task.Run(() => {
                    try {
                        var _rfu = rfu;
                        util.debugWriteLine("rm rec 録画開始" + rfu);

                        util.debugWriteLine(form);
                        util.debugWriteLine(form.urlText);
                        util.debugWriteLine(form.urlText.Text);

                        var rfuCode = rfu.GetHashCode();
                        recordRunningList.Add(rfuCode);
                        //endcode 0-その他の理由 1-stop 2-最初に終了 3-始まった後に番組終了
                        var endCode = rfu.rec(form.urlText.Text, lvid, wssUrl);
                        util.debugWriteLine("endcode " + endCode);
                        recordRunningList.Remove(rfuCode);

                        if (rfu == _rfu)
                        {
                            isRecording = false;
                            rfu         = null;
                            if (!form.IsDisposed && util.isShowWindow)
                            {
                                try {
                                    form.Invoke((MethodInvoker) delegate() {
                                        try {
                                            form.recBtn.Text            = "録画開始";
                                            form.urlText.Enabled        = true;
                                            form.optionMenuItem.Enabled = true;
                                        } catch (Exception e) {
                                            util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                                        }
                                    });
                                } catch (Exception e) {
                                    util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                                }
                            }

                            util.debugWriteLine("end rec " + rfu);
                            if (!isClickedRecBtn && endCode == 3)
                            {
                                Environment.ExitCode = 5;
                                if (util.isShowWindow)
                                {
                                    try {
                                        form.Invoke((MethodInvoker) delegate() {
                                            try {
                                                form.Close();
                                            } catch (Exception e) {
                                                util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                                            }
                                        });
                                    } catch (Exception e) {
                                        util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                                    }
                                }
                            }
                            hlsUrl = null;

                            recordingUrl = null;
                        }
                        if (bool.Parse(cfg.get("IscloseExit")) && endCode == 3)
                        {
                            rfu = null;
                            Environment.ExitCode = 5;
                            if (util.isShowWindow)
                            {
                                try {
                                    form.Invoke((MethodInvoker) delegate() {
                                        try {
                                            form.Close();
                                            form.addLogText("終了しました。");
                                        } catch (Exception e) {
                                            util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                                        }
                                    });
                                } catch (Exception e) {
                                    util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                                }
                            }
                        }
                        if (util.isStdIO && (endCode == 0 || endCode == 2 || endCode == 3))
                        {
                            form.Invoke((MethodInvoker) delegate() {
                                try {
                                    form.Close();
                                } catch (Exception e) {
                                    util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                                }
                            });
                        }
                    } catch (Exception e) {
                        util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                        rfu = null;
                        form.Invoke((MethodInvoker) delegate() {
                            try {
                                form.recBtn.Text            = "録画開始";
                                form.urlText.Enabled        = true;
                                form.optionMenuItem.Enabled = true;
                            } catch (Exception ee) {
                                util.debugWriteLine(ee.Message + " " + ee.StackTrace + " " + ee.Source + " " + ee.TargetSite);
                            }
                        });
                    }
                });
            }
            else
            {
                stopRecording();
            }
        }
Example #20
0
        public void start()
        {
            check.form.addLogText("カテゴリページからの取得を開始します");
            var isFirst = true;

            while (isRetry)
            {
                //util.debugWriteLine("category check lastlv" + lastLv + " " + DateTime.Now);
                util.debugWriteLine("checked lv list start count " + check.checkedLvIdList.Count);

                try
                {
                    var items = new List <RssItem>();
                    for (var j = 0; j < urls.Length; j++)
                    {
                        var url = urls[j];

                        var end = 1000;
                        for (var i = 0; i < 1000 && i < end; i++)
                        {
                            util.debugWriteLine("category page i " + i + " " + url);


                            var res = util.getPageSource(url.Replace("#", i.ToString()), null);
                            if (res == null)
                            {
                                var t = int.Parse(config.get("rssUpdateInterval"));
                                if (t < 15)
                                {
                                    t = 15;
                                }
                                Thread.Sleep(t * 1000);
                                break;
                            }
                            var isEndFile        = false;
                            var isContainAddedLv = getRssItems(res, ref items, ref isEndFile, categoryNames[j]);
                            if (isContainAddedLv)
                            {
                                var isContainLv = items.FindIndex(x => check.checkedLvIdList.IndexOf(x.lvId) > -1) != -1;
                                if (end == 1000 &&
                                    (!isStartTimeAllCheck || (isContainLv)) &&
                                    !isStartTimeAllCheck)
                                {
                                    end = i + 1;
                                }
                                //						break;
                            }
                            if (isEndFile)
                            {
                                break;
                            }
                            if (isFirst && !isStartTimeAllCheck)
                            {
                                break;
                            }
                        }
                        //if (items.Count > 0)
                        //	lastLv = items[0].lvId;

                        util.debugWriteLine("checked lv list count " + check.checkedLvIdList.Count);
                        util.debugWriteLine("get category items " + items.Count);
                        if (items.Count > -1)
                        {
                            foreach (RssItem it in items)
                            {
                                util.debugWriteLine(it.lvId + " " + it.comId + " " + it.hostName + " " + it.title + " " + it.pubDate);
                            }
                        }
                    }
                    check.foundLive(items);
                    setDescription(items);

                    isStartTimeAllCheck = false;
                    isFirst             = false;


                    if (check.checkedLvIdList.Count > 20000)
                    {
                        check.deleteOldCheckedLvIdList();
                    }

                    var _t = int.Parse(config.get("rssUpdateInterval"));
                    if (_t < 15)
                    {
                        _t = 15;
                    }
                    Thread.Sleep(_t * 1000);
                }
                catch (Exception e)
                {
                    util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                }
            }
            check.form.addLogText("カテゴリページからの取得を終了します");
        }
Example #21
0
 public TimeTableChecker(Check check, config.config config)
 {
     isAllCheck  = bool.Parse(config.get("IsStartTimeAllCheck"));
     this.check  = check;
     this.config = config;
 }
Example #22
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;
            }
        }