🏠

Greasy Fork is available in English.

JS FLACMetadataEditor

Allows you to edit metadata of FLAC files. CO

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.org/scripts/40545/646530/JS%20FLACMetadataEditor.js


提问、发表评价,或者 举报这个脚本
作者
AHOHNMYC
版本
0.0.2.1
创建于
2018-04-12
更新于
2018-04-23
大小
19.8 KB
许可证
GPL-3.0-or-later

FLACMetadataEditor

Script allows you to edit metadata in FLAC files

inspired by egoroof's Browser ID3 Writer

Live demo

Usage:

// # Creating editor instance:
const editor = new FLACMetadataEditor(ArrayBuffer);
// # Get version:
const editorVersion = editor.scriptVersion; // <- e.g. '0.0.2.1'
// # Editing tags:
// List with standard field names: https://xiph.org/vorbis/doc/v-comment
editor.addComment('ARTIST=Laibach');
editor.addComment('ARTIST', 'Laibach');
// All properties are facultative except "data"
// Default values (except "data", of course) presented in example:
editor.addPicture({
APICtype: 3,
MIMEType: 'image/jpeg',
colorDepth: 0,
colorNumber: 0,
data: ImageDataAsArrayBuffer,
description: '',
width: 0,
height: 0
});
// remove single atrist
editor.removeComment('ARTIST', 'Laibach');
// remove all atrists
editor.removeComment('ARTIST');
// remove ALL comments
editor.removeComment();
// # Writing changes
editor.serializeMetadata();
// # Convert result to blob
const resultArrayBuffer = editor.arrayBuffer;
const blob = new Blob([resultArrayBuffer], {type: 'audio/flac'});
const url = URL.createObjectURL(blob);

What else?

Editable full FLAC metadata except CUESHEET

May be accessed through editor.metadata

Do console.log(editor) to explore it. Structures have self-descriptive names

Chains

As all public functions return this, we are able to create trains. e.g. this returns changed ArrayBuffer with only one comment — TITLE=The Whistleblowers

new FLACMetadataEditor(ArrayBuffer).removeComment().addComment('TITLE','The Whistleblowers').serializeMetadata().arrayBuffer;

TODO: