{"id":1106,"date":"2010-05-27T16:39:00","date_gmt":"2010-05-27T08:39:00","guid":{"rendered":"\/?p=1106"},"modified":"2010-05-27T16:39:00","modified_gmt":"2010-05-27T16:39:00","slug":"1106","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/other\/1106.html","title":{"rendered":"\u767e\u5ea6MP3\u97f3\u4e50API\u63a5\u53e3\u53ca\u5e94\u7528"},"content":{"rendered":"

      \u5f53\u4f60\u5728\u767e\u5ea6\u53bb\u641c\u7d22\u4e00\u9996\u6b4c\u65f6,\u4f60\u4f1a\u53d1\u73b0\u6709\u79cd\u66f4\u7b80\u5355\u7684\u65b9\u6cd5,\u563f\u563f,\u5b89\u5b81\u30e4\u592a\u5929\u771f\u544a\u8bc9\u4f60\u4e2a\u79d8\u5bc6,\u767e\u5ea6\u6709\u4e2a\u4e0d\u516c\u5f00\u7684API<\/p>\n

http:\/\/box.zhangmen.baidu.com<\/strong>\/x?op=12&count=1&title=\u5927\u7ea6\u5728\u51ac\u5b63<\/font>$$\u9f50\u79e6<\/font>$$$$
\u7528\u4e0a\u9762\u7684\u5730\u5740,\u7ea2\u8272\u90e8\u5206\u6539\u6210\u6b4c\u540d\u4e0e\u4f5c\u8005\u540d,\u7136\u540e\u767e\u5ea6\u5c31\u4f1a\u7ed9\u4f60\u4e00\u4e2aXML:
<?xml version="1.0" encoding="gb2312" ?>
<result<\/font>>
  <count<\/font>>1<\/strong><\/count<\/font>>
<da<\/wbr>ta<\/font>>
<encode<\/font>>http:\/\/song.feifa-radio.com\/Q\/20050701\/jingxuan\/YjI$.Wma<\/strong><\/encode<\/font>> \u793e<\/span>
<decode<\/font>>1.Wma<\/strong><\/decode<\/font>>
<type<\/font>>2<\/strong><\/type<\/font>>
<lrcid<\/font>>49684<\/strong><\/lrcid<\/font>>
   <\/da<\/wbr>ta<\/font>>
<\/result<\/font>><\/p>\n

\u5176\u4e2d\u7684count \u503c\u4e3a1\u662f\u8bf4\u8fd4\u56de\u7684\u662f\u4e00\u4e2a,\u8fd9\u4e2a\u6ca1\u4ec0\u4e48\u7528,\u63a5\u4e0b\u6765\u7684\u4e1c\u897f\u5c31\u6709\u7528\u4e86,encode<\/font>\u91cc\u7684\u503c\u662f\u6b4c\u66f2\u52a0\u5bc6\u540e\u7684\u5730\u5740,\u52a0\u5bc6\u53ea\u662f\u5bf9\u6587\u4ef6\u540d\u52a0\u5bc6\u7684,\u6211\u4eec\u9700\u8981\u7684\u53ea\u662f\u524d\u9762\u7684\u8def\u5f84,\u4e5f\u5c31\u662f <\/font>http:\/\/song.feifa-radio.com\/Q\/20050701\/jingxuan\/ <\/strong>\u8fd9\u90e8\u5206,\u7136\u540e\u590d\u5236decode <\/font>\u7684\u503c: <\/font>1.Wma <\/strong>\u4e0e\u524d\u9762\u7684\u76f8\u62fc\u5c31\u662f\u6b63\u786e\u7684\u4e0b\u8f7d\u5730\u5740:<\/font><\/font><\/font><\/font><\/font>
http:\/\/song.feifa-radio.com\/Q\/20050701\/jingxuan\/1.Wma<\/strong><\/strong>
\u540e\u9762\u7684type<\/font>\u7684\u503c\u4e3a2\u8868\u793a\u6b64\u6b4c\u66f2\u6587\u4ef6\u7c7b\u578b\u662fwma\u7684,\u5176\u5b83\u7684:1\u8868\u793arm,0\u8868\u793aMP3,\u901a\u5e38\u6211\u4eec\u4e0b\u7684\u7c7b\u578b\u90fd\u662fMP3\u6216WMA\u7684,\u6240\u4ee5\u53ea\u8981\u67092\u62160\u7684<\/font><\/font>
lrcid<\/font>\u8fd9\u4e2a\u7684\u503c\u662f\u767e\u5ea6\u670d\u52a1\u5668\u4e0a\u8fd9\u9996\u6b4c\u7684\u6b4c\u8bcd\u6587\u4ef6\u7684\u6587\u4ef6\u540d,\u8fd9\u4e2a\u6587\u4ef6\u7684\u8def\u5f84\u662f:<\/font><\/font>http:\/\/box.zhangmen.baidu.com<\/strong>\/bdlrc<\/strong>\/496\/49684.lrc  <\/font><\/font><\/p>\n

\u8fd9\u4e2a\u5730\u5740\u89e3\u6790\u4e0b:<\/font>
http:\/\/box.zhangmen.baidu.com<\/strong>\/bdlrc<\/strong>\/ \u8fd9\u4e2a\u662f\u767e\u5ea6lrc\u6b4c\u8bcd\u5b58\u653e\u5730\u5740,\u540e\u9762\u7684496\u662f\u4e00\u4e2a\u7684\u4e0d\u5b9a\u7684,\u6c11\u5c31\u662f\u8bf4\u6b4c\u66f2\u4e0d\u540c\u90a3\u4e2a\u76ee\u5f55\u540d\u4e5f\u4e0d\u540c,\u5b83\u7684\u7b97\u6cd5\u662f\u62ff\u6b4c\u8bcd\u6587\u4ef6\u540d(\u4e5f\u5c31\u662f\u4e0a\u9762\u8bf4\u7684 49684<\/font><\/strong>) \u9664\u4ee5\u4e00\u767e,\u7136\u540e\u53d6\u5c0f\u4e8e\u7b49\u4e8e\u5176\u7ed3\u679c\u7684\u6700\u5927\u6574\u6570,\u5982\u4e0a\u9762\u7684:49684\/100 =496.84<\/strong> \u53d6<\/font><\/font>\u5c0f\u4e8e\u7b49\u4e8e496.84<\/strong> <\/font>\u7684\u6700\u5927\u6574\u6570\u5c31\u662f<\/font>496<\/strong><\/font>,\u4e8e\u662f\u8fd9\u9996\u6b4c\u5b8c\u6574\u7684\u6b4c\u8bcd\u5730\u5740\u5c31\u51fa\u6765\u4e86:http:\/\/box.zhangmen.baidu.com<\/strong>\/bdlrc<\/strong>\/496\/49684.lrc
<\/font><\/font><\/font><\/font>
\u5b89\u5b81\u30e4\u592a\u5929\u771f\u4f3c\u4e4e\u8bf4\u5f97\u590d\u6742\u4e86\u4e86,\u5475\u5475,\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u7528<\/p>\n

\u4f5c\u8005: \u5b89\u5b81\u30e4\u592a\u5929\u771f
\u7f51\u5740: http:\/\/hi.baidu.com\/kiss3344
\u7248\u6743\u6240\u6709\u3002\u8f6c\u8f7d\u65f6\u5fc5\u987b\u4ee5\u94fe\u63a5\u5f62\u5f0f\u6ce8\u660e\u4f5c\u8005\u548c\u539f\u59cb\u51fa\u5904\u53ca\u672c\u58f0\u660e\u3002<\/font><\/font><\/font><\/font><\/font><\/span><\/p>\n

<\/p>\n

\n

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Da<\/wbr>ta;
using System.Drawing;
using System.Text;
using System.Xml;
using System.Windows.Forms;<\/font><\/font><\/font><\/font><\/font><\/p>\n

namespace BaiDuAPI
{
   public partial class Form1 : Form
   {
       public Form1()
       {
           InitializeComponent();<\/font><\/font><\/font><\/font><\/font><\/p>\n

           this.skinEngine1.SkinFile = "vista1_green.ssk";
       }<\/font><\/font><\/font><\/font><\/font><\/p>\n

       private void button1_Click(object sender, EventArgs e)
       {
           System.Media.SoundPlayer sp = new System.Media.SoundPlayer();<\/font><\/font><\/font><\/font><\/font><\/p>\n

           <\/font><\/font><\/font><\/font><\/font><\/p>\n

           try
           {
               string strEncode = "";<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strDecode = "";<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strLrc = "";<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strExt = "";<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strPath = "";<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string[] AppString;<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string AppAPI = GetMP3URL(textBox4.Text);<\/font><\/font><\/font><\/font><\/font><\/p>\n

               if (AppAPI == "nothing")
               {
                   MessageBox.Show("\u627e\u4e0d\u5230\u97f3\u4e50 " + textBox4.Text + " \u8bf7\u66f4\u6362\u67e5\u8be2\u540d\u79f0");<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   return;
               }
               else
               {
                   AppString = AppAPI.Split("\u3000".ToCharArray());<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   strEncode = AppString[0].ToString();           \/\/\u7f16\u7801<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   strDecode = AppString[1].ToString();           \/\/\u89e3\u7801<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   strExt = AppString[2].ToString();              \/\/\u6269\u5c55\u540d<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   strLrc = AppString[3].ToString();              \/\/\u6b4c\u8bcdURL<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   strPath = AppString[4].ToString();             \/\/\u6b4c\u66f2URL<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   textBox1.Text = strEncode;<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   textBox2.Text = strDecode;<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   textBox3.Text = strPath;<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   textBox5.Text = strExt;<\/font><\/font><\/font><\/font><\/font><\/p>\n

                   textBox6.Text = strLrc;
               }
           }
           catch
           {
               MessageBox.Show("\u627e\u4e0d\u5230\u97f3\u4e50 " + textBox4.Text + " \u8bf7\u66f4\u6362\u67e5\u8be2\u540d\u79f0");
           }<\/font><\/font><\/font><\/font><\/font><\/p>\n

       }<\/font><\/font><\/font><\/font><\/font><\/p>\n

       public string GetMP3URL(string fString)
       {
           try
           {
               string strAPI = "http:\/\/box.zhangmen.baidu.com\/x?op=12&count=1&title<\/a>=";<\/font><\/font><\/font><\/font><\/font><\/p>\n

               strAPI = strAPI + fString;<\/font><\/font><\/font><\/font><\/font><\/p>\n

               XmlTextReader hfXMLReader = new XmlTextReader(strAPI);<\/font><\/font><\/font><\/font><\/font><\/p>\n

               DataSet ds = new DataSet();<\/font><\/font><\/font><\/font><\/font><\/p>\n

               ds.ReadXml(hfXMLReader);<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strDecode = ds.Tables["da<\/wbr>ta"].Rows[0]["decode"].ToString().Replace("\\n", "");         \/\/\u8bfb\u53d6\u6b4c\u66f2\u540d\u79f0<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strEncode = ds.Tables["da<\/wbr>ta"].Rows[0]["encode"].ToString().Replace("\\n", "");       \/\/\u8bfb\u53d6\u6b4c\u66f2\u7f16\u7801<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strLrc = ds.Tables["da<\/wbr>ta"].Rows[0]["lrcid"].ToString().Replace("<br \/>", "");             \/\/\u8bfb\u53d6\u6b4c\u8bcdID<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strPath = "";<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strExt = "";<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string[] strPre = strEncode.Split("\/".ToCharArray());<\/font><\/font><\/font><\/font><\/font><\/p>\n

               strPath = strEncode.Replace(strPre[strPre.Length – 1], strDecode);         \/\/\u8d4b\u503cMP3\u771f\u6b63\u5730\u5740<\/font><\/font><\/font><\/font><\/font><\/p>\n

               string strLrcPath = "http:\/\/box.zhangmen.baidu.com\/bdlrc\/<\/a>";                \/\/\u6b4c\u8bcd\u57fa\u672c\u5730\u5740<\/font><\/font><\/font><\/font><\/font><\/p>\n

               if (strLrc == "0")
               {
                   strLrc = "\u6682\u65e0\u6b4c\u8bcd";
               }
               else
               {
                   strLrc = strLrcPath + (Int32.Parse(strLrc) \/ 100).ToString() + "\/" + strLrc + ".lrc";
               }<\/font><\/font><\/font><\/font><\/font><\/p>\n

               switch (ds.Tables["da<\/wbr>ta"].Rows[0]["type"].ToString())
               {
                   case "1":
                       strExt = "rm";
                       break;
                   case "0":
                       strExt = "mp3";
                       break;
                   case "2":
                       strExt = "wma";
                       break;
               }<\/font><\/font><\/font><\/font><\/font><\/p>\n

               if (strEncode == "nothing")
               {
                   return "nothing";
               }<\/font><\/font><\/font><\/font><\/font><\/p>\n

               return strEncode + "\u3000" + strDecode + "\u3000" + strExt + "\u3000" + strLrc + "\u3000" + strPath;
           }
           catch
           {
               return GetMP3URL(fString);
           }
       }<\/font><\/font><\/font><\/font><\/font><\/p>\n

       private void button2_Click(object sender, EventArgs e)
       {
           string tempstr = "";<\/font><\/font><\/font><\/font><\/font><\/p>\n

           for (int i = 1; i < 11; i++)
           {
               tempstr += "1<<" + i.ToString() + ": " + (1 << i).ToString() + "\\r\\n";
           }<\/font><\/font><\/font><\/font><\/font><\/p>\n

           MessageBox.Show(tempstr);
       }<\/font><\/font><\/font><\/font><\/font><\/p>\n

       private void button2_Click_1(object sender, EventArgs e)
       {
           this.axWindowsMediaPlayer1.URL = textBox3.Text;
       }
   }<\/font><\/font><\/font><\/font><\/font><\/p>\n

\u539f\u6587:<\/strong>http:\/\/shuhejiang.blog.163.com\/blog\/static\/117667532009111533750457\/<\/font><\/font><\/font><\/font><\/font><\/p>\n<\/div>\n

<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

      \u5f53\u4f60\u5728\u767e\u5ea6\u53bb\u641c\u7d22\u4e00\u9996\u6b4c\u65f6,\u4f60\u4f1a\u53d1\u73b0\u6709\u79cd\u66f4\u7b80\u5355\u7684\u65b9\u6cd5,\u563f\u563f,\u5b89\u5b81\u30e4\u592a\u5929\u771f\u544a\u8bc9\u4f60\u4e2a\u79d8\u5bc6,\u767e\u5ea6\u6709\u4e2a\u4e0d\u516c\u5f00\u7684API<\/p>\n

http:\/\/box.zhangmen.baidu.com<\/strong>\/x?op=12&count=1&title=\u5927\u7ea6\u5728\u51ac\u5b63<\/font>$$\u9f50\u79e6<\/font>$$$$
\u7528\u4e0a\u9762\u7684\u5730\u5740,\u7ea2\u8272\u90e8\u5206\u6539\u6210\u6b4c\u540d\u4e0e\u4f5c\u8005\u540d,\u7136\u540e\u767e\u5ea6\u5c31\u4f1a\u7ed9\u4f60\u4e00\u4e2aXML:
<?xml version=<\/font><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1106"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1106"}],"version-history":[{"count":0,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1106\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}