コード例 #1
0
ファイル: Nico.cs プロジェクト: kazenif/NicoLive_v1_kai
        //-------------------------------------------------------------------------
        // GetSaleList
        //-------------------------------------------------------------------------
        public bool GetSaleList(string iLv, ref List<SaleList> iSaleList)
        {
            string url = "http://watch.live.nicovideo.jp/api/getsalelist?v=" + iLv;
            string xml = HttpGet(url, ref mCookieLogin);

            //Debug.WriteLine(xml);

            if (!xml.Contains("status=\"ok\""))
                return false;

            MatchCollection match;
            iSaleList = new List<SaleList>();
            match = Regex.Matches(xml, "<label>(.*?)</label>");
            if (match.Count > 0)
            {
                foreach (Match m in match)
                {
                    SaleList sale = new SaleList();
                    sale.mLabel = m.Groups[1].Value;
                    iSaleList.Add(sale);
                }
            }

            int n = 0;
            match = Regex.Matches(xml, "<code>(.*?)</code>");
            if (match.Count > 0)
            {
                foreach (Match m in match)
                {
                    SaleList sale = iSaleList[n];
                    sale.mCode = m.Groups[1].Value;
                    iSaleList[n++] = sale;
                }
            }

            n = 0;
            match = Regex.Matches(xml, "<num>(.*?)</num>");
            if (match.Count > 0)
            {
                foreach (Match m in match)
                {
                    SaleList sale = iSaleList[n];
                    sale.mNum = m.Groups[1].Value;
                    iSaleList[n++] = sale;
                }
            }

            n = 0;
            match = Regex.Matches(xml, "<price>(.*?)</price>");
            if (match.Count > 0)
            {
                foreach (Match m in match)
                {
                    SaleList sale = iSaleList[n];
                    sale.mPrice = m.Groups[1].Value;
                    iSaleList[n++] = sale;
                }
            }

            n = 0;
            match = Regex.Matches(xml, "</code><item>(.*?)</item>");
            if (match.Count > 0)
            {
                foreach (Match m in match)
                {
                    SaleList sale = iSaleList[n];
                    sale.mItem = m.Groups[1].Value;
                    iSaleList[n++] = sale;
                }
            }

            /*

            SaleList sale = new SaleList();
            using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml), false))
            using (XmlTextReader reader = new XmlTextReader(ms))
            {
                while (reader.Read())
                {

                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.LocalName.Equals("code"))
                            sale.mCode = reader.ReadString();
                        else if (reader.LocalName.Equals("num"))
                            sale.mNum = reader.ReadString();
                        else if (reader.LocalName.Equals("price"))
                            sale.mPrice = reader.ReadString();
                        else if (reader.LocalName.Equals("label"))
                            sale.mLabel = reader.ReadString();
                        else if (reader.LocalName.Equals("item")) ;
                            sale.mItem = reader.ReadString();
                    }
                    else if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        if (sale.mItem.Length  > 0)
                        {
                            iSaleList.Add(sale);
                            sale = new SaleList();
                        }
                    }
                }
            }
             */
            return true;
        }
コード例 #2
0
ファイル: Nico.cs プロジェクト: kazenif/NicoLive_v1_kai
        //-------------------------------------------------------------------------
        // Purchase
        //-------------------------------------------------------------------------
        public bool Purchase(string iLv, string iToken, SaleList iItem)
        {
            string url = "http://watch.live.nicovideo.jp/api/usepoint?v=" + iLv + "&code=" + iItem.mCode + "&item=" + iItem.mItem + "&token=" + iToken + "&num=" + iItem.mNum;
            string xml = HttpGet(url, ref mCookieLogin);

            Debug.WriteLine(xml);

            if (!xml.Contains("status=\"ok\""))
                return false;

            return true;
        }