mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 19:08:33 +08:00
fix: Show correct translation for Netease Cloud Muic lyrics source
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<Identity
|
<Identity
|
||||||
Name="37412.BetterLyrics"
|
Name="37412.BetterLyrics"
|
||||||
Publisher="CN=E1428B0E-DC1D-4EA4-ACB1-4556569D5BA9"
|
Publisher="CN=E1428B0E-DC1D-4EA4-ACB1-4556569D5BA9"
|
||||||
Version="1.0.114.0" />
|
Version="1.0.115.0" />
|
||||||
|
|
||||||
<mp:PhoneIdentity PhoneProductId="ca4a4830-fc19-40d9-b823-53e2bff3d816" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
<mp:PhoneIdentity PhoneProductId="ca4a4830-fc19-40d9-b823-53e2bff3d816" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,10 @@ namespace BetterLyrics.WinUI3.Models
|
|||||||
private static readonly IResourceService _resourceService = Ioc.Default.GetRequiredService<IResourceService>();
|
private static readonly IResourceService _resourceService = Ioc.Default.GetRequiredService<IResourceService>();
|
||||||
|
|
||||||
public List<LyricsLine> LyricsLines { get; set; }
|
public List<LyricsLine> LyricsLines { get; set; }
|
||||||
private string? _languageCode;
|
|
||||||
public string? LanguageCode
|
public string? LanguageCode
|
||||||
{
|
{
|
||||||
get => _languageCode ?? LanguageHelper.DetectLanguageCode(WrappedOriginalText);
|
get => field ?? LanguageHelper.DetectLanguageCode(WrappedOriginalText);
|
||||||
set => _languageCode = value;
|
set => field = value;
|
||||||
}
|
}
|
||||||
public string WrappedOriginalText => string.Join(StringHelper.NewLine, LyricsLines.Select(line => line.OriginalText));
|
public string WrappedOriginalText => string.Join(StringHelper.NewLine, LyricsLines.Select(line => line.OriginalText));
|
||||||
|
|
||||||
|
|||||||
@@ -60,17 +60,25 @@ namespace BetterLyrics.WinUI3.Services.TranslateService
|
|||||||
|
|
||||||
public int SearchTranslatedLyricsItself(List<LyricsData> lyricsDataArr, string targetLangCode)
|
public int SearchTranslatedLyricsItself(List<LyricsData> lyricsDataArr, string targetLangCode)
|
||||||
{
|
{
|
||||||
|
int ret = -1;
|
||||||
|
float maxTranslatinRate = 0.0f;
|
||||||
|
|
||||||
if (lyricsDataArr.Count > 1)
|
if (lyricsDataArr.Count > 1)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < lyricsDataArr.Count; i++)
|
for (int i = 1; i < lyricsDataArr.Count; i++)
|
||||||
{
|
{
|
||||||
if (lyricsDataArr[i].LanguageCode == targetLangCode)
|
if (lyricsDataArr[i].LanguageCode == targetLangCode)
|
||||||
{
|
{
|
||||||
return i; // Translation lyrics data found
|
float translationRate = lyricsDataArr[i].LyricsLines.Count / lyricsDataArr[0].LyricsLines.Count;
|
||||||
|
if (translationRate > maxTranslatinRate)
|
||||||
|
{
|
||||||
|
maxTranslatinRate = translationRate;
|
||||||
|
ret = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1; // No translation lyrics data found
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user