This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
appcat
/
sonist
Archived
1
0
Fork 0

优化歌曲扫描

2.x
宇天 2018-12-30 18:30:27 +08:00
parent 1cb1be5e1b
commit 6de49d1981
2 changed files with 13 additions and 8 deletions

9
dist/audio/index.js vendored
View File

@ -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)
})

View File

@ -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())