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