Skip to content

Commit 98b724b

Browse files
authored
Merge pull request #83 from jitwxs/dev
Release v4.2
2 parents 5ff15c1 + 0ce589c commit 98b724b

27 files changed

+896
-377
lines changed

MusicLyricApp/AUTHORS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Taku Kudo <[email protected]>
2+
3+
4+
Masayuki Asahara:[email protected]
5+
Yuji Matsumoto:[email protected]
6+

MusicLyricApp/Api/NetEaseMusicApiV2.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ protected override LyricVo GetLyricVo0(string songId)
7575
var lyricVo = new LyricVo();
7676
if (resp.Lrc != null)
7777
{
78-
lyricVo.Lyric = resp.Lrc.Lyric;
78+
lyricVo.SetLyric(resp.Lrc.Lyric);
7979
}
8080
if (resp.Tlyric != null)
8181
{
82-
lyricVo.TranslateLyric = resp.Tlyric.Lyric;
82+
lyricVo.SetTranslateLyric(resp.Tlyric.Lyric);
8383
}
8484

8585
return lyricVo;

MusicLyricApp/Api/QQMusicApiV2.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,17 @@ protected override LyricVo GetLyricVo0(string songId)
6565
{
6666
var resp = _api.GetLyric(songId);
6767

68-
if (resp.Code == 0)
68+
if (resp.Code != 0)
6969
{
70-
return new LyricVo
71-
{
72-
Lyric = resp.lyric ?? string.Empty,
73-
TranslateLyric = resp.trans ?? string.Empty
74-
};
70+
throw new MusicLyricException(ErrorMsg.LRC_NOT_EXIST);
7571
}
76-
77-
throw new MusicLyricException(ErrorMsg.LRC_NOT_EXIST);
72+
73+
var lyricVo = new LyricVo();
74+
75+
lyricVo.SetLyric(resp.lyric);
76+
lyricVo.SetTranslateLyric(resp.trans);
77+
78+
return lyricVo;
7879
}
7980

8081
/// <summary>

MusicLyricApp/Bean/Constants.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ namespace MusicLyricApp.Bean
44
{
55
public static class Constants
66
{
7-
public const string Version = "v4.1";
7+
public const string Version = "v4.2";
88

99
public static readonly string SettingPath = Environment.CurrentDirectory + "\\MusicLyricAppSetting.json";
10+
11+
public static readonly string IpaDicPath = Environment.CurrentDirectory + "\\IpaDic";
1012

1113
public const int SettingFormOffset = 20;
14+
15+
public static readonly string[] IpaDicDependency = {
16+
IpaDicPath + "\\char.bin",
17+
IpaDicPath + "\\matrix.bin",
18+
IpaDicPath + "\\sys.dic",
19+
IpaDicPath + "\\unk.dic",
20+
};
1221
}
1322
}

MusicLyricApp/Bean/MusicLyricsVO.cs

Lines changed: 124 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,63 @@
22
using System.Collections.Generic;
33
using System.ComponentModel;
44
using System.Linq;
5+
using System.Web;
6+
using MusicLyricApp.Exception;
7+
using MusicLyricApp.Utils;
58

