lyrics translations
This commit is contained in:
parent
23541ae239
commit
1f47407622
3 changed files with 27 additions and 6 deletions
|
@ -319,7 +319,7 @@
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
<div class="app-drawer" v-if="drawertest">
|
<div class="app-drawer" v-if="drawertest">
|
||||||
<lyrics-view v-if="drawertest && lyricon" :time="lyriccurrenttime" :lyrics="lyrics"></lyrics-view>
|
<lyrics-view v-if="drawertest && lyricon" :time="lyriccurrenttime" :lyrics="lyrics" ></lyrics-view>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -605,6 +605,9 @@
|
||||||
<h3 class="lyric-line" @click="app.seekTo(lyric.startTime, false)"
|
<h3 class="lyric-line" @click="app.seekTo(lyric.startTime, false)"
|
||||||
v-bind:class="{ active: app.getLyricClass(lyric.startTime, lyric.endTime)}">
|
v-bind:class="{ active: app.getLyricClass(lyric.startTime, lyric.endTime)}">
|
||||||
{{ lyric.line }}
|
{{ lyric.line }}
|
||||||
|
<div class="lyrics-translation" v-if="lyric.translation && lyric.translation != ''">
|
||||||
|
{{ lyric.translation }}
|
||||||
|
<div>
|
||||||
</h3>
|
</h3>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
|
|
@ -53,7 +53,7 @@ Vue.component('mediaitem-list-item', {
|
||||||
|
|
||||||
Vue.component('lyrics-view', {
|
Vue.component('lyrics-view', {
|
||||||
template: '#lyrics-view',
|
template: '#lyrics-view',
|
||||||
props: ["time", "lyrics"],
|
props: ["time", "lyrics", "translation"],
|
||||||
methods: {}
|
methods: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -472,8 +472,10 @@ const app = new Vue({
|
||||||
for (var i = u.length -1; i >= 0; i--) {
|
for (var i = u.length -1; i >= 0; i--) {
|
||||||
let xline = (/(\[[0-9.:\[\]]*\])+(.*)/).exec(u[i])
|
let xline = (/(\[[0-9.:\[\]]*\])+(.*)/).exec(u[i])
|
||||||
let end = (preLrc.length > 0) ? ((preLrc[preLrc.length-1].startTime) ?? 99999) : 99999
|
let end = (preLrc.length > 0) ? ((preLrc[preLrc.length-1].startTime) ?? 99999) : 99999
|
||||||
preLrc.push({ startTime: app.toMS(xline[1].substring(1,xline[1].length - 2)) ?? 0, endTime: end, line: xline[2] })
|
preLrc.push({ startTime: app.toMS(xline[1].substring(1,xline[1].length - 2)) ?? 0, endTime: end, line: xline[2], translation: '' })
|
||||||
}
|
}
|
||||||
|
if (preLrc.length > 0)
|
||||||
|
preLrc.push({startTime: 0,endTime: preLrc[preLrc.length-1].startTime, line: "lrcInstrumental", translation: ''});
|
||||||
app.lyrics = preLrc.reverse();
|
app.lyrics = preLrc.reverse();
|
||||||
if (lrcfile != null && lrcfile != '') {
|
if (lrcfile != null && lrcfile != '') {
|
||||||
// load translation
|
// load translation
|
||||||
|
@ -507,9 +509,20 @@ const app = new Vue({
|
||||||
let status2 = jsonResponse2["message"]["header"]["status_code"];
|
let status2 = jsonResponse2["message"]["header"]["status_code"];
|
||||||
if (status2 == 200) {
|
if (status2 == 200) {
|
||||||
try {
|
try {
|
||||||
let lyrics = jsonResponse2["message"]["body"]["translations_list"];
|
let preTrans = []
|
||||||
if (lyrics.length > 0) {
|
let u = app.lyrics;
|
||||||
// convert translations to suitable json
|
let translation_list = jsonResponse2["message"]["body"]["translations_list"];
|
||||||
|
if (translation_list.length > 0) {
|
||||||
|
for (var i = 0; i < u.length - 1; i++) {
|
||||||
|
preTrans[i] = ""
|
||||||
|
for (var trans_line of translation_list){
|
||||||
|
if (u[i].line == " "+trans_line["translation"]["matched_line"]){
|
||||||
|
u[i].translation = trans_line["translation"]["description"];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
app.lyrics = u;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
/// not found trans -> ignore
|
/// not found trans -> ignore
|
||||||
|
|
|
@ -1264,6 +1264,11 @@ input[type=range].web-slider::-webkit-slider-runnable-track {
|
||||||
margin: 3px;
|
margin: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.lyrics-translation {
|
||||||
|
font-size: 1.6rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes lyricWaitingLine {
|
@keyframes lyricWaitingLine {
|
||||||
0% {
|
0% {
|
||||||
opacity: 0.25;
|
opacity: 0.25;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue