新增将播放与下载的歌词转换为繁体中文选项

pull/733/head
lyswhut 2021-12-06 16:07:12 +08:00
parent ec3a0e08c3
commit b350f133b0
8 changed files with 36 additions and 11 deletions

View File

@ -4,6 +4,7 @@
- 播放详情页新增桌面歌词切换按钮 - 播放详情页新增桌面歌词切换按钮
- 新增将我的列表保存为TXT、CSV格式可以去设置-备份与恢复中使用注意此类格式的备份目前不支持恢复到LX Music中 - 新增将我的列表保存为TXT、CSV格式可以去设置-备份与恢复中使用注意此类格式的备份目前不支持恢复到LX Music中
- 新增根据歌曲名、歌手名等字段对列表自动排序的功能,可以在我的列表右击列表名弹出的菜单中使用 - 新增根据歌曲名、歌手名等字段对列表自动排序的功能,可以在我的列表右击列表名弹出的菜单中使用
- 新增将播放与下载的歌词转换为繁体中文选项,默认关闭,可在设置-播放设置中开启
### 优化 ### 优化
@ -13,6 +14,10 @@
- 修复kw源某些歌曲的歌词提取异常的问题 - 修复kw源某些歌曲的歌词提取异常的问题
### 变更
- 现在使用繁体中文语言时将不再自动转换歌词,转换行为将由上面新增的转换开关控制
### 其他 ### 其他
- 升级vue到 3.x - 升级vue到 3.x

View File