69
namespace MusicLyricApp.Bean
710
{
811
// 双语歌词类型
912
public enum ShowLrcTypeEnum
1013
{
11-
ONLY_ORIGIN = 0, // 仅显示原文
12-
ONLY_TRANSLATE = 1, // 仅显示译文
13-
ORIGIN_PRIOR = 2, // 优先原文
14-
TRANSLATE_PRIOR = 3, // 优先译文
15-
MERGE_ORIGIN = 4, // 合并显示,优先原文
16-
MERGE_TRANSLATE = 5, // 合并显示,优先译文
14+
[Description("仅显示原文")] ONLY_ORIGIN = 0,
15+
[Description("仅显示译文")] ONLY_TRANSLATE = 1,
16+
[Description("优先原文(交错)")] ORIGIN_PRIOR_STAGGER = 2,
17+
[Description("优先译文(交错)")] TRANSLATE_PRIOR_STAGGER = 3,
18+
[Description("优先原文(独立)")] ORIGIN_PRIOR_ISOLATED = 4,
19+
[Description("优先译文(独立)")] TRANSLATE_PRIOR_ISOLATED = 5,
20+
[Description("优先原文(合并)")] ORIGIN_PRIOR_MERGE = 6,
21+
[Description("优先译文(合并)")] TRANSLATE_PRIOR_MERGE = 7,
1722
}
1823

1924
// 输出文件名类型
2025
public enum OutputFilenameTypeEnum
2126
{
22-
NAME_SINGER = 0, // 歌曲名 - 歌手
23-
SINGER_NAME = 1, // 歌手 - 歌曲名
24-
NAME = 2 // 歌曲名
27+
[Description("歌曲名 - 歌手")] NAME_SINGER = 0,
28+
[Description("歌手 - 歌曲名")] SINGER_NAME = 1,
29+
[Description("歌曲名")] NAME = 2
2530
}
2631

2732
// 搜索来源
2833
public enum SearchSourceEnum
2934
{
30-
NET_EASE_MUSIC = 0, // 网易云音乐
31-
QQ_MUSIC = 1 // QQ音乐
35+
[Description("网易云")] NET_EASE_MUSIC = 0,
36+
[Description("QQ音乐")] QQ_MUSIC = 1
3237
}
3338

3439
// 搜索类型
3540
public enum SearchTypeEnum
3641
{
37-
SONG_ID = 0, // 歌曲ID
38-
ALBUM_ID = 1 // 专辑ID
42+
[Description("单曲")] SONG_ID = 0,
43+
[Description("专辑")] ALBUM_ID = 1
3944
}
4045

4146
// 强制两位类型
4247
public enum DotTypeEnum
4348
{
44-
DISABLE = 0, // 不启用
45-
DOWN = 1, // 截位
46-
HALF_UP = 2 // 四舍五入
49+
[Description("不启用")] DISABLE = 0,
50+
[Description("截位")] DOWN = 1,
51+
[Description("四舍五入")] HALF_UP = 2
4752
}
4853

4954
// 输出文件格式
5055
public enum OutputEncodingEnum
5156
{
52-
UTF_8 = 0,
53-
UTF_8_BOM = 1,
54-
GB_2312 = 2,
55-
GBK = 3,
56-
UNICODE = 4
57+
[Description("UTF-8")] UTF_8 = 0,
58+
[Description("UTF-8-BOM")] UTF_8_BOM = 1,
59+
[Description("GB-2312")] GB_2312 = 2,
60+
[Description("GBK")] GBK = 3,
61+
[Description("UNICODE")] UNICODE = 4
5762
}
5863

5964
public enum OutputFormatEnum
@@ -63,6 +68,23 @@ public enum OutputFormatEnum
6368
[Description("srt文件(*.srt)|*.srt")] SRT = 1
6469
}
6570

71+
// 罗马音转换模式
72+
public enum RomajiModeEnum
73+
{
74+
[Description("标准模式")] NORMAL = 0,
75+
[Description("空格分组")] SPACED = 1,
76+
[Description("送假名")] OKURIGANA = 2,
77+
[Description("注音假名")] FURIGANA = 3,
78+
}
79+
80+
// 罗马音字体系
81+
public enum RomajiSystemEnum
82+
{
83+
[Description("日本式")] NIPPON = 0,
84+
[Description("护照式")] PASSPORT = 1,
85+
[Description("平文式")] HEPBURN = 2,
86+
}
87+
6688
/**
6789
* 错误码
6890
*/
@@ -79,6 +101,7 @@ public static class ErrorMsg
79101
public const string FUNCTION_NOT_SUPPORT = "该功能暂不可用,请等待后续更新";
80102
public const string SONG_URL_COPY_SUCCESS = "歌曲直链,已复制到剪切板";
81103
public const string SONG_URL_GET_FAILED = "歌曲直链,获取失败";
104+
public const string ROMAJI_DEPENDENCY_LOSS = "罗马音相关依赖缺失,请重新下载";
82105
public const string SAVE_COMPLETE = "保存完毕,成功 {0} 跳过 {1}";
83106

84107
public const string GET_LATEST_VERSION_FAILED = "获取最新版本失败";
@@ -146,54 +169,111 @@ public class LyricVo
146169
/// <summary>
147170
/// 歌词内容
148171
/// </summary>
149-
public string Lyric { get; set; }
172+
public string Lyric;
150173

151174
/// <summary>
152175
/// 译文歌词内容
153176
/// </summary>
154-
public string TranslateLyric { get; set; }
177+
public string TranslateLyric;
155178

