/usr/share/doc/libgroove-dev/examples/metadata.c is in libgroove-dev 4.3.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | /* read or update metadata in a media file */
#include <groove/groove.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static int usage(char *exe) {
fprintf(stderr, "Usage: %s <file> [--update key value] [--delete key]\n"
"Repeat --update and --delete as many times as you need to.\n", exe);
return 1;
}
int main(int argc, char * argv[]) {
/* parse arguments */
char *exe = argv[0];
char *filename;
struct GrooveFile *file;
int i;
char *arg;
char *key;
char *value;
struct GrooveTag *tag;
if (argc < 2)
return usage(exe);
printf("Using libgroove v%s\n", groove_version());
filename = argv[1];
groove_init();
atexit(groove_finish);
groove_set_logging(GROOVE_LOG_INFO);
file = groove_file_open(filename);
if (!file) {
fprintf(stderr, "error opening file\n");
return 1;
}
for (i = 2; i < argc; i += 1) {
arg = argv[i];
if (strcmp("--update", arg) == 0) {
if (i + 2 >= argc) {
groove_file_close(file);
fprintf(stderr, "--update requires 2 arguments");
return usage(exe);
}
key = argv[++i];
value = argv[++i];
groove_file_metadata_set(file, key, value, 0);
} else if (strcmp("--delete", arg) == 0) {
if (i + 1 >= argc) {
groove_file_close(file);
fprintf(stderr, "--delete requires 1 argument");
return usage(exe);
}
key = argv[++i];
groove_file_metadata_set(file, key, NULL, 0);
} else {
groove_file_close(file);
return usage(exe);
}
}
struct GrooveAudioFormat audio_format;
groove_file_audio_format(file, &audio_format);
printf("channels=%d\n", groove_channel_layout_count(audio_format.channel_layout));
tag = NULL;
printf("duration=%f\n", groove_file_duration(file));
while ((tag = groove_file_metadata_get(file, "", tag, 0)))
printf("%s=%s\n", groove_tag_key(tag), groove_tag_value(tag));
if (file->dirty && groove_file_save(file) < 0)
fprintf(stderr, "error saving file\n");
groove_file_close(file);
return 0;
}
|