1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

If possible display lyrics in lrc format

This commit is contained in:
LJQ 2024-05-05 00:01:52 +08:00 committed by Bill Thornton
parent 648e8ff2a6
commit 8a61ff890f
3 changed files with 19 additions and 11 deletions

View file

@ -39,6 +39,19 @@ function downloadRemoteLyrics(context, id) {
}); });
} }
function getLyricsText(lyricsObject) {
return lyricsObject.reduce((htmlAccumulator, lyric) => {
if (lyric.Start) {
const minutes = Math.floor(lyric.Start / 600000000);
const seconds = Math.floor((lyric.Start % 600000000) / 10000000);
const hundredths = Math.floor((lyric.Start % 10000000) / 100000);
htmlAccumulator += '[' + String(minutes).padStart(2, '0') + ':' + String(seconds).padStart(2, '0') + '.' + String(hundredths).padStart(2, '0') + '] ';
}
htmlAccumulator += escapeHtml(lyric.Text) + '<br/>';
return htmlAccumulator;
}, '');
}
function renderSearchResults(context, results) { function renderSearchResults(context, results) {
let lastProvider = ''; let lastProvider = '';
let html = ''; let html = '';
@ -57,10 +70,7 @@ function renderSearchResults(context, results) {
const provider = result.ProviderName; const provider = result.ProviderName;
const metadata = result.Lyrics.Metadata; const metadata = result.Lyrics.Metadata;
const lyrics = result.Lyrics.Lyrics.reduce((htmlAccumulator, lyric) => { const lyrics = getLyricsText(result.Lyrics.Lyrics);
htmlAccumulator += escapeHtml(lyric.Text) + '<br/>';
return htmlAccumulator;
}, '');
if (provider !== lastProvider) { if (provider !== lastProvider) {
if (i > 0) { if (i > 0) {
html += '</div>'; html += '</div>';
@ -225,7 +235,7 @@ function showOptions(button, context, lyricsId, lyrics) {
const items = []; const items = [];
items.push({ items.push({
name: globalize.translate('LyricsPreview'), name: globalize.translate('PreviewLyrics'),
id: 'preview' id: 'preview'
} }
, { , {
@ -294,10 +304,7 @@ function fillCurrentLyrics(context, apiClient, item) {
let html = ''; let html = '';
html += '<h2>' + globalize.translate('Lyrics') + '</h2>'; html += '<h2>' + globalize.translate('Lyrics') + '</h2>';
html += '<div>'; html += '<div>';
html += response.data.Lyrics.reduce((htmlAccumulator, lyric) => { html += getLyricsText(response.data.Lyrics);
htmlAccumulator += escapeHtml(lyric.Text) + '<br/>';
return htmlAccumulator;
}, '');
html += '</div>'; html += '</div>';
context.querySelector('.currentLyrics').innerHTML = html; context.querySelector('.currentLyrics').innerHTML = html;
} }

View file

@ -1,6 +1,6 @@
<div class="formDialogHeader"> <div class="formDialogHeader">
<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1" title="${ButtonBack}"><span class="material-icons arrow_back" aria-hidden="true"></span></button> <button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1" title="${ButtonBack}"><span class="material-icons arrow_back" aria-hidden="true"></span></button>
<h3 class="formDialogHeaderTitle">${LyricsPreview}</h3> <h3 class="formDialogHeaderTitle">${HeaderPreviewLyrics}</h3>
</div> </div>
<div class="formDialogContent smoothScrollY"> <div class="formDialogContent smoothScrollY">

View file

@ -462,6 +462,7 @@
"HeaderPleaseSignIn": "Please sign in", "HeaderPleaseSignIn": "Please sign in",
"HeaderPortRanges": "Firewall and Proxy Settings", "HeaderPortRanges": "Firewall and Proxy Settings",
"HeaderPreferredMetadataLanguage": "Preferred Metadata Language", "HeaderPreferredMetadataLanguage": "Preferred Metadata Language",
"HeaderPreviewLyrics": "Preview Lyrics",
"HeaderRecentlyPlayed": "Recently Played", "HeaderRecentlyPlayed": "Recently Played",
"HeaderRecordingMetadataSaving": "Recording Metadata", "HeaderRecordingMetadataSaving": "Recording Metadata",
"HeaderRecordingOptions": "Recording Options", "HeaderRecordingOptions": "Recording Options",
@ -996,7 +997,6 @@
"Lyric": "Lyric", "Lyric": "Lyric",
"Lyricist": "Lyricist", "Lyricist": "Lyricist",
"Lyrics": "Lyrics", "Lyrics": "Lyrics",
"LyricsPreview": "Lyrics Preview",
"ManageLibrary": "Manage library", "ManageLibrary": "Manage library",
"ManageRecording": "Manage recording", "ManageRecording": "Manage recording",
"MapChannels": "Map Channels", "MapChannels": "Map Channels",
@ -1319,6 +1319,7 @@
"Premiere": "Premiere", "Premiere": "Premiere",
"Premieres": "Premieres", "Premieres": "Premieres",
"Preview": "Preview", "Preview": "Preview",
"PreviewLyrics": "Preview Lyrics",
"Previous": "Previous", "Previous": "Previous",
"PreviousChapter": "Previous chapter", "PreviousChapter": "Previous chapter",
"PreviousTrack": "Skip to previous", "PreviousTrack": "Skip to previous",