工具下載:酷狗寫真一鍵提取工具.zip
前幾天在聽歌時,發現by2那性感撩人的照片,一股熱血涌上心頭,突然非常想下載這些照片。於是我百度了一下怎么提取,百度經驗告訴了我。
酷狗的歌詞寫真是保存在C:\Users\用戶名\AppData\Roaming\KuGou8(7)\SingerImg 目錄下,格式為KRS,不容易提取。
有一個園友剛好寫過一個KRS提取工具,也是用來提取酷狗歌詞的,但是不是很智能,而且功能比較簡單,於是我就自己搞了個,本人運行效果還不錯。
軟件界面和說明
1.自動識別當前用戶,找到酷狗寫真文件夾
2.友好的提示和進度信息
3.一鍵獲取,不需要額外的操作,默認保存路徑為D:\酷狗歌手寫真,沒有D盤我也沒有辦法...
4.運行清理工具清理后我也沒有辦法...
5. win7 net framework 3.5
6,安裝了酷狗,有寫真需要提取...
運行后的結果
代碼實現
主要的核心是怎么提取KRS文件,解析代碼如下
/// <summary> /// 獲取KRS文件流的字符串 /// </summary> /// <param name="path"></param> /// <returns></returns> public string ReadFiles(string path) { FileStream stream = null; string str; try { if (File.Exists(path)) { stream = File.OpenRead(path); byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); stream.Flush(); return this.byteToHexStr(buffer); } str = null; } catch (Exception exception) { throw exception; } finally { if (stream != null) { stream.Close(); stream.Dispose(); } } return str; }
/// <summary> /// 轉16進制 /// </summary> /// <param name="bytes"></param> /// <returns></returns> public string byteToHexStr(byte[] bytes) { string str; try { StringBuilder builder = new StringBuilder(); if (bytes != null) { for (int i = 0; i < bytes.Length; i++) { builder.Append(bytes[i].ToString("X2")); } } str = builder.ToString(); } catch (Exception exception) { throw exception; } return str; }
/// <summary> /// 得到文件的進制字符串 /// </summary> /// <param name="krsData"></param> /// <returns></returns> public List<string> getPicHexs(string krsData) { List<string> list = new List<string>(); Regex regex = new Regex("FFD9(0A)*$"); string[] strArray = krsData.Replace("FFD8FFE0", "|").Split(new char[] { '|' }); foreach (string str in strArray) { if (regex.IsMatch(str)) { list.Add("FFD8FFE0" + str); } } return list; }
/// <summary> /// 保存圖片文件 /// </summary> /// <param name="data">KRS單個圖片的字符串</param> /// <param name="path">圖片文件保存路徑</param> public void WriteFiles(string data, string path) { FileStream stream = null; try { stream = File.Create(path); byte[] buffer = strToToHexByte(data); stream.Write(buffer, 0, buffer.Length); stream.Flush(); } catch (Exception exception) { throw exception; } finally { if (stream != null) { stream.Close(); stream.Dispose(); } } }
思考和可擴展功能
1.自由選取保存和打開路徑
2.C:\Users\Administrator\AppData\Roaming\KuGou8\SingerImg\SingerRes.xml 保存了歌手和KRS對應關系,可以分文件夾保存。
如果工具不適合自己,可以自己修改和開發,現在感覺達到我的需求了。這些功能我就不實現了,如果有興趣的可以反編譯我的工具,代碼太丑,全部代碼就不公布了...