/** * Attempts to load APE or ID3 tags from the specified file. */ static struct tag * tag_load_fallback(const char *path) { struct tag *tag = tag_ape_load(path); if (tag == NULL) tag = tag_id3_load(path); return tag; }
int main(int argc, char **argv) { const char *decoder_name, *path; const struct decoder_plugin *plugin; struct tag *tag; bool empty; if (argc != 3) { g_printerr("Usage: read_tags DECODER FILE\n"); return 1; } decoder_name = argv[1]; path = argv[2]; input_stream_global_init(); decoder_plugin_init_all(); plugin = decoder_plugin_from_name(decoder_name); if (plugin == NULL) { g_printerr("No such decoder: %s\n", decoder_name); return 1; } tag = decoder_plugin_tag_dup(plugin, path); decoder_plugin_deinit_all(); input_stream_global_finish(); if (tag == NULL) { g_printerr("Failed to read tags\n"); return 1; } print_tag(tag); empty = tag_is_empty(tag); tag_free(tag); if (empty) { tag = tag_ape_load(path); if (tag == NULL) tag = tag_id3_load(path); if (tag != NULL) { print_tag(tag); tag_free(tag); } } return 0; }
int main(int argc, char **argv) { GError *error = NULL; const char *decoder_name, *path; const struct decoder_plugin *plugin; struct tag *tag; bool empty; #ifdef HAVE_LOCALE_H /* initialize locale */ setlocale(LC_CTYPE,""); #endif if (argc != 3) { g_printerr("Usage: read_tags DECODER FILE\n"); return 1; } decoder_name = argv[1]; path = argv[2]; tag_pool_init(); if (!input_stream_global_init(&error)) { g_warning("%s", error->message); g_error_free(error); return 2; } decoder_plugin_init_all(); plugin = decoder_plugin_from_name(decoder_name); if (plugin == NULL) { g_printerr("No such decoder: %s\n", decoder_name); return 1; } tag = decoder_plugin_tag_dup(plugin, path); if (tag == NULL && plugin->stream_tag != NULL) { struct input_stream *is = input_stream_open(path, &error); if (is == NULL) { g_printerr("Failed to open %s: %s\n", path, error->message); g_error_free(error); return 1; } tag = decoder_plugin_stream_tag(plugin, is); input_stream_close(is); } decoder_plugin_deinit_all(); input_stream_global_finish(); if (tag == NULL) { g_printerr("Failed to read tags\n"); return 1; } print_tag(tag); empty = tag_is_empty(tag); tag_free(tag); if (empty) { tag = tag_ape_load(path); if (tag == NULL) tag = tag_id3_load(path); if (tag != NULL) { print_tag(tag); tag_free(tag); } } tag_pool_deinit(); return 0; }