Пример #1
0
        public static SongInformation GetSongInformation(String songId, String songType)
        {
            String url = "http://5sing.kugou.com/m/detail/" + songType + "-" + songId + "-1.html";
            Encoding myEncoding = Encoding.GetEncoding("utf-8");
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            req.Method = "GET";
            req.Timeout = 5000;
            try
            {
                HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse();
                StreamReader reader = new StreamReader(myResponse.GetResponseStream());
                String str = reader.ReadToEnd();
                reader.Close();

                //写入class
                SongInformation result = new SongInformation();
                result.songId = songId;
                result.songType = songType;
                String res = Regex.Match(str, @"http://.+preload").ToString();
                res = res.Substring(0, res.Length - 9);
                result.fileName = res;
                String s = Regex.Match(str, @"<title>.+ - 手机原创音乐基地</title>").ToString();
                s = s.Substring(0, s.IndexOf(" - 手机原创音乐基地</title>"));
                s = s.Substring(0, s.LastIndexOf(" - "));
                s = s.Substring(7);
                result.songName = s.Substring(0, s.LastIndexOf(" - "));
                result.authorName = s.Substring(s.LastIndexOf(" - ") + 3);
                return result;
            }
            catch (Exception e)
            {
                SongInformation result = new SongInformation();
                result.songId = songId;
                result.songType = songType;
                return result;
            }

        }
Пример #2
0
 public static SongInformation AddDownloadPath(SongInformation inf, String rootPath)
 {
     if (inf.songName == "" || inf.authorName == "")
         return inf;
     inf.path = rootPath + "\\" + MakeDirPath(inf.authorName);
     inf.file = MakeFilePath(inf.authorName + " - " + inf.songName + inf.fileName.Substring(inf.fileName.LastIndexOf(".")));
     return inf;
 }