···5566drop:
77 rm -rf oudio.db
88+99+sync:
1010+ odin run ./src/library/
+1-1
src/db/migrations/01-init.sql
···6677CREATE TABLE album (
88 id TEXT PRIMARY KEY,
99- title TEXT NOT NULL,
99+ title TEXT NOT NULL UNIQUE,
1010 mb_id TEXT UNIQUE,
1111 mb_rg_id TEXT UNIQUE
1212);
+11-6
src/db/repo/album.odin
···1717 err: db_pkg.DatabaseErrors,
1818) {
19192020+ fmt.printfln("New Album: %#v", album)
2121+2022 ok: bool
2121- mb_id, mb_rg_id: string
22232324 id := db_pkg.gen_id("album", allocator)
2425 new_id = id
···3031 delete(c_title, allocator)
3132 }
32333333- query: cstring = "INSERT INTO album (id, title, mb_id, mb_rg_id) VALUES (?, ?, ?, ?)"
3434+ query: cstring = "INSERT INTO album (id, title, mb_id, mb_rg_id) VALUES (?, ?, ?, ?) ON CONFLICT DO NOTHING"
34353536 stmt: ^sqlite.Statement
3637···6263 return new_id, .UnknownError
6364 }
64656666+6767+ c_mb_id, c_mb_rg_id: cstring
6868+ defer delete(c_mb_id, allocator)
6969+ defer delete(c_mb_rg_id, allocator)
7070+6571 if mb_id, ok := album.mb_id.?; ok {
6666- c_mb_id := strings.clone_to_cstring(mb_id, allocator)
6767- defer delete(c_mb_id, allocator)
7272+ c_mb_id = strings.clone_to_cstring(mb_id, allocator)
7373+ fmt.printfln("%s %s", mb_id, c_mb_id)
68746975 if rc := sqlite.bind_text(
7076 stmt,
···818782888389 if mb_rg_id, ok := album.mb_rg_id.?; ok {
8484- c_mb_rg_id := strings.clone_to_cstring(mb_rg_id, allocator)
8585- defer delete(c_mb_rg_id, allocator)
9090+ c_mb_rg_id = strings.clone_to_cstring(mb_rg_id, allocator)
86918792 if rc := sqlite.bind_text(
8893 stmt,
+21-1
src/formats/flac.odin
···2727 album_artist: string,
2828 track_number: u8,
2929 artists: []string,
3030+ mb_id: Maybe(string),
3131+ mb_rg_id: Maybe(string),
3232+ mb_artist_id: Maybe(string),
3033}
31343235destroy_vorbis_comment :: proc(c: VorbisComment, allocator: mem.Allocator = context.allocator) {
3336 delete(c.title, allocator)
3437 delete(c.album, allocator)
3538 delete(c.album_artist, allocator)
3636- delete(c.artists)
3939+ delete(c.artists, allocator)
4040+ if mb_id, ok := c.mb_id.?; ok {
4141+ delete(mb_id, allocator)
4242+ }
4343+4444+ if mb_rg_id, ok := c.mb_rg_id.?; ok {
4545+ delete(mb_rg_id, allocator)
4646+ }
4747+4848+ if mb_artist_id, ok := c.mb_artist_id.?; ok {
4949+ delete(mb_artist_id, allocator)
5050+ }
3751}
38523953check_is_flac :: proc(r: ^bufio.Reader) -> bool {
···178192 comment.album_artist = strings.clone(value)
179193 case "TITLE":
180194 comment.title = strings.clone(value)
195195+ case "MUSICBRAINZ_ALBUMID":
196196+ comment.mb_id = strings.clone(value)
197197+ case "MUSICBRAINZ_RELEASEGROUPID":
198198+ comment.mb_rg_id = strings.clone(value)
199199+ case "MUSICBRAINZ_ARTISTID":
200200+ comment.mb_artist_id = strings.clone(value)
181201 case "TRACKNUMBER":
182202 track_number, ok := strconv.parse_int(value)
183203 if !ok {
+4-2
src/library/sync.odin
···8383 assert(flac_err == nil)
84848585 album := types.Album {
8686- id = "",
8787- title = flac.album,
8686+ id = "",
8787+ title = flac.album,
8888+ mb_id = flac.mb_id,
8989+ mb_rg_id = flac.mb_rg_id,
8890 }
89919092 artist := types.Artist {