麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

C# 歌詞自動下載顯示代碼

2019-11-17 04:12:38
字體:
來源:轉載
供稿:網友

歌詞下載:

view plaincopy to clipboardPRint?
//Foxer_Player_App_Author: CT.ThEN  
//Foxer_Player_App_BuildTime: Otc,12,2008  
//Foxer_Player_App_Version: 1.01  
//Foxer_Player_App_Author_email: [email protected]  
//Foxer_Player_App_Author_schoolID: 2740610812  
//Foxer_Player_lrc_down:download_lrc_form_web  
using System;  
using System.Collections.Generic;  
using System.Text;  
using System.Text.RegularExpressions;  
using System.Web;  
using System.Net;  
using System.IO;  
using System.Windows.Forms;  
namespace Foxer_Player_1._1  
{  
    class lrc_down  
    {  
        public static WebClient client = new WebClient();  
        public static void gecixia(string name)  
        {  
            string geci_search_adress;  
            geci_search_adress = HttpUtility.UrlEncode(name, Encoding.Default);  
            string ci = geci_search_adress;  
            string geci = "           
            string ne = GetWebContent(geci);  
             
            Regex r2 = new Regex("((downlrc.
jsp?).*(LRC歌詞下載))", RegexOptions.IgnoreCase);  
            
