Skip to content

Commit

Permalink
添加对下载歌曲时封面图片大小的控制处理(#1609
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Jan 22, 2024
1 parent c238d49 commit 47635c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions publish/changeLog.md
Expand Up @@ -22,6 +22,7 @@
- 添加对wy源某些歌曲有问题的歌词进行修复
- 改进本地音乐在线信息的匹配机制
- 优化任务下载状态显示,现在下载时若数据传输完成但数据写入未完成时会显示相应的状态
- 添加对下载歌曲时封面图片大小的控制处理(#1609

### 修复

Expand Down
3 changes: 2 additions & 1 deletion src/common/utils/musicMeta/flacMeta.js
Expand Up @@ -59,14 +59,15 @@ const writeMeta = async(filePath, meta, picPath) => {

module.exports = (filePath, meta) => {
if (!meta.APIC) return writeMeta(filePath, meta)
const picUrl = meta.APIC
let picUrl = meta.APIC
delete meta.APIC
if (!/^http/.test(picUrl)) {
return writeMeta(filePath, meta)
}
let ext = path.extname(picUrl)
let picPath = filePath.replace(/\.flac$/, '') + (ext ? ext.replace(extReg, '$1') : '.jpg')

if (picUrl.includes('music.126.net')) picUrl += `${picUrl.includes('?') ? '&' : '?'}param=500y500`
download(picUrl, picPath).then(success => {
if (success) {
writeMeta(filePath, meta, picPath).finally(() => {
Expand Down
13 changes: 8 additions & 5 deletions src/common/utils/musicMeta/mp3Meta.js
@@ -1,6 +1,6 @@
const NodeID3 = require('node-id3')
const path = require('path')
const fs = require('fs')
// const fs = require('fs')
const download = require('./downloader')
const extReg = /^(\.(?:jpe?g|png)).*$/

Expand All @@ -23,13 +23,16 @@ module.exports = (filePath, meta) => {
}
let ext = path.extname(meta.APIC)
let picPath = filePath.replace(/\.mp3$/, '') + (ext ? ext.replace(extReg, '$1') : '.jpg')
download(meta.APIC, picPath).then(success => {

let picUrl = meta.APIC
if (picUrl.includes('music.126.net')) picUrl += `${picUrl.includes('?') ? '&' : '?'}param=500y500`
download(picUrl, picPath).then(success => {
if (success) {
meta.APIC = picPath
handleWriteMeta(meta, filePath)
fs.unlink(picPath, err => {
if (err) console.log(err.message)
})
// fs.unlink(picPath, err => {
// if (err) console.log(err.message)
// })
} else {
delete meta.APIC
handleWriteMeta(meta, filePath)
Expand Down

0 comments on commit 47635c9

Please sign in to comment.