{"id":18446348,"url":"https://github.com/misterhat/sync-music-db","last_synced_at":"2026-03-02T23:36:56.705Z","repository":{"id":44078666,"uuid":"204746325","full_name":"misterhat/sync-music-db","owner":"misterhat","description":"keep music metadata in sync with a sqlite database","archived":false,"fork":false,"pushed_at":"2022-12-10T00:12:01.000Z","size":142,"stargazers_count":3,"open_issues_count":5,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T03:08:48.653Z","etag":null,"topics":["id3","metadata","mp3-tags","music-library","sqlite"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/misterhat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-27T16:39:14.000Z","updated_at":"2021-10-08T03:01:47.000Z","dependencies_parsed_at":"2023-01-25T20:16:44.640Z","dependency_job_id":null,"html_url":"https://github.com/misterhat/sync-music-db","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterhat%2Fsync-music-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterhat%2Fsync-music-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterhat%2Fsync-music-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misterhat%2Fsync-music-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/misterhat","download_url":"https://codeload.github.com/misterhat/sync-music-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755385,"owners_count":20990616,"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":["id3","metadata","mp3-tags","music-library","sqlite"],"created_at":"2024-11-06T07:09:04.189Z","updated_at":"2026-03-02T23:36:51.680Z","avatar_url":"https://github.com/misterhat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sync-music-db\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"./sync-music-db.svg\" width=\"300\"\u003e\u003c/p\u003e\n\nkeep music metadata in sync with a [sqlite](https://sqlite.org/index.html)\ndatabase. watches a directory for changes, and updates a sqlite table with\nrelevant id3 (or [other metadata formats](\nhttps://github.com/borewit/music-metadata#support-for-audio-file-types)).\n\nthis module is intended to be used with media players, but is appropriate for\nanything that relies on a music library.\n\n## install\n\n    $ npm install sync-music-db sqlite\n\n[sqlite](https://www.npmjs.com/package/sqlite) is a\n[peerDependency](https://docs.npmjs.com/files/package.json#peerdependencies).\nthis module doesn't explicitly `require` it, but it takes a sqlite `db`\ninstance in its constructor.\n\n## example\n\n```javascript\nconst SyncMusicDb = require('./');\nconst sqlite = require('sqlite');\n\n(async () =\u003e {\n    const db = await sqlite.open('./example.sqlite');\n    const syncMusicDb = new SyncMusicDb({ db, dir: './test/_music' });\n\n    await syncMusicDb.createTable();\n\n    console.time('sync');\n\n    syncMusicDb\n        .on('ready', () =\u003e console.timeEnd('sync'))\n        .on('add', track =\u003e console.log(`${track.title} added`))\n        .on('remove', path =\u003e console.log(`${path} removed`))\n        .on('error', err =\u003e console.error(err))\n        .refresh();\n})();\n```\n\n## api\n### SyncMusicDb.TRACK\\_ATTRS\nthe columns in the `tracks` table.\n\n```javascript\n[\n    'path', 'mtime', 'title', 'artist', 'album', 'year', 'duration', 'track_no',\n    'tags', 'is_vbr', 'bitrate', 'codec', 'container'\n]\n```\n\n### syncMusicDb = new SyncMusicDb({ db, dir, tableName = 'tracks', delay = 1000, ignoreExt = true })\ncreate an `EventEmitter` to sync the specified `dir` directory to a\n[sqlite](https://www.npmjs.com/package/sqlite) `db` instance.\n\n`tableName` specifies which table has `SyncMusicDb.TRACK_ATTRS`.\n\n`delay` specifies how long to wait for file changes (in ms) before reading them.\n\n`ignoreExt` specifies whether to ignore non-media extensions.\n\n### async syncMusicDb.createTable()\ncreate the `tracks` table in the `sqliteDb` instance.\n\n### syncMusicDb.refresh()\ndo an initial sync with the specified `dir` and begin watching it for\nnew changes.\n\n### async syncMusicDb.close()\nstop syncing and watching `dir`.\n\n### syncMusicDb.on('synced', isSynced =\u003e {})\nis `sqliteDb` up-to-date with `dir`?\n\n### syncMusicDb.on('ready', () =\u003e {})\nthe initial sync has finished (from a `.refresh` call).\n\n### syncMusicDb.on('add', track =\u003e {})\n`track` has been added or updated.\n\n### syncMusicDb.on('remove', path =\u003e {})\n`path` has been removed.\n\n### syncMusicDb.isReady\nis `syncMusicDb` listening to live `dir` changes (after initial scan)?\n\n### syncMusicDb.isSynced\nis all the metadata from `dir` stored in `db`?\n\n## license\nLGPL-3.0+\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisterhat%2Fsync-music-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisterhat%2Fsync-music-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisterhat%2Fsync-music-db/lists"}