            if (r2.IsMatch(ne))  
            {  
                 
                string wangzhi = r2.Match(ne).Value;  
                string down_address = "                DownloadFile(down_address, System.AppDomain.CurrentDomain.BaseDirectory + "Lrc//" + name + ".lrc");  
               
            }  
            else 
            {  
                Regex r3 = new Regex("
http://.*(?=.*lrc/")");  
                if (r3.IsMatch(ne))  
                {  
                    string wangzhi1 = r3.Match(ne).Value;  
                    
                      
                    string down_address1 = "                    client.Dispose();  
                    DownloadFile( down_address1, System.AppDomain.CurrentDomain.BaseDirectory + "Lrc//" + name + ".lrc");  
                }  
                else 
                {  
                    Regex r4 = new Regex(@"lrc.
aspxp.net/lrc.asp.* ");  
                    if (r4.IsMatch(ne))  
                    {  
                        string wangzhi2 = r2.Match(ne).Value;  
                        string down_address2 = wangzhi2.Remove(wangzhi2.IndexOf('"'));  
                        DownloadFile("http://" + down_address2, System.AppDomain.CurrentDomain.BaseDirectory + "Lrc//" + name + ".lrc");  
                    }  
                }  
            }  
        }  
        public static string GetWebContent(string Url)  
        {  
            string strResult = "";  
            try 
            {  
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);  
                //聲明一個HttpWebRequest請求  
                request.Timeout = 30000;  
                //設置連接超時時間  
                request.Headers.Set("Pragma", "no-cache");  
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();  
                Stream streamReceive = response.GetResponseStream();  
                Encoding encoding = Encoding.GetEncoding("GB2312");  
                StreamReader streamReader = new StreamReader(streamReceive, encoding);  
                strResult = streamReader.ReadToEnd();  
            }  
            catch 
            {  
                // MessageBox.Show("出錯");  
            }  
            return strResult;  
        }  
        public static void DownloadFile(string URLAddress, string fileName)  
        {  
            try 
            {  
                client.DownloadFile(URLAddress, fileName);  
                Stream str = client.OpenRead(URLAddress);  
                StreamReader reader = new StreamReader(str);  
                byte[] mbyte = new byte[1000000];  
                int allmybyte = (int)mbyte.Length;  
                int startmbyte = 0;  
                while (allmybyte > 0)  
                {  
                    int m = str.Read(mbyte, startmbyte, allmybyte);  
                    if (m == 0)  
                        break;  
                    startmbyte += m;  
                    allmybyte -= m;  
                }  
                FileStream fstr = new FileStream(fileName, FileMode.OpenOrCreate, Fileaccess.Write);  
                fstr.Write(mbyte, 0, startmbyte);  
                str.Close();  
                fstr.Close();  
                client.Dispose();  
            }  
            catch 
            {  
                // MessageBox.Show(exp.Message, "Error");  
            }  
        }  
       
    }  

//Foxer_Player_App_Author: CT.ThEN
//Foxer_Player_App_BuildTime: Otc,12,2008
//Foxer_Player_App_Version: 1.01
//Foxer_Player_App_Author_email: [email protected]
//Foxer_Player_App_Author_schoolID: 2740610812
//Foxer_Player_lrc_down:download_lrc_form_web
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Net;
using System.IO;
using System.Windows.Forms;
namespace Foxer_Player_1._1
{
    class lrc_down
    {
        public static WebClient client = new WebClient();
        public static void gecixia(string name)
        {
            string geci_search_adress;
            geci_search_adress = HttpUtility.UrlEncode(name, Encoding.Default);
            string ci = geci_search_adress;
            string geci = "        
            string ne = GetWebContent(geci);
          
            Regex r2 = new Regex("((downlrc.jsp?).*(LRC歌詞下載))", RegexOptions.IgnoreCase);
         
            if (r2.IsMatch(ne))
            {
              
                string wangzhi = r2.Match(ne).Value;
                string down_address = "
                DownloadFile(down_address, System.AppDomain.CurrentDomain.BaseDirectory + "Lrc//" + name + ".lrc");
            
            }
            else
            {
                Regex r3 = new Regex("
http://.*(?=.*lrc/")");
                if (r3.IsMatch(ne))
                {
                    string wangzhi1 = r3.Match(ne).Value;
                 
                   
                    string down_address1 = "                    client.Dispose();
                    DownloadFile( down_address1, System.AppDomain.CurrentDomain.BaseDirectory + "Lrc//" + name + ".lrc");
                }
                else
                {
                    Regex r4 = new Regex(@"lrc.aspxp.net/lrc.asp.* ");
                    if (r4.IsMatch(ne))
                    {
                        string wangzhi2 = r2.Match(ne).Value;
                        string down_address2 = wangzhi2.Remove(wangzhi2.IndexOf('"'));
                        DownloadFile("http://" + down_address2, System.AppDomain.CurrentDomain.BaseDirectory + "Lrc//" + name + ".lrc");
                    }
                }
            }
        }
        public static string GetWebContent(string Url)
        {
            string strResult = "";
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
                //聲明一個HttpWebRequest請求
                request.Timeout = 30000;
                //設置連接超時時間
                request.Headers.Set("Pragma", "no-cache");
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream streamReceive = response.GetResponseStream();
                Encoding encoding = Encoding.GetEncoding("GB2312");
                StreamReader streamReader = new StreamReader(streamReceive, encoding);
                strResult = streamReader.ReadToEnd();
            }
            catch
            {
                // MessageBox.Show("出錯");
            }
            return strResult;
        }
        public static void DownloadFile(string URLAddress, string fileName)
        {
            try
            {
                client.DownloadFile(URLAddress, fileName);
                Stream str = client.OpenRead(URLAddress);
                StreamReader reader = new StreamReader(str);
                byte[] mbyte = new byte[1000000];
                int allmybyte = (int)mbyte.Length;
                int startmbyte = 0;
                while (allmybyte > 0)
                {
                    int m = str.Read(mbyte, startmbyte, allmybyte);
                    if (m == 0)
                        break;
                    startmbyte += m;
                    allmybyte -= m;
                }
                FileStream fstr = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
                fstr.Write(mbyte, 0, startmbyte);
                str.Close();
                fstr.Close();
                client.Dispose();
            }
            catch
            {
                // MessageBox.Show(exp.Message, "Error");
            }
        }
    
    }
}
 

歌詞顯示:

view plaincopy to clipboardprint?
//Foxer_Player_App_Author: CT.ThEN  
//Foxer_Player_App_BuildTime: Otc,12,2008  
//Foxer_Player_App_Version: 1.01  
//Foxer_Player_App_Author_email:
[email protected]  
//Foxer_Player_App_Author_schoolID: 2740610812  
//Foxer_Player_lrc_show:showLryic  
using System;  
using System.Collections.Generic;  
using System.Text;  
using System.IO;  
using System.Threading;  
using System.Windows.Forms;  
namespace Foxer_Player_1._1  
{  
    class lrc_show  
    {  
        private static string musicPath;  
        private static string lrcPath;  
        private static string[] lrcString;  
        private static string listItem;  
        private static string  listItemUnAdd ="XX#ooX#X";  
        private static bool isHasLrc=false;  
        public static bool unClict=true;  
        private static string[] clear;  
        //main  
        public static string get_lrc(string musicPath1,string geciIs1)  
        {  
              
            musicPath = musicPath1;  
            getGeci_str();  
            string listAdd=getList_add_geci(geciIs1);  
            return listAdd;  
             
        }  
        public static void getGeci_str()  
        {  
            try 
            {  
            FileInfo fi = new FileInfo(musicPath);  
            foreach (string gecifile in Directory.GetFiles(application.StartupPath + "//Lrc//"))  
            {  
                FileInfo fi2 = new FileInfo(gecifile);  
                lrcPath = fi.Name.Remove(fi.Name.LastIndexOf('.'));  
                try 
                {  
                    if (fi2.Name.Substring(0, fi2.Name.Length - 4) == fi.Name.Substring(0, fi.Name.Length - 4))  
                    {  
                        lrcString = File.ReadAllLines(gecifile, Encoding.Default);  
                        isHasLrc = true;  
                        return;  
                    }  
                    lrcString = clear;  
                    if (unClict)  
                    {  
                        Thread t2 = new Thread(new ThreadStart(fangfa));  
                        t2.IsBackground = true;  
                        t2.Start();  
                        unClict = false;  
                        isHasLrc = true;  
                    }  
                }  
                catch 
                {  
                }  
            }  
            }  
            catch 
            {  
            }  
             
           
        }  
        private static void fangfa()  
        {  
            lrc_down.gecixia(lrcPath);  
        }  
        private static string  getList_add_geci(string currentPos)  
        {  
              
            try 
            {  
                for (int i = 0; i < lrcString.Length; i++)  
                {  
                    int l = lrcString[i].LastIndexOf("]");  
                    if(l == 9)  
                    {  
                        if (getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 8, 5))  
                        {  
                            listItem = lrcString[i].Substring(l + 1, lrcString[i].Length - l - 1);  
                            return listItem;  
                        }  
                        
                    }  
                    else 
                        if (l == 19)  
                        {  
                            if (getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 8, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 18, 5))  
                            {  
                                listItem = lrcString[i].Substring(l + 1, lrcString[i].Length - l - 1);  
                                return listItem;  
                            }  
                            
                        }  
                        else 
                            if (l == 29)  
                            {  
                                if (getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 8, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 18, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 28, 5))  
                                {  
                                    listItem = lrcString[i].Substring(l + 1, lrcString[i].Length - l - 1);  
                                    return listItem;  
                                }  
                                
                            }  
                            else 
                                if (l == 39)  
                                {  
                                    if (getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 8, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 18, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 28, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 38, 5))  
                                    {  
                                        listItem = lrcString[i].Substring(l + 1, lrcString[i].Length - l - 1);  
                                        return listItem;  
                                    }  
                                    
                                }  
                                else 
                                    if (l == 49)  
                                    {  
                                        if (getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 8, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 18, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 28, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 38, 5) || getLengthWithFormat2(currentPos) == lrcString[i].Substring(l - 48, 5))  
                                        {  
                                            listItem = lrcString[i].Substring(l + 1, lrcString[i].Length - l - 1);  
                                            return listItem;  
                                        }  
                                        
                                    }  
                     
                }  
                return listItemUnAdd;  
            }  
            catch 
            {  
                return listItemUnAdd;  
            }  
        }  
        private static string getLengthWithFormat2(string mm)  
        {  
            string ccds = mm.Replace("00:", "");  
            if (ccds.Length < 5)  
            {  
                ccds = "00:" + ccds;  
            }  
            return ccds;  
        }  
    }  

