From 5ee5faaed4deb59acbda219b974dc3a43482f192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E7=85=8C?= Date: Tue, 4 Aug 2020 22:50:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E5=88=A4=E6=96=AD=E4=B8=BA=E9=9D=9ENLyric?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=AD=8C=E8=AF=8D=E7=9A=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=20Batch=20Step=E6=94=B9=E4=B8=BA100?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NLyric/NLyric.csproj | 4 ++-- NLyric/NLyricImpl.cs | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/NLyric/NLyric.csproj b/NLyric/NLyric.csproj index 7fa27e5..0efaa61 100644 --- a/NLyric/NLyric.csproj +++ b/NLyric/NLyric.csproj @@ -4,8 +4,8 @@ NLyric NLyric Copyright © 2019-2020 Wwh - 2.6.0.0 - 2.6.0.0 + 2.6.0.1 + 2.6.0.1 ..\bin\$(Configuration) Exe netcoreapp3.1;net472 diff --git a/NLyric/NLyricImpl.cs b/NLyric/NLyricImpl.cs index 5097b80..ffeba7e 100644 --- a/NLyric/NLyricImpl.cs +++ b/NLyric/NLyricImpl.cs @@ -113,14 +113,19 @@ private static AudioInfo[] LoadAllAudioInfos(string directory) { finally { audioFile?.Dispose(); } - var trackInfo = _database.TrackInfos.Match(audioInfo.Album, audioInfo.Track); + TrackInfo trackInfo; + lock (_database.TrackInfos) + trackInfo = _database.TrackInfos.Match(audioInfo.Album, audioInfo.Track); if (!(trackInfo is null)) { audioInfo.TrackInfo = trackInfo; return audioInfo; } // 尝试从数据库获取歌曲 if (The163KeyHelper.TryGetTrackId(tag, out int trackId)) { - audioInfo.TrackInfo = new TrackInfo(audioInfo.Track, audioInfo.Album, trackId); + trackInfo = new TrackInfo(audioInfo.Track, audioInfo.Album, trackId); + lock (_database.TrackInfos) + _database.TrackInfos.Add(trackInfo); + audioInfo.TrackInfo = trackInfo; return audioInfo; } // 尝试从163Key获取ID @@ -145,6 +150,7 @@ private static async Task LoadAllAudioInfoCandidates(AudioInfo[] audioInfoCandid else { FastConsole.WriteInfo($"已获取文件\"{Path.GetFileName(candidate.Path)}\"的网易云音乐ID: {trackInfo.Id}。"); candidate.TrackInfo = new TrackInfo(candidate.Track, candidate.Album, trackInfo.Id); + _database.TrackInfos.Add(candidate.TrackInfo); } callback?.Invoke(candidate); FastConsole.WriteNewLine(); @@ -696,7 +702,7 @@ private static Task AccelerateAllTracksAsync(AudioInfo[] audioInfos) { } private static async Task AccelerateAllLyricsAsync(AudioInfo[] audioInfos) { - const int STEP = 50; + const int STEP = 100; int[] trackIds = audioInfos.Select(t => t.TrackInfo.Id).ToArray(); for (int i = 0; i < trackIds.Length; i += STEP) {