Skip to content

Commit

Permalink
Merge pull request #83 from jitwxs/dev
Browse files Browse the repository at this point in the history
Release v4.2
  • Loading branch information
jitwxs authored May 2, 2022
2 parents 5ff15c1 + 0ce589c commit 98b724b
Show file tree
Hide file tree
Showing 27 changed files with 896 additions and 377 deletions.
6 changes: 6 additions & 0 deletions MusicLyricApp/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Taku Kudo <taku@chasen.org>
chasen@is.aist-nara.ac.jp

Masayuki Asahara:masayu-a@is.aist-nara.ac.jp
Yuji Matsumoto:matsu@is.aist-nara.ac.jp

4 changes: 2 additions & 2 deletions MusicLyricApp/Api/NetEaseMusicApiV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ protected override LyricVo GetLyricVo0(string songId)
var lyricVo = new LyricVo();
if (resp.Lrc != null)
{
lyricVo.Lyric = resp.Lrc.Lyric;
lyricVo.SetLyric(resp.Lrc.Lyric);
}
if (resp.Tlyric != null)
{
lyricVo.TranslateLyric = resp.Tlyric.Lyric;
lyricVo.SetTranslateLyric(resp.Tlyric.Lyric);
}

return lyricVo;
Expand Down
17 changes: 9 additions & 8 deletions MusicLyricApp/Api/QQMusicApiV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ protected override LyricVo GetLyricVo0(string songId)
{
var resp = _api.GetLyric(songId);

if (resp.Code == 0)
if (resp.Code != 0)
{
return new LyricVo
{
Lyric = resp.lyric ?? string.Empty,
TranslateLyric = resp.trans ?? string.Empty
};
throw new MusicLyricException(ErrorMsg.LRC_NOT_EXIST);
}

throw new MusicLyricException(ErrorMsg.LRC_NOT_EXIST);

var lyricVo = new LyricVo();

lyricVo.SetLyric(resp.lyric);
lyricVo.SetTranslateLyric(resp.trans);

return lyricVo;
}

/// <summary>
Expand Down
11 changes: 10 additions & 1 deletion MusicLyricApp/Bean/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ namespace MusicLyricApp.Bean
{
public static class Constants
{
public const string Version = "v4.1";
public const string Version = "v4.2";

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

public static readonly string IpaDicPath = Environment.CurrentDirectory + "\\IpaDic";

public const int SettingFormOffset = 20;

public static readonly string[] IpaDicDependency = {
IpaDicPath + "\\char.bin",
IpaDicPath + "\\matrix.bin",
IpaDicPath + "\\sys.dic",
IpaDicPath + "\\unk.dic",
};
}
}
184 changes: 124 additions & 60 deletions MusicLyricApp/Bean/MusicLyricsVO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,63 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using MusicLyricApp.Exception;
using MusicLyricApp.Utils;

