Beispiel #1
0
 public LyricInfo(NcmLyric lyric, string checkSum) : this(lyric.RawVersion, lyric.TranslatedVersion, checkSum)
 {
     if (!lyric.IsCollected)
     {
         throw new ArgumentException("未收录的歌词不能添加到缓存", nameof(lyric));
     }
 }
Beispiel #2
0
        private static void UpdateCache(NcmLyric lyric, string checkSum)
        {
            int index;

            index = _allCaches.LyricCaches.FindIndex(t => t.IsMatched(lyric.Id));
            if (index != -1)
            {
                _allCaches.LyricCaches.RemoveAt(index);
            }
            _allCaches.LyricCaches.Add(new LyricCache(lyric, checkSum));
        }
Beispiel #3
0
        private static Lrc ToLrc(NcmLyric lyric)
        {
            if (!lyric.IsCollected)
            {
                Logger.Instance.LogWarning("当前歌曲的歌词未被收录!");
                return(null);
            }
            if (lyric.IsAbsoluteMusic)
            {
                Logger.Instance.LogWarning("当前歌曲是纯音乐无歌词!");
                return(null);
            }
            foreach (string mode in _lyricSettings.Modes)
            {
                switch (mode.ToUpperInvariant())
                {
                case "MERGED":
                    if (lyric.Raw == null || lyric.Translated == null)
                    {
                        continue;
                    }
                    Logger.Instance.LogInfo("已获取混合歌词。");
                    return(MergeLyric(lyric.Raw, lyric.Translated));

                case "RAW":
                    if (lyric.Raw == null)
                    {
                        continue;
                    }
                    Logger.Instance.LogInfo("已获取原始歌词。");
                    return(lyric.Raw);

                case "TRANSLATED":
                    if (lyric.Translated == null)
                    {
                        continue;
                    }
                    Logger.Instance.LogInfo("已获取翻译歌词。");
                    return(lyric.Translated);

                default:
                    throw new ArgumentOutOfRangeException(nameof(mode));
                }
            }
            Logger.Instance.LogWarning("获取歌词失败(可能歌曲是纯音乐但是未被网易云音乐标记为纯音乐)。");
            return(null);
        }