{"id":22235844,"url":"https://github.com/sentriz/go-taglib","last_synced_at":"2025-04-14T07:10:34.655Z","repository":{"id":258010089,"uuid":"860662617","full_name":"sentriz/go-taglib","owner":"sentriz","description":"portable Go audio metadata read/write via TagLib compiled to WASM","archived":false,"fork":false,"pushed_at":"2025-02-01T03:42:41.000Z","size":2220,"stargazers_count":47,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T12:42:45.322Z","etag":null,"topics":["audio-metadata","flac","mp3","ogg","taglib","wasm","wazero"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sentriz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-20T21:55:26.000Z","updated_at":"2025-03-26T07:24:18.000Z","dependencies_parsed_at":"2024-10-26T20:34:03.452Z","dependency_job_id":"dbdee8fa-ad9d-43d1-b5b1-78eb7039e585","html_url":"https://github.com/sentriz/go-taglib","commit_stats":null,"previous_names":["sentriz/go-taglib-wasm","sentriz/go-taglib"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sentriz%2Fgo-taglib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sentriz%2Fgo-taglib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sentriz%2Fgo-taglib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sentriz%2Fgo-taglib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sentriz","download_url":"https://codeload.github.com/sentriz/go-taglib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837287,"owners_count":21169374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio-metadata","flac","mp3","ogg","taglib","wasm","wazero"],"created_at":"2024-12-03T02:44:15.497Z","updated_at":"2025-04-14T07:10:34.646Z","avatar_url":"https://github.com/sentriz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-taglib\n\nThis project is a Go library for reading and writing audio metadata tags. By packaging an embedded **WASM** binary, the library needs no external dependencies or CGo. Meaning easy static builds and cross compilation.\n\n[![godoc](https://img.shields.io/badge/pkg.go.dev-doc-blue)](http://pkg.go.dev/go.senan.xyz/taglib)\n\n## Features\n\n- **Read** and **write** metadata tags for audio files, including support for **multi-valued** tags.\n- Retrieve audio properties such as length, bitrate, sample rate, and channels.\n- Supports multiple audio formats including _MP3_, _FLAC_, _M4A_, _WAV_, _OGG_, _WMA_, and more.\n- Safe for concurrent use\n- [Reasonably fast](#performance)\n\n## Usage\n\nAdd the library to your project with `go get go.senan.xyz/taglib@latest`\n\n### Reading metadata\n\n```go\nfunc main() {\n    tags, err := taglib.ReadTags(\"path/to/audiofile.mp3\")\n    // check(err)\n\n    fmt.Printf(\"tags: %v\\n\", tags) // map[string][]string\n\n    fmt.Printf(\"AlbumArtist: %q\\n\", tags[taglib.AlbumArtist])\n    fmt.Printf(\"Album: %q\\n\", tags[taglib.Album])\n    fmt.Printf(\"TrackNumber: %q\\n\", tags[taglib.TrackNumber])\n}\n```\n\n### Writing metadata\n\n```go\nfunc main() {\n    err := taglib.WriteTags(\"path/to/audiofile.mp3\", map[string][]string{\n        // Multi-valued tags allowed\n        taglib.AlbumArtist:   {\"David Bynre\", \"Brian Eno\"},\n        taglib.Album:         {\"My Life in the Bush of Ghosts\"},\n        taglib.TrackNumber:   {\"1\"},\n\n        // Non-standard allowed too\n        \"ALBUMARTIST_CREDIT\": {\"Brian Eno \u0026 David Bynre\"},\n    }, 0)\n    // check(err)\n}\n```\n\n#### Options for writing\n\nThe behaviour of writing can be configured with some bitset flags\n\nThe options are\n\n- `Clear` which indicates that all existing tags not present in the new map should be removed\n- `DiffBeforeWrite` which won't modify the file on disk if the new metadata is the same as the old\n\nThe options can be combined the with the bitwise `OR` operator (`|`)\n\n```go\n    taglib.WriteTags(path, tags, taglib.Clear|taglib.DiffBeforeWrite) // clear and diff\n    taglib.WriteTags(path, tags, taglib.DiffBeforeWrite)              // only diff diff\n    taglib.WriteTags(path, tags, taglib.Clear)                        // only clear\n    taglib.WriteTags(path, tags, 0)                                   // don't clear or diff\n```\n\n### Reading properties\n\n```go\nfunc main() {\n    properties, err := taglib.ReadProperties(\"path/to/audiofile.mp3\")\n    // check(err)\n\n    fmt.Printf(\"Length: %v\\n\", properties.Length)\n    fmt.Printf(\"Bitrate: %d\\n\", properties.Bitrate)\n    fmt.Printf(\"SampleRate: %d\\n\", properties.SampleRate)\n    fmt.Printf(\"Channels: %d\\n\", properties.Channels)\n}\n```\n\n## Manually Building and Using the WASM Binary\n\nThe binary is already included in the package. However if you want to manually build and override it, you can with WASI SDK and Go build flags\n\n1. Install [WASI SDK](https://github.com/WebAssembly/wasi-sdk) globally. The default installation path is `/opt/wasi-sdk/`\n2. Clone this repository and Git submodules\n\n   ```console\n   $ git clone \"https://github.com/sentriz/go-taglib.git\" --recursive\n   $ cd go-taglib\n   ```\n\n3. Generate the WASM binary:\n\n   ```console\n   $ go generate ./...\n   $ # taglib.wasm created\n   ```\n\n4. Use the new binary in your project\n\n   ```console\n   $ GCO_ENABLED=0 go build -ldflags=\"-X 'go.senan.xyz/taglib.binaryPath=/path/to/taglib.wasm'\" ./your/project/...\n   ```\n\n### Performance\n\nIn this example, tracks are read on average in `0.3 ms`, and written in `1.85 ms`\n\n```\ngoos: linux\ngoarch: amd64\npkg: go.senan.xyz/taglib\ncpu: AMD Ryzen 7 7840U w/ Radeon  780M Graphics\nBenchmarkWrite-16         608   1847873 ns/op\nBenchmarkRead-16         3802    299247 ns/op\n```\n\n## License\n\nThis project is licensed under the GNU Lesser General Public License v2.1. See the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n\n## Acknowledgments\n\n- [TagLib](https://taglib.org/) for the audio metadata library.\n- [Wazero](https://github.com/tetratelabs/wazero) for the WebAssembly runtime in Go.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsentriz%2Fgo-taglib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsentriz%2Fgo-taglib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsentriz%2Fgo-taglib/lists"}