namespace MusicLyricApp.Bean
{
// 双语歌词类型
public enum ShowLrcTypeEnum
{
ONLY_ORIGIN = 0, // 仅显示原文
ONLY_TRANSLATE = 1, // 仅显示译文
ORIGIN_PRIOR = 2, // 优先原文
TRANSLATE_PRIOR = 3, // 优先译文
MERGE_ORIGIN = 4, // 合并显示,优先原文
MERGE_TRANSLATE = 5, // 合并显示,优先译文
[Description("仅显示原文")] ONLY_ORIGIN = 0,
[Description("仅显示译文")] ONLY_TRANSLATE = 1,
[Description("优先原文(交错)")] ORIGIN_PRIOR_STAGGER = 2,
[Description("优先译文(交错)")] TRANSLATE_PRIOR_STAGGER = 3,
[Description("优先原文(独立)")] ORIGIN_PRIOR_ISOLATED = 4,
[Description("优先译文(独立)")] TRANSLATE_PRIOR_ISOLATED = 5,
[Description("优先原文(合并)")] ORIGIN_PRIOR_MERGE = 6,
[Description("优先译文(合并)")] TRANSLATE_PRIOR_MERGE = 7,
}

// 输出文件名类型
public enum OutputFilenameTypeEnum
{
NAME_SINGER = 0, // 歌曲名 - 歌手
SINGER_NAME = 1, // 歌手 - 歌曲名
NAME = 2 // 歌曲名
[Description("歌曲名 - 歌手")] NAME_SINGER = 0,
[Description("歌手 - 歌曲名")] SINGER_NAME = 1,
[Description("歌曲名")] NAME = 2
}

// 搜索来源
public enum SearchSourceEnum
{
NET_EASE_MUSIC = 0, // 网易云音乐
QQ_MUSIC = 1 // QQ音乐
[Description("网易云")] NET_EASE_MUSIC = 0,
[Description("QQ音乐")] QQ_MUSIC = 1
}

// 搜索类型
public enum SearchTypeEnum
{
SONG_ID = 0, // 歌曲ID
ALBUM_ID = 1 // 专辑ID
[Description("单曲")] SONG_ID = 0,
[Description("专辑")] ALBUM_ID = 1
}

// 强制两位类型
public enum DotTypeEnum
{
DISABLE = 0, // 不启用
DOWN = 1, // 截位
HALF_UP = 2 // 四舍五入
[Description("不启用")] DISABLE = 0,
[Description("截位")] DOWN = 1,
[Description("四舍五入")] HALF_UP = 2
}

// 输出文件格式
public enum OutputEncodingEnum
{
UTF_8 = 0,
UTF_8_BOM = 1,
GB_2312 = 2,
GBK = 3,
UNICODE = 4
[Description("UTF-8")] UTF_8 = 0,
[Description("UTF-8-BOM")] UTF_8_BOM = 1,
[Description("GB-2312")] GB_2312 = 2,
[Description("GBK")] GBK = 3,
[Description("UNICODE")] UNICODE = 4
}

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

// 罗马音转换模式
public enum RomajiModeEnum
{
[Description("标准模式")] NORMAL = 0,
[Description("空格分组")] SPACED = 1,
[Description("送假名")] OKURIGANA = 2,
[Description("注音假名")] FURIGANA = 3,
}

// 罗马音字体系
public enum RomajiSystemEnum
{
[Description("日本式")] NIPPON = 0,
[Description("护照式")] PASSPORT = 1,
[Description("平文式")] HEPBURN = 2,
}

/**
* 错误码
*/
Expand All @@ -79,6 +101,7 @@ public static class ErrorMsg
public const string FUNCTION_NOT_SUPPORT = "该功能暂不可用,请等待后续更新";
public const string SONG_URL_COPY_SUCCESS = "歌曲直链,已复制到剪切板";
public const string SONG_URL_GET_FAILED = "歌曲直链,获取失败";
public const string ROMAJI_DEPENDENCY_LOSS = "罗马音相关依赖缺失,请重新下载";
public const string SAVE_COMPLETE = "保存完毕,成功 {0} 跳过 {1}";

public const string GET_LATEST_VERSION_FAILED = "获取最新版本失败";
Expand Down Expand Up @@ -146,54 +169,111 @@ public class LyricVo
/// <summary>
/// 歌词内容
/// </summary>
public string Lyric { get; set; }
public string Lyric;

/// <summary>
/// 译文歌词内容
/// </summary>
public string TranslateLyric { get; set; }
public string TranslateLyric;

/// <summary>
/// 歌曲时长 ms
/// </summary>
public long Duration { get; set; }

/// <summary>
/// 实际输出的歌词
/// </summary>
public string Output { get; set; }
public void SetLyric(string content)
{
Lyric = HttpUtility.HtmlDecode(content);
}

public void SetTranslateLyric(string content)
{
TranslateLyric = HttpUtility.HtmlDecode(content);
}

public bool IsEmpty()
{
return string.IsNullOrEmpty(Lyric) && string.IsNullOrEmpty(TranslateLyric);
}
}

/// <summary>
/// 搜索信息
/// 当行歌词信息
/// </summary>
public class SearchInfo
public class LyricLineVo : IComparable
{
/// <summary>
/// 搜索来源
/// 时间戳字符串
/// </summary>
public SearchSourceEnum SearchSource { get; set; }
public string Timestamp { get; set; }

/**
* 时间偏移量
*/
public long TimeOffset { get; set; }

/// <summary>
/// 搜索类型
/// 歌词正文
/// </summary>
public SearchTypeEnum SearchType { get; set; }
public string Content { get; set; }

/// <summary>
/// 输出文件名类型
/// </summary>
public OutputFilenameTypeEnum OutputFileNameType { get; set; }
public LyricLineVo(string lyricLine)
{
var index = lyricLine.IndexOf("]");
if (index == -1)
{
Timestamp = "";
TimeOffset = -1;
Content = lyricLine;
}
else
{
Timestamp = lyricLine.Substring(0, index + 1);
Content = lyricLine.Substring(index + 1);
TimeOffset = GlobalUtils.TimestampStrToLong(Timestamp);
}
}

/// <summary>
/// 歌词展示格式
/// </summary>
public ShowLrcTypeEnum ShowLrcType { get; set; }
public LyricLineVo()
{
}

public int CompareTo(object input)
{
if (!(input is LyricLineVo obj))
{
throw new MusicLyricException(ErrorMsg.SYSTEM_ERROR);
}

if (TimeOffset == -1 && obj.TimeOffset == -1)
{
return 0;
}

if (TimeOffset == -1)
{
return -1;
}

if (obj.TimeOffset == -1)
{
return 1;
}

return (int) (TimeOffset - obj.TimeOffset);
}

public override string ToString()
{
return Timestamp + Content;
}
}

/// <summary>
/// 搜索信息
/// </summary>
public class SearchInfo
{
/// <summary>
/// 输入 ID 列表
/// </summary>
Expand All @@ -204,25 +284,9 @@ public class SearchInfo
/// </summary>
public readonly HashSet<string> SongIds = new HashSet<string>();

/// <summary>
/// 输出文件编码
/// </summary>
public OutputEncodingEnum Encoding { get; set; }

/// <summary>
/// 指定歌词合并的分隔符
/// </summary>
public string LrcMergeSeparator { get; set; }

/// <summary>
/// 小数位处理策略
/// </summary>
public DotTypeEnum DotType { get; set; }
public SettingBean SettingBeanBackup { get; set; }

/// <summary>
/// 输出文件格式
/// </summary>
public OutputFormatEnum OutputFileFormat { get; set; }
public SettingBean SettingBean { get; set; }
}

public static class EnumHelper
Expand Down
Loading

0 comments on commit 98b724b

Please sign in to comment.