Esempio n. 1
0
        public string RetrieveLyrics(string sourceFileUrl, string artist, string trackTitle, string album,
                                     bool synchronisedPreferred, string provider)
        {
            if (provider != ProviderName)
            {
                return(null);
            }

            var searchResult = QueryWithFeatRemoved(trackTitle, artist);

            if (searchResult == null)
            {
                return(null);
            }
            var lyricResult = RequestLyric(searchResult.id);

            if (lyricResult.lrc?.lyric == null)
            {
                return(null);
            }
            if (lyricResult.tlyric?.lyric == null || _config.format == NeteaseConfig.OutputFormat.Original)
            {
                return(lyricResult.lrc.lyric); // No need to process translation
            }
            if (_config.format == NeteaseConfig.OutputFormat.Translation)
            {
                return(lyricResult.tlyric?.lyric ?? lyricResult.lrc.lyric);
            }
            // translation
            return(LyricProcessor.InjectTranslation(lyricResult.lrc.lyric, lyricResult.tlyric.lyric));
        }
Esempio n. 2
0
        public string RetrieveLyrics(string sourceFileUrl, string artist, string trackTitle, string album,
                                     bool synchronisedPreferred, string provider)
        {
            if (provider != ProviderName)
            {
                return(null);
            }
            var isNoTranslate = File.Exists(Path.Combine(_mbApiInterface.Setting_GetPersistentStoragePath(), NoTranslateFilename));

            var searchResult = QueryWithFeatRemoved(trackTitle, artist);

            if (searchResult == null)
            {
                return(null);
            }
            var lyricResult = RequestLyric(searchResult.id);

            if (lyricResult.lrc?.lyric == null)
            {
                return(null);
            }
            if (lyricResult.tlyric?.lyric == null || isNoTranslate)
            {
                return(lyricResult.lrc.lyric); // No need to process translation
            }
            // translation
            return(LyricProcessor.InjectTranslation(lyricResult.lrc.lyric, lyricResult.tlyric.lyric));
        }
Esempio n. 3
0
        public string RetrieveLyrics(string sourceFileUrl, string artist, string trackTitle, string album,
                                     bool synchronisedPreferred, string provider)
        {
            if (provider != ProviderName)
            {
                return(null);
            }

            var id          = 0;
            var specifiedId = _mbApiInterface.Library_GetFileTag(sourceFileUrl, MetaDataType.Custom10)
                              ?? _mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Custom10);

            if (specifiedId != null && specifiedId.StartsWith("netease="))
            {
                specifiedId = specifiedId.Substring("netease=".Length);
                int.TryParse(specifiedId, out id);
            }

            if (id == 0)
            {
                var searchResult = QueryWithFeatRemoved(trackTitle, artist);
                if (searchResult == null)
                {
                    return(null);
                }
                id = searchResult.id;
            }

            if (id == 0)
            {
                return(null);
            }

            var lyricResult = RequestLyric(id);

            if (lyricResult.lrc?.lyric == null)
            {
                return(null);
            }
            if (lyricResult.tlyric?.lyric == null || _config.format == NeteaseConfig.OutputFormat.Original)
            {
                return(lyricResult.lrc.lyric); // No need to process translation
            }
            if (_config.format == NeteaseConfig.OutputFormat.Translation)
            {
                return(lyricResult.tlyric?.lyric ?? lyricResult.lrc.lyric);
            }
            // translation
            return(LyricProcessor.InjectTranslation(lyricResult.lrc.lyric, lyricResult.tlyric.lyric));
        }