出處:http://blog.csdn.net/ctthen/archive/2009/06/19/4284177.aspx


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: av在线免费网 | 91成人免费在线视频 | 久久久久在线观看 | 国产精品久久久久久久av | 欧美成人激情 | 斗破苍穹在线免费 | 亚洲成人国产 | 成人免费一区二区三区在线观看 | 最新se94se在线欧美 | 91成人久久 | 手机免费看一级片 | 国产午夜免费 | 国产一级二级在线播放 | 国产一有一级毛片视频 | 久久色在线 | 久久精品爱 | 欧美日韩国产成人在线观看 | 免费一级特黄做受大片 | 国产小视频在线观看 | 视频一区二区三区视频 | 国产一国产一级毛片视频在线 | 午夜视频免费播放 | 免费看污视频在线观看 | 精品偷拍久久 | 国产一区二精品区在线 | www.91操 | 亚洲综合视频在线播放 | 日韩黄色成人 | 一级免费 | 国产91久久精品一区二区 | 日韩精品中文字幕一区二区三区 | 91精品国产九九九久久久亚洲 | 毛片免费观看完整版 | 成人三级视频在线观看 | 久久经典国产视频 | 欧美ab| 国产不卡av在线 | 欧美18—19sex性hd按摩 | 激情亚洲一区二区三区 | 87成人免费看片 | 国产亚洲精久久久久久蜜臀 |