Merge pull request '修正云音乐 PC 3.0 写出的 metadata 格式与之前不一致导致解码错误的问题' (#51) from fix/ncm-3-metadata into master
Reviewed-on: #51
This commit is contained in:
commit
9205dbf701
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "unlock-music",
|
"name": "unlock-music",
|
||||||
"version": "1.10.4",
|
"version": "1.10.5",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "unlock-music",
|
"name": "unlock-music",
|
||||||
"version": "1.10.4",
|
"version": "1.10.5",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "unlock-music",
|
"name": "unlock-music",
|
||||||
"version": "1.10.4",
|
"version": "1.10.5",
|
||||||
"ext_build": 0,
|
"ext_build": 0,
|
||||||
"updateInfo": "完善音乐标签编辑功能,支持编辑更多标签",
|
"updateInfo": "完善音乐标签编辑功能,支持编辑更多标签",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -139,7 +139,7 @@ class NcmDecrypt {
|
|||||||
} else {
|
} else {
|
||||||
result = JSON.parse(plainText.slice(labelIndex + 1));
|
result = JSON.parse(plainText.slice(labelIndex + 1));
|
||||||
}
|
}
|
||||||
if (!!result.albumPic) {
|
if (result.albumPic) {
|
||||||
result.albumPic = result.albumPic.replace('http://', 'https://') + '?param=500y500';
|
result.albumPic = result.albumPic.replace('http://', 'https://') + '?param=500y500';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -160,11 +160,20 @@ class NcmDecrypt {
|
|||||||
|
|
||||||
// build artists
|
// build artists
|
||||||
let artists: string[] = [];
|
let artists: string[] = [];
|
||||||
if (!!this.oriMeta.artist) {
|
if (typeof this.oriMeta.artist === 'string') {
|
||||||
this.oriMeta.artist.forEach((arr) => artists.push(<string>arr[0]));
|
// v3.0: artist 现在可能是字符串了?
|
||||||
|
artists.push(this.oriMeta.artist);
|
||||||
|
} else if (Array.isArray(this.oriMeta.artist)) {
|
||||||
|
this.oriMeta.artist.forEach((artist) => {
|
||||||
|
if (typeof artist === 'string') {
|
||||||
|
artists.push(artist);
|
||||||
|
} else if (Array.isArray(artist) && artist[0] && typeof artist[0] === 'string') {
|
||||||
|
artists.push(artist[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (artists.length === 0 && !!info.artist) {
|
if (artists.length === 0 && info.artist) {
|
||||||
artists = info.artist
|
artists = info.artist
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((val) => val.trim())
|
.map((val) => val.trim())
|
||||||
@ -180,7 +189,7 @@ class NcmDecrypt {
|
|||||||
this.image.buffer = await img.getBufferAsync('image/jpeg');
|
this.image.buffer = await img.getBufferAsync('image/jpeg');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('get cover image failed', e);
|
console.log('fetch cover image failed', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.newMeta = { title: info.title, artists, album: this.oriMeta.album, picture: this.image?.buffer };
|
this.newMeta = { title: info.title, artists, album: this.oriMeta.album, picture: this.image?.buffer };
|
||||||
@ -226,12 +235,14 @@ class NcmDecrypt {
|
|||||||
this.audio = this._getAudio(keyBox);
|
this.audio = this._getAudio(keyBox);
|
||||||
this.format = this.oriMeta.format || SniffAudioExt(this.audio);
|
this.format = this.oriMeta.format || SniffAudioExt(this.audio);
|
||||||
this.mime = AudioMimeType[this.format];
|
this.mime = AudioMimeType[this.format];
|
||||||
await this._buildMeta();
|
|
||||||
try {
|
try {
|
||||||
|
await this._buildMeta();
|
||||||
await this._writeMeta();
|
await this._writeMeta();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('write meta data failed', e);
|
console.warn('build/write meta failed, skip.', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.gatherResult();
|
return this.gatherResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user