GithubHelp home page GithubHelp logo

trustedtomato / id3-rw Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 0.0 22.38 MB

Insanely quick ID3 reading & writing for JavaScript powered by WebAssembly.

Home Page: https://trustedtomato.github.io/id3-rw/

License: MIT License

JavaScript 6.36% Rust 91.97% HTML 1.40% CSS 0.10% Makefile 0.17%
id3 id3v2 id3v1 id3-reader id3-writer javascript webassembly web

id3-rw's Introduction

id3-rw

Insanely quick ID3 reading & writing for JavaScript powered by WebAssembly.

Test GitHub Pages

Screenshot of id3-rw in action.

Demos

Demos can be found on id3-rw's website.

Usage

Getting metadata

import { getMetadataFrom } from 'id3-rw'

const url = 'https://upload.wikimedia.org/wikipedia/commons/b/bd/%27Tis_a_faded_picture_by_Florrie_Forde.mp3'

await fetch(url).then(async response => {
  const stream = response.body
  const metadata = await getMetadataFrom(stream)
  expectToContain(metadata, {
    artist: "Florrie Forde\r",
    title: "'Tis a faded picture\r",
    album: "Edison Amberol: 12255\r"
  })

  // IMPORTANT! Always remember to destroy the metadata
  // after you've got the properties you need,
  // else you'll get a memory leak!
  metadata.free()
})

Modifying audio metadata

import { createTagControllerFrom } from 'id3-rw'

await fetch('https://upload.wikimedia.org/wikipedia/commons/b/bd/%27Tis_a_faded_picture_by_Florrie_Forde.mp3').then(async response => {
  const buffer = new Uint8Array(await response.arrayBuffer())

  const tagController = await createTagControllerFrom(buffer)

  // Getting metadata using the controller API
  const metadata = tagController.getMetadata()
  expectToContain(metadata, {
    artist: 'Florrie Forde\r',
    title: '\'Tis a faded picture\r',
    album: 'Edison Amberol: 12255\r'
  })
  metadata.free()

  // Changing the metadata
  tagController.setYear(1910)

  // Getting the resulting Uint8Array (the tagged file's buffer),
  // which can be used with the File System API or for a download
  const taggedBuffer = tagController.putTagInto(buffer)
  expectToEqual(taggedBuffer.length > 0, true)

  // IMPORTANT! Don't forget to destroy the tagController!
  tagController.free()
})

API

See generated docs.

Contributing

Clone this repository. You should setup & build the Rust project by running make setup and make build. To run the examples locally, you need to cd into www and run npm start. Now you should be able to access the examples at localhost:8080.

If you have any questions, feel free to open an issue!

Acknowledgement

This library uses a patched version of the rust-id3 library, so most of the hard work was done by its developer polyfloyd. Thank you!

id3-rw's People

Contributors

trustedtomato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

id3-rw's Issues

Add support for modifying not-text metadata

I have initially left out that since I didn't need it and it would require extra effort to implement, but comment on this issue if you need it. Examples include modifying cover image and adding a comment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.