Skip to content

Commit

Permalink
Merge pull request #36 from jitwxs/dev
Browse files Browse the repository at this point in the history
Release v3.4
  • Loading branch information
jitwxs authored Mar 1, 2022
2 parents 10756bd + e340516 commit 87bf2e8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
39 changes: 26 additions & 13 deletions WindowsFormsApp1/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public partial class MainForm : Form
// 输出文件名类型
OUTPUT_FILENAME_TYPE_ENUM output_filename_type_enum;

public const string Version = "v3.3";
public const string Version = "v3.4";

public MainForm()
{
Expand All @@ -52,7 +52,13 @@ private void ReloadConfig()
{
_globalSaveVoMap.Clear();

_globalSearchInfo.InputIds = search_id_text.Text.Trim().Split(',');
var ids = search_id_text.Text.Trim().Split(',');
_globalSearchInfo.InputIds = new string[ids.Length];
for (var i = 0; i < ids.Length; i++)
{
_globalSearchInfo.InputIds[i] = ids[i].Trim();
}

_globalSearchInfo.SONG_IDS.Clear();
_globalSearchInfo.SearchType = search_type_enum;
_globalSearchInfo.OutputFileNameType = output_filename_type_enum;
Expand Down Expand Up @@ -267,15 +273,14 @@ private void songUrlBtn_Click(object sender, EventArgs e)
// 输出日志
foreach (var songId in _globalSearchInfo.SONG_IDS)
{
if (_globalSaveVoMap.ContainsKey(songId))
{
_globalSaveVoMap.TryGetValue(songId, out var saveVo);
log.Append("ID: " + songId + ", Links: " + saveVo.SongVo.Links + "\r\n");
}
else
_globalSaveVoMap.TryGetValue(songId, out var saveVo);

var link = "failure";
if (saveVo != null)
{
log.Append("ID: " + songId + ", Links: failure\r\n");
}
link = saveVo.SongVo.Links ?? "failure";
}
log.Append($"ID: {songId}, Links: {link}\r\n");
}

UpdateLrcTextBox(log.ToString());
Expand All @@ -285,8 +290,16 @@ private void songUrlBtn_Click(object sender, EventArgs e)
// only loop one times
foreach (var item in _globalSaveVoMap)
{
Clipboard.SetDataObject(item.Value.SongVo.Links);
MessageBox.Show(ErrorMsg.SONG_URL_COPY_SUCESS, "提示");
var link = item.Value.SongVo.Links;
if (link == null)
{
MessageBox.Show(ErrorMsg.SONG_URL_GET_FAILED, "提示");
}
else
{
Clipboard.SetDataObject(link);
MessageBox.Show(ErrorMsg.SONG_URL_COPY_SUCESS, "提示");
}
}
}
}
Expand All @@ -297,7 +310,6 @@ private void songUrlBtn_Click(object sender, EventArgs e)
private void SingleSave(long songId)
{
var saveDialog = new SaveFileDialog();
var sw = new StreamWriter(saveDialog.FileName, false, NetEaseMusicUtils.GetEncoding(_globalSearchInfo.Encoding));
try
{
if (!_globalSaveVoMap.TryGetValue(songId, out var saveVo))
Expand All @@ -321,6 +333,7 @@ private void SingleSave(long songId)
saveDialog.Filter = "lrc文件(*.lrc)|*.lrc|txt文件(*.txt)|*.txt";
if (saveDialog.ShowDialog() == DialogResult.OK)
{
var sw = new StreamWriter(saveDialog.FileName, false, NetEaseMusicUtils.GetEncoding(_globalSearchInfo.Encoding));
sw.Write(textBox_lrc.Text);
sw.Flush();
sw.Close();
Expand Down
2 changes: 1 addition & 1 deletion WindowsFormsApp1/NetEaseMusicVO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static class ErrorMsg
public static string LRC_NOT_EXIST = "歌词信息暂未被收录或查询失败";
public static string FUNCTION_NOT_SUPPORT = "该功能暂不可用,请等待后续更新";
public static string SONG_URL_COPY_SUCESS = "歌曲直链,已复制到剪切板";
public static string BATCH_SONG_URL_COPY_SUCESS = "批量歌曲直链,已复制到剪切板";
public static string SONG_URL_GET_FAILED = "歌曲直链,获取失败";
public static string FILE_NAME_IS_EMPTY = "输出文件名不能为空";
public static string SAVE_SUCCESS = "保存成功";

Expand Down

0 comments on commit 87bf2e8

Please sign in to comment.