Esempio n. 1
0
        // 批量保存
        private void BatchSave()
        {
            SaveFileDialog saveDialog = new SaveFileDialog();

            try
            {
                saveDialog.FileName = "直接选择保存路径即可,无需修改此处内容";
                saveDialog.Filter   = "lrc文件(*.lrc)|*.lrc|txt文件(*.txt)|*.txt";
                if (saveDialog.ShowDialog() == DialogResult.OK)
                {
                    string localFilePath = saveDialog.FileName.ToString();
                    // 获取文件后缀
                    string fileSuffix = localFilePath.Substring(localFilePath.LastIndexOf("."));
                    //获取文件路径,不带文件名
                    string filePath = localFilePath.Substring(0, localFilePath.LastIndexOf("\\"));

                    foreach (var item in globalSaveVOMap)
                    {
                        string       outputFileName = NeteaseMusicUtils.GetOutputName(item.Value.songVO, globalSearchInfo);
                        string       path           = filePath + "/" + NeteaseMusicUtils.GetSafeFilename(outputFileName) + fileSuffix;
                        StreamWriter sw             = new StreamWriter(path, false, NeteaseMusicUtils.GetEncoding(globalSearchInfo.Encoding));
                        sw.Write(NeteaseMusicUtils.GetOutputLyric(item.Value.lyricVO.Lyric, item.Value.lyricVO.TLyric, globalSearchInfo));
                        sw.Flush();
                        sw.Close();
                    }
                    MessageBox.Show(ErrorMsg.SAVE_SUCCESS, "提示");
                }
            }
            catch (Exception ew)
            {
                MessageBox.Show("批量保存失败,错误信息:\n" + ew.Message);
            }

            // 输出日志
            StringBuilder log = new StringBuilder();

            foreach (var songIdStr in globalSearchInfo.SearchIds)
            {
                if (globalSaveVOMap.ContainsKey(songIdStr))
                {
                    log.Append("ID: " + songIdStr + ", Result: success\r\n");
                }
                else
                {
                    log.Append("ID: " + songIdStr + ", Result: failure\r\n");
                }
            }
            UpdateLrcTextBox(log.ToString());
        }
Esempio n. 2
0
 // 更新前端歌词
 private void UpdateLrcTextBox(string replace)
 {
     if (replace != "")
     {
         textBox_lrc.Text = replace;
     }
     else
     {
         // 根据最新配置,更新输出歌词
         if (globalSaveVOMap != null && globalSaveVOMap.Count == 1)
         {
             // only loop one times
             foreach (var item in globalSaveVOMap)
             {
                 string outputLyric = NeteaseMusicUtils.GetOutputLyric(item.Value.lyricVO.Lyric, item.Value.lyricVO.TLyric, globalSearchInfo);
                 textBox_lrc.Text = outputLyric == "" ? ErrorMsg.LRC_NOT_EXIST : outputLyric;
             }
         }
     }
 }