支持flac文件歌词写入

pull/277/head
lyswhut 2020-07-03 09:16:20 +08:00
parent 3b25e0a112
commit a5243ff58c
7 changed files with 9 additions and 10 deletions

View File

@ -41,7 +41,7 @@ const defaultSetting = {
maxDownloadNum: 3, maxDownloadNum: 3,
isDownloadLrc: false, isDownloadLrc: false,
isEmbedPic: true, isEmbedPic: true,
isEmbedLyric: true, isEmbedLyric: false,
}, },
leaderboard: { leaderboard: {
source: 'kw', source: 'kw',

View File

@ -10,7 +10,6 @@ const extReg = /^(\.(?:jpe?g|png)).*$/
const vendor = 'reference libFLAC 1.2.1 20070917' const vendor = 'reference libFLAC 1.2.1 20070917'
const writeMeta = async(filePath, meta, picPath) => { const writeMeta = async(filePath, meta, picPath) => {
if (meta.lyric) delete meta.lyric
const comments = Object.keys(meta).map(key => `${key.toUpperCase()}=${meta[key] || ''}`) const comments = Object.keys(meta).map(key => `${key.toUpperCase()}=${meta[key] || ''}`)
const data = { const data = {
vorbis: { vorbis: {

View File

@ -5,12 +5,12 @@ const request = require('request')
const extReg = /^(\.(?:jpe?g|png)).*$/ const extReg = /^(\.(?:jpe?g|png)).*$/
const handleWriteMeta = (meta, filePath) => { const handleWriteMeta = (meta, filePath) => {
if (meta.lyric) { if (meta.lyrics) {
meta.unsynchronisedLyrics = { meta.unsynchronisedLyrics = {
language: 'zho', language: 'zho',
text: meta.lyric, text: meta.lyrics,
} }
delete meta.lyric delete meta.lyrics
} }
NodeID3.write(meta, filePath) NodeID3.write(meta, filePath)
} }

View File

@ -74,7 +74,7 @@
"download_name": "Music file naming", "download_name": "Music file naming",
"download_data_embed": "Whether to embed the following content in the audio file", "download_data_embed": "Whether to embed the following content in the audio file",
"download_embed_pic": "Embedding cover", "download_embed_pic": "Embedding cover",
"download_embed_lyric": "Embedding lyric (supports MP3 format only)", "download_embed_lyric": "Embedding lyric",
"download_lyric_title": "Select whether to download the lyrics file", "download_lyric_title": "Select whether to download the lyrics file",
"download_lyric": "Lyrics download", "download_lyric": "Lyrics download",
"download_name1": "Title - Artist", "download_name1": "Title - Artist",

View File

@ -74,7 +74,7 @@
"download_name": "文件命名方式", "download_name": "文件命名方式",
"download_data_embed": "是否将以下内容嵌入到音频文件中", "download_data_embed": "是否将以下内容嵌入到音频文件中",
"download_embed_pic": "封面嵌入", "download_embed_pic": "封面嵌入",
"download_embed_lyric": "歌词嵌入(只支持 mp3 格式)", "download_embed_lyric": "歌词嵌入",
"download_lyric_title": "是否同时下载歌词文件", "download_lyric_title": "是否同时下载歌词文件",
"download_lyric": "歌词下载", "download_lyric": "歌词下载",
"download_name1": "歌名 - 歌手", "download_name1": "歌名 - 歌手",

View File

@ -69,7 +69,7 @@
"download_name": "文件命名方式", "download_name": "文件命名方式",
"download_data_embed": "是否將以下內容嵌入到音頻文件中", "download_data_embed": "是否將以下內容嵌入到音頻文件中",
"download_embed_pic": "封面嵌入", "download_embed_pic": "封面嵌入",
"download_embed_lyric": "歌詞嵌入(只支持 mp3 格式)", "download_embed_lyric": "歌詞嵌入",
"download_lyric_title": "是否同時下載歌詞文件", "download_lyric_title": "是否同時下載歌詞文件",
"download_lyric": "歌詞下載", "download_lyric": "歌詞下載",
"download_name1": "歌名 - 歌手", "download_name1": "歌名 - 歌手",

View File

@ -184,13 +184,13 @@ const saveMeta = (downloadInfo, filePath, isEmbedPic, isEmbedLyric) => {
}) })
: Promise.resolve(), : Promise.resolve(),
] ]
Promise.all(tasks).then(([imgUrl, lyric]) => { Promise.all(tasks).then(([imgUrl, lyrics]) => {
setMeta(filePath, { setMeta(filePath, {
title: downloadInfo.musicInfo.name, title: downloadInfo.musicInfo.name,
artist: downloadInfo.musicInfo.singer, artist: downloadInfo.musicInfo.singer,
album: downloadInfo.musicInfo.albumName, album: downloadInfo.musicInfo.albumName,
APIC: imgUrl, APIC: imgUrl,
lyric, lyrics,
}) })
}) })
} }