Skip to content

Commit

Permalink
Merge pull request #126 from jitwxs/dev
Browse files Browse the repository at this point in the history
Release v5.0
  • Loading branch information
jitwxs authored Sep 16, 2022
2 parents d65374a + a2389a3 commit bd5d350
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 44 deletions.
2 changes: 1 addition & 1 deletion MusicLyricApp/Api/QQMusicApiV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static string ContractSinger(QQMusicBean.Singer[] singers)

private static string BuildPicUrl(QQMusicBean.Album album)
{
return $"https://y.qq.com/music/photo_new/T002R300x300M000{album.Pmid}.jpg";
return $"https://y.qq.com/music/photo_new/T002R800x800M000{album.Pmid}.jpg";
}
}
}
2 changes: 1 addition & 1 deletion MusicLyricApp/Bean/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace MusicLyricApp.Bean
{
public static class Constants
{
public const string Version = "v4.9";
public const string Version = "v5.0";

public static readonly string SettingPath = Environment.CurrentDirectory + "\\MusicLyricAppSetting.json";

Expand Down
2 changes: 1 addition & 1 deletion MusicLyricApp/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 43 additions & 38 deletions MusicLyricApp/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,21 +517,23 @@ private async void SingleSave(string songId)
}

var saveDialog = new SaveFileDialog();
saveDialog.FileName = GlobalUtils.GetOutputName(saveVo.SongVo, _globalSearchInfo.SettingBean.Param.OutputFileNameType);
saveDialog.Filter = _globalSearchInfo.SettingBean.Param.OutputFileFormat.ToDescription();

if (saveDialog.ShowDialog() != DialogResult.OK)
{
return;
}

try
{
saveDialog.FileName = GlobalUtils.GetOutputName(saveVo.SongVo, _globalSearchInfo.SettingBean.Param.OutputFileNameType);
saveDialog.Filter = _globalSearchInfo.SettingBean.Param.OutputFileFormat.ToDescription();
if (saveDialog.ShowDialog() == DialogResult.OK)
using (var sw = new StreamWriter(saveDialog.FileName, false, GlobalUtils.GetEncoding(_globalSearchInfo.SettingBean.Param.Encoding)))
{
using (var sw = new StreamWriter(saveDialog.FileName, false,
GlobalUtils.GetEncoding(_globalSearchInfo.SettingBean.Param.Encoding)))
{
await sw.WriteAsync(await LyricUtils.GetOutputContent(saveVo.LyricVo, _globalSearchInfo));
await sw.FlushAsync();
}

MessageBox.Show(string.Format(ErrorMsg.SAVE_COMPLETE, 1, 0), "提示");
await sw.WriteAsync(await LyricUtils.GetOutputContent(saveVo.LyricVo, _globalSearchInfo));
await sw.FlushAsync();
}

MessageBox.Show(string.Format(ErrorMsg.SAVE_COMPLETE, 1, 0), "提示");
}
catch (System.Exception ew)
{
Expand All @@ -546,49 +548,52 @@ private async void SingleSave(string songId)
private async void BatchSave()
{
var saveDialog = new SaveFileDialog();
saveDialog.FileName = "直接选择保存路径即可,无需修改此处内容";
saveDialog.Filter = _globalSearchInfo.SettingBean.Param.OutputFileFormat.ToDescription();

if (saveDialog.ShowDialog() != DialogResult.OK)
{
return;
}

// 保存
var skipCount = 0;
var success = new HashSet<string>();

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

var localFilePath = saveDialog.FileName;
// 获取文件后缀
var fileSuffix = localFilePath.Substring(localFilePath.LastIndexOf("."));
//获取文件路径,不带文件名
var filePath = localFilePath.Substring(0, localFilePath.LastIndexOf("\\"));

foreach (var item in _globalSaveVoMap)
foreach (var item in _globalSaveVoMap)
{
var saveVo = item.Value;
var lyricVo = saveVo.LyricVo;
if (lyricVo.IsEmpty())
{
var saveVo = item.Value;
var lyricVo = saveVo.LyricVo;
if (lyricVo.IsEmpty())
{
skipCount++;
continue;
}
skipCount++;
continue;
}

var path = filePath + '/' + GlobalUtils.GetOutputName(saveVo.SongVo, _globalSearchInfo.SettingBean.Param.OutputFileNameType) + fileSuffix;
using(var sw = new StreamWriter(path, false, GlobalUtils.GetEncoding(_globalSearchInfo.SettingBean.Param.Encoding)))
{
await sw.WriteAsync(await LyricUtils.GetOutputContent(lyricVo, _globalSearchInfo));
await sw.FlushAsync();
success.Add(item.Key);
}
var path = filePath + '/' + GlobalUtils.GetOutputName(saveVo.SongVo, _globalSearchInfo.SettingBean.Param.OutputFileNameType) + fileSuffix;
using(var sw = new StreamWriter(path, false, GlobalUtils.GetEncoding(_globalSearchInfo.SettingBean.Param.Encoding)))
{
await sw.WriteAsync(await LyricUtils.GetOutputContent(lyricVo, _globalSearchInfo));
await sw.FlushAsync();
success.Add(item.Key);
}
}

MessageBox.Show(string.Format(ErrorMsg.SAVE_COMPLETE, success.Count, skipCount), "提示");
}
catch (System.Exception ew)
{
_logger.Error(ew, "批量保存失败");
MessageBox.Show("批量保存失败,错误信息:\n" + ew.Message);
}

MessageBox.Show(string.Format(ErrorMsg.SAVE_COMPLETE, success.Count, skipCount), "提示");

// 输出日志
var log = new StringBuilder();
Expand Down
4 changes: 4 additions & 0 deletions MusicLyricApp/MusicLyricApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<PropertyGroup>
<ApplicationIcon>Favicon2.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=5.8.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d">
<HintPath>..\packages\Costura.Fody.5.8.0-alpha0098\lib\netstandard1.0\Costura.dll</HintPath>
Expand Down Expand Up @@ -337,6 +340,7 @@
<Content Include="Favicon2.ico" />
<Content Include="matrix.bin" />
<Content Include="NLog.xsd" />
<Content Include="Properties\app.manifest" />
<Content Include="sys.dic" />
<Content Include="unk.dic" />
</ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions MusicLyricApp/Properties/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!-- https://docs.microsoft.com/zh-cn/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process -->
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
5 changes: 2 additions & 3 deletions MusicLyricApp/Utils/LyricUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ private static async Task<List<LyricLineVo>> FormatLyric(string originLrc, strin
{
var showLrcType = searchInfo.SettingBean.Param.ShowLrcType;
var searchSource = searchInfo.SettingBean.Param.SearchSource;
var ignoreEmptyLine = searchInfo.SettingBean.Param.IgnoreEmptyLyric;

var originLyrics = SplitLrc(originLrc, searchSource, ignoreEmptyLine);
var originLyrics = SplitLrc(originLrc, searchSource, searchInfo.SettingBean.Param.IgnoreEmptyLyric);

/*
* 1、原文歌词不存在
Expand All @@ -64,7 +63,7 @@ private static async Task<List<LyricLineVo>> FormatLyric(string originLrc, strin
// 译文处理,启用罗马音进行转换,否则使用原始的译文
var romajiConfig = searchInfo.SettingBean.Config.RomajiConfig;

var translateLyrics = SplitLrc(translateLrc, searchSource, ignoreEmptyLine);
var translateLyrics = SplitLrc(translateLrc, searchSource, true);

translateLyrics = DealTranslateLyric(originLyrics, translateLyrics, searchInfo.SettingBean);

Expand Down

0 comments on commit bd5d350

Please sign in to comment.