优化歌曲扫描
parent
1cb1be5e1b
commit
6de49d1981
|
@ -9,6 +9,7 @@
|
|||
const { exec } = require('child_process')
|
||||
const { EventEmitter } = require('events')
|
||||
const util = require('util')
|
||||
const path = require('path')
|
||||
|
||||
class AudioPlayer {
|
||||
constructor() {
|
||||
|
@ -185,10 +186,12 @@ export const ID3 = song => {
|
|||
pc.stdout.on('close', _ => {
|
||||
try {
|
||||
let { format } = JSON.parse(buf)
|
||||
let name = path.basename(song)
|
||||
format.tags = format.tags || {}
|
||||
resolve({
|
||||
title: format.tags.TITLE || format.tags.title,
|
||||
album: format.tags.ALBUM || format.tags.album,
|
||||
artist: format.tags.ARTIST || format.tags.artist,
|
||||
title: format.tags.TITLE || format.tags.title || name,
|
||||
album: format.tags.ALBUM || format.tags.album || '',
|
||||
artist: format.tags.ARTIST || format.tags.artist || '',
|
||||
duration: +format.duration,
|
||||
size: +(format.size / 1024 / 1024).toFixed(2)
|
||||
})
|
||||
|
|
|
@ -190,19 +190,21 @@ export default Anot({
|
|||
Object.assign(song, {
|
||||
title: this.form.title,
|
||||
artist: this.form.artist,
|
||||
album: this.form.album
|
||||
album: this.form.album,
|
||||
cover: '',
|
||||
kgHash: ''
|
||||
})
|
||||
|
||||
this.list.set(this.__idx__, song)
|
||||
delete this.__idx__
|
||||
|
||||
let col = new Intl.Collator('zh')
|
||||
this.list.sort((a, b) => {
|
||||
return col.compare(a.artist, b.artist)
|
||||
})
|
||||
// this.list.sort((a, b) => {
|
||||
// return col.compare(a.artist, b.artist)
|
||||
// })
|
||||
|
||||
LS.update(song.id, song)
|
||||
LS.sort('artist', true)
|
||||
// LS.sort('artist', true)
|
||||
|
||||
SONIST.clear()
|
||||
SONIST.push(LS.getAll())
|
||||
|
|
Reference in New Issue