156179
/// <summary>
157180
/// 歌曲时长 ms
158181
/// </summary>
159182
public long Duration { get; set; }
160183

161-
/// <summary>
162-
/// 实际输出的歌词
163-
/// </summary>
164-
public string Output { get; set; }
184+
public void SetLyric(string content)
185+
{
186+
Lyric = HttpUtility.HtmlDecode(content);
187+
}
188+
189+
public void SetTranslateLyric(string content)
190+
{
191+
TranslateLyric = HttpUtility.HtmlDecode(content);
192+
}
165193

166194
public bool IsEmpty()
167195
{
168196
return string.IsNullOrEmpty(Lyric) && string.IsNullOrEmpty(TranslateLyric);
169197
}
170198
}
171-
199+
172200
/// <summary>
173-
/// 搜索信息
201+
/// 当行歌词信息
174202
/// </summary>
175-
public class SearchInfo
203+
public class LyricLineVo : IComparable
176204
{
177205
/// <summary>
178-
/// 搜索来源
206+
/// 时间戳字符串
179207
/// </summary>
180-
public SearchSourceEnum SearchSource { get; set; }
208+
public string Timestamp { get; set; }
209+
210+
/**
211+
* 时间偏移量
212+
*/
213+
public long TimeOffset { get; set; }
181214

182215
/// <summary>
183-
/// 搜索类型
216+
/// 歌词正文
184217
/// </summary>
185-
public SearchTypeEnum SearchType { get; set; }
218+
public string Content { get; set; }
186219

187-
/// <summary>
188-
/// 输出文件名类型
189-
/// </summary>
190-
public OutputFilenameTypeEnum OutputFileNameType { get; set; }
220+
public LyricLineVo(string lyricLine)
221+
{
222+
var index = lyricLine.IndexOf("]");
223+
if (index == -1)
224+
{
225+
Timestamp = "";
226+
TimeOffset = -1;
227+
Content = lyricLine;
228+
}
229+
else
230+
{
231+
Timestamp = lyricLine.Substring(0, index + 1);
232+
Content = lyricLine.Substring(index + 1);
233+
TimeOffset = GlobalUtils.TimestampStrToLong(Timestamp);
234+
}
235+
}
191236

192-
/// <summary>
193-
/// 歌词展示格式
194-
/// </summary>
195-
public ShowLrcTypeEnum ShowLrcType { get; set; }
237+
public LyricLineVo()
238+
{
239+
}
240+
241+
public int CompareTo(object input)
242+
{
243+
if (!(input is LyricLineVo obj))
244+
{
245+
throw new MusicLyricException(ErrorMsg.SYSTEM_ERROR);
246+
}
247+
248+
if (TimeOffset == -1 && obj.TimeOffset == -1)
249+
{
250+
return 0;
251+
}
252+
253+
if (TimeOffset == -1)
254+
{
255+
return -1;
256+
}
257+
258+
if (obj.TimeOffset == -1)
259+
{
260+
return 1;
261+
}
262+
263+
return (int) (TimeOffset - obj.TimeOffset);
264+
}
265+
266+
public override string ToString()
267+
{
268+
return Timestamp + Content;
269+
}
270+
}
196271

272+
/// <summary>
273+
/// 搜索信息
274+
/// </summary>
275+
public class SearchInfo
276+
{
197277
/// <summary>
198278
/// 输入 ID 列表
199279
/// </summary>
@@ -204,25 +284,9 @@ public class SearchInfo
204284
/// </summary>
205285
public readonly HashSet<string> SongIds = new HashSet<string>();
206286

207-
/// <summary>
208-
/// 输出文件编码
209-
/// </summary>
210-
public OutputEncodingEnum Encoding { get; set; }
211-
212-
/// <summary>
213-
/// 指定歌词合并的分隔符
214-
/// </summary>
215-
public string LrcMergeSeparator { get; set; }
216-
217-
/// <summary>
218-
/// 小数位处理策略
219-
/// </summary>
220-
public DotTypeEnum DotType { get; set; }
287+
public SettingBean SettingBeanBackup { get; set; }
221288

222-
/// <summary>
223-
/// 输出文件格式
224-
/// </summary>
225-
public OutputFormatEnum OutputFileFormat { get; set; }
289+
public SettingBean SettingBean { get; set; }
226290
}
227291

228292
public static class EnumHelper

0 commit comments

Comments
 (0)