@ -2,7 +2,7 @@ const path = require('path')
const os = require('os') const os = require('os')
const defaultSetting = { const defaultSetting = {
version: '1.0.45', version: '1.0.46',
player: { player: {
togglePlayMethod: 'listLoop', togglePlayMethod: 'listLoop',
highQuality: false, highQuality: false,
@ -12,6 +12,7 @@ const defaultSetting = {
mediaDeviceId: 'default', mediaDeviceId: 'default',
isMediaDeviceRemovedStopPlay: false, isMediaDeviceRemovedStopPlay: false,
isShowLyricTranslation: false, isShowLyricTranslation: false,
isS2t: false, // 是否将歌词从简体转换为繁体
isPlayLxlrc: true, isPlayLxlrc: true,
isSavePlayTime: false, isSavePlayTime: false,
}, },

View File

@ -305,6 +305,7 @@
"setting__other_tray_theme_origin": "Primary Color", "setting__other_tray_theme_origin": "Primary Color",
"setting__play": "Play", "setting__play": "Play",
"setting__play_lyric_lxlrc": "Use Karaoke-style lyrics playback (if supported)", "setting__play_lyric_lxlrc": "Use Karaoke-style lyrics playback (if supported)",
"setting__play_lyric_s2t": "Convert the playing and downloading lyrics to Traditional Chinese",
"setting__play_lyric_transition": "Show lyrics translation", "setting__play_lyric_transition": "Show lyrics translation",
"setting__play_mediaDevice": "Audio output", "setting__play_mediaDevice": "Audio output",
"setting__play_mediaDevice_remove_stop_play": "Pause the song when the current sound output device is changed", "setting__play_mediaDevice_remove_stop_play": "Pause the song when the current sound output device is changed",

View File

@ -305,6 +305,7 @@
"setting__other_tray_theme_origin": "原色", "setting__other_tray_theme_origin": "原色",
"setting__play": "播放设置", "setting__play": "播放设置",
"setting__play_lyric_lxlrc": "使用卡拉OK式歌词播放如果支持", "setting__play_lyric_lxlrc": "使用卡拉OK式歌词播放如果支持",
"setting__play_lyric_s2t": "将播放与下载的歌词转换为繁体中文",
"setting__play_lyric_transition": "显示歌词翻译", "setting__play_lyric_transition": "显示歌词翻译",
"setting__play_mediaDevice": "音频输出", "setting__play_mediaDevice": "音频输出",
"setting__play_mediaDevice_remove_stop_play": "当前的声音输出设备被改变时暂停播放歌曲", "setting__play_mediaDevice_remove_stop_play": "当前的声音输出设备被改变时暂停播放歌曲",

View File

@ -305,6 +305,7 @@
"setting__other_tray_theme_origin": "原色", "setting__other_tray_theme_origin": "原色",
"setting__play": "播放設置", "setting__play": "播放設置",
"setting__play_lyric_lxlrc": "使用卡拉OK式歌詞播放如果支持", "setting__play_lyric_lxlrc": "使用卡拉OK式歌詞播放如果支持",
"setting__play_lyric_s2t": "將播放與下載的歌詞轉換為繁體中文",
"setting__play_lyric_transition": "顯示歌詞翻譯", "setting__play_lyric_transition": "顯示歌詞翻譯",
"setting__play_mediaDevice": "音頻輸出", "setting__play_mediaDevice": "音頻輸出",
"setting__play_mediaDevice_remove_stop_play": "當前的聲音輸出設備被改變時暫停播放歌曲", "setting__play_mediaDevice_remove_stop_play": "當前的聲音輸出設備被改變時暫停播放歌曲",

View File

@ -130,7 +130,7 @@ export default ({ setting }) => {
getLrc(targetSong).then(({ lyric, tlyric, lxlyric }) => { getLrc(targetSong).then(({ lyric, tlyric, lxlyric }) => {
if (targetSong.songmid !== musicInfo.songmid) return if (targetSong.songmid !== musicInfo.songmid) return
return ( return (
global.i18n.locale == 'zh-tw' setting.value.player.isS2t
? Promise.all([ ? Promise.all([
lyric ? langS2T(lyric) : Promise.resolve(''), lyric ? langS2T(lyric) : Promise.resolve(''),
tlyric ? langS2T(tlyric) : Promise.resolve(''), tlyric ? langS2T(tlyric) : Promise.resolve(''),

View File

@ -177,7 +177,7 @@ const handleGetLyric = function(musicInfo, retryedSource = [], originMusic) {
}) })
} }
const getLyric = function(musicInfo, isUseOtherSource) { const getLyric = function(musicInfo, isUseOtherSource, isS2t) {
return getLyricFromStorage(musicInfo).then(lrcInfo => { return getLyricFromStorage(musicInfo).then(lrcInfo => {
return ( return (
lrcInfo.lyric lrcInfo.lyric
@ -194,8 +194,7 @@ const getLyric = function(musicInfo, isUseOtherSource) {
return null return null
}) })
).then(lrcs => { ).then(lrcs => {
if (!lrcs) return lrcs if (!lrcs || !isS2t) return lrcs
if (global.i18n.locale != 'zh-tw') return lrcs
return rendererInvoke(NAMES.mainWindow.lang_s2t, Buffer.from(lrcs.lyric).toString('base64')).then(b64 => Buffer.from(b64, 'base64').toString()).then(lyric => { return rendererInvoke(NAMES.mainWindow.lang_s2t, Buffer.from(lrcs.lyric).toString('base64')).then(b64 => Buffer.from(b64, 'base64').toString()).then(lyric => {
lrcs.lyric = lyric lrcs.lyric = lyric
return lrcs return lrcs
@ -213,7 +212,7 @@ const fixKgLyric = lrc => /\[00:\d\d:\d\d.\d+\]/.test(lrc) ? lrc.replace(/(?:\[0
* @param {*} filePath * @param {*} filePath
* @param {*} isEmbedPic // 是否嵌入图片 * @param {*} isEmbedPic // 是否嵌入图片
*/ */
const saveMeta = function(downloadInfo, filePath, isUseOtherSource, isEmbedPic, isEmbedLyric) { const saveMeta = function({ downloadInfo, filePath, isUseOtherSource, isEmbedPic, isEmbedLyric, isS2t }) {
if (downloadInfo.metadata.type === 'ape') return if (downloadInfo.metadata.type === 'ape') return
const tasks = [ const tasks = [
isEmbedPic isEmbedPic
@ -229,7 +228,7 @@ const saveMeta = function(downloadInfo, filePath, isUseOtherSource, isEmbedPic,
}) })
: Promise.resolve(), : Promise.resolve(),
isEmbedLyric isEmbedLyric
? getLyric.call(this, downloadInfo.metadata.musicInfo, isUseOtherSource) ? getLyric.call(this, downloadInfo.metadata.musicInfo, isUseOtherSource, isS2t)
: Promise.resolve(), : Promise.resolve(),
] ]
Promise.all(tasks).then(([imgUrl, lyrics = {}]) => { Promise.all(tasks).then(([imgUrl, lyrics = {}]) => {
@ -249,8 +248,8 @@ const saveMeta = function(downloadInfo, filePath, isUseOtherSource, isEmbedPic,
* @param {*} downloadInfo * @param {*} downloadInfo
* @param {*} filePath * @param {*} filePath
*/ */
const downloadLyric = function(downloadInfo, isUseOtherSource, filePath, lrcFormat) { const downloadLyric = function({ downloadInfo, isUseOtherSource, filePath, lrcFormat, isS2t }) {
getLyric.call(this, downloadInfo.metadata.musicInfo, isUseOtherSource).then(lrcs => { getLyric.call(this, downloadInfo.metadata.musicInfo, isUseOtherSource, isS2t).then(lrcs => {
if (lrcs?.lyric) { if (lrcs?.lyric) {
lrcs.lyric = fixKgLyric(lrcs.lyric) lrcs.lyric = fixKgLyric(lrcs.lyric)
saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric, lrcFormat) saveLrc(filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'), lrcs.lyric, lrcFormat)
@ -408,8 +407,23 @@ const actions = {
commit('onCompleted', downloadInfo) commit('onCompleted', downloadInfo)
dispatch('startTask') dispatch('startTask')
saveMeta.call(_this, downloadInfo, downloadInfo.metadata.filePath, rootState.setting.download.isUseOtherSource, rootState.setting.download.isEmbedPic, rootState.setting.download.isEmbedLyric) saveMeta.call(_this, {
if (rootState.setting.download.isDownloadLrc) downloadLyric.call(_this, downloadInfo, rootState.setting.download.isUseOtherSource, downloadInfo.metadata.filePath, rootState.setting.download.lrcFormat) downloadInfo,
filePath: downloadInfo.metadata.filePath,
isUseOtherSource: rootState.setting.download.isUseOtherSource,
isEmbedPic: rootState.setting.download.isEmbedPic,
isEmbedLyric: rootState.setting.download.isEmbedLyric,
isS2t: rootState.setting.player.isS2t,
})
if (rootState.setting.download.isDownloadLrc) {
downloadLyric.call(_this, {
downloadInfo,
isUseOtherSource: rootState.setting.download.isUseOtherSource,
filePath: downloadInfo.metadata.filePath,
lrcFormat: rootState.setting.download.lrcFormat,
isS2t: rootState.setting.player.isS2t,
})
}
console.log('on complate') console.log('on complate')
}, },
onError(err) { onError(err) {

View File

@ -5,6 +5,8 @@ dd
base-checkbox(id="setting_player_save_play_time" v-model="currentStting.player.isSavePlayTime" :label="$t('setting__play_save_play_time')") base-checkbox(id="setting_player_save_play_time" v-model="currentStting.player.isSavePlayTime" :label="$t('setting__play_save_play_time')")
.gap-top .gap-top
base-checkbox(id="setting_player_lyric_transition" v-model="currentStting.player.isShowLyricTranslation" :label="$t('setting__play_lyric_transition')") base-checkbox(id="setting_player_lyric_transition" v-model="currentStting.player.isShowLyricTranslation" :label="$t('setting__play_lyric_transition')")
.gap-top
base-checkbox(id="setting_player_lyric_s2t" v-model="currentStting.player.isS2t" :label="$t('setting__play_lyric_s2t')")
.gap-top .gap-top
base-checkbox(id="setting_player_lyric_play_lxlrc" v-model="currentStting.player.isPlayLxlrc" :label="$t('setting__play_lyric_lxlrc')") base-checkbox(id="setting_player_lyric_play_lxlrc" v-model="currentStting.player.isPlayLxlrc" :label="$t('setting__play_lyric_lxlrc')")
.gap-top .gap-top