aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emms-print-metadata.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/emms-print-metadata.c b/emms-print-metadata.c
index 3157f46..9bf6352 100644
--- a/emms-print-metadata.c
+++ b/emms-print-metadata.c
@@ -35,8 +35,24 @@ main (int argc, char **argv)
}
file = taglib_file_new (argv[1]);
+
+ if (!file)
+ {
+ fprintf (stderr, "%s: File does not exist or is of an unknown type\n", argv[1]);
+ exit (1);
+ }
+
tag = taglib_file_tag (file);
+ /* Apparently, if the file is named foo.mp3 or similar, the library
+ still can open it, for whatever reason.
+ */
+ if (!tag)
+ {
+ fprintf (stderr, "%s: File does not exist or is of an unknown type\n", argv[1]);
+ exit (1);
+ }
+
printf ("info-artist=%s\n", taglib_tag_artist (tag));
printf ("info-title=%s\n", taglib_tag_title (tag));
printf ("info-album=%s\n", taglib_tag_album (tag));