Last active
February 18, 2025 23:52
-
-
Save ObjectBoxPC/03aa713e8a4936df35b8a9026531a794 to your computer and use it in GitHub Desktop.
Simple program to extract MusicBrainz disc IDs from CDs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <discid/discid.h> | |
static const char* get_device(int argc, char** argv); | |
int main(int argc, char** argv) { | |
DiscId* discid; | |
const char* device; | |
int read_successful; | |
discid = discid_new(); | |
if (discid == NULL) { | |
puts("Could not initialize discid"); | |
return 1; | |
} | |
device = get_device(argc, argv); | |
if (discid_read_sparse(discid, device, 0)) { | |
printf("Disc ID is: %s\n", discid_get_id(discid)); | |
printf("Submit via: %s\n", discid_get_submission_url(discid)); | |
read_successful = 1; | |
} else { | |
printf("Could not read %s: %s\n", device, discid_get_error_msg(discid)); | |
read_successful = 0; | |
} | |
discid_free(discid); | |
return read_successful ? 0 : 1; | |
} | |
static const char* get_device(int argc, char** argv) { | |
if (argc >= 2) { | |
return argv[1]; | |
} else { | |
return discid_get_default_device(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment