Skip to content

Commit

Permalink
修复不显示"正在尝试下载xxx的歌词。"
Browse files Browse the repository at this point in the history
  • Loading branch information
wwh1004 committed Feb 7, 2020
1 parent 8bf748f commit 7db6bb1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion NLyric/NLyricImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ internal static class NLyricImpl {
string databasePath;
AudioInfo[] audioInfos;

FastConsole.WriteLine("程序会自动过滤相似度为0的结果与歌词未被收集的结果!!!", ConsoleColor.Green);
loginTask = LoginIfNeedAsync(arguments);
databasePath = Path.Combine(arguments.Directory, ".nlyric");
LoadDatabase(databasePath);
Expand Down Expand Up @@ -60,6 +61,8 @@ internal static class NLyricImpl {
SaveDatabaseCore(databasePath);
FastConsole.WriteNewLine();
}
if (arguments.UseBatch)
PrepareAllLyrics(audioInfos);
foreach (AudioInfo audioInfo in audioInfos)
if (!(audioInfo.TrackInfo is null))
await TryDownloadLyricAsync(audioInfo);
Expand Down Expand Up @@ -253,6 +256,15 @@ internal static class NLyricImpl {
return ncmTracks;
}

private static void PrepareAllLyrics(AudioInfo[] audioInfos) {
int[] trackIds;

trackIds = audioInfos.Where(t => !(t.TrackInfo is null)).Select(t => t.TrackInfo.Id).ToArray();
for (int i = 0; i < trackIds.Length; i += 50) {
// TODO
}
}

private static async Task<bool> TryDownloadLyricAsync(AudioInfo audioInfo) {
string lrcPath;
bool hasLrcFile;
Expand All @@ -272,12 +284,12 @@ internal static class NLyricImpl {
FastConsole.WriteException(ex);
return false;
}
FastConsole.WriteInfo($"正在尝试下载\"{Path.GetFileName(audioInfo.Path)} ({audioInfo.Track})\"的歌词。");
if (hasLrcFile) {
// 如果歌词存在,判断是否需要覆盖或更新
LyricInfo lyricInfo;

lyricInfo = trackInfo.Lyric;
FastConsole.WriteInfo($"正在尝试下载\"{Path.GetFileName(audioInfo.Path)} ({audioInfo.Track})\"的歌词。");
if (!(lyricInfo is null) && lyricInfo.CheckSum == lyricCheckSum) {
// 歌词由NLyric创建
if (ncmLyric.RawVersion <= lyricInfo.RawVersion && ncmLyric.TranslatedVersion <= lyricInfo.TranslatedVersion) {
Expand Down

0 comments on commit 7db6bb1

Please sign in to comment.