diff --git a/inc/lektor/macro.h b/inc/lektor/macro.h
index 712ae9f9a6799646dd2bace4b3d459746631f940..468f1de0b1f425a80c35adaa113893a1092aa75e 100644
--- a/inc/lektor/macro.h
+++ b/inc/lektor/macro.h
@@ -55,6 +55,12 @@
         fprintf(stderr, " ! %s: %s\n", __func__, msg);                  \
         return ret;                                                     \
     }
+#define GOTO_IF(cond, msg, label)                                       \
+    if (cond) {                                                         \
+        fprintf(stderr, " ! %s: %s\n", __func__, msg);                  \
+        goto label;                                                     \
+    }
 
+#define GOTO_UNLESS(cond, msg, label)   GOTO_IF(!(cond), msg, ret)
 #define RETURN_UNLESS(cond, msg, ret)   RETURN_IF(!(cond), msg, ret)
 #define NOTHING                         /* Usefull to return nothing. */
diff --git a/src/mkv/write.c b/src/mkv/write.c
index b3bad2e94a12289c2fc782c111115beb27f97582..b712d838e1d036e1df3af820580d9dfffcf84302 100644
--- a/src/mkv/write.c
+++ b/src/mkv/write.c
@@ -152,16 +152,20 @@ metadata_from_path(char *const mkvfile, struct kara_metadata *meta)
         "(jp|fr|en|ru|sp|it|ch|latin|multi|undefined)/(.+)/"
         "(.+) - (OP|ED|IS|AMV|VOCA|PV|MV|LIVE)([[:digit:]]*) - (.+)\\.mkv$";
 
-    RETURN_IF(regcomp(&regex, rgx, REG_EXTENDED), "Failed to compile regex", false);
-
+    GOTO_IF(regcomp(&regex, rgx, REG_EXTENDED), "Failed to compile regex", error);
     memset(meta, 0, sizeof(struct kara_metadata));
     memset(msgbuf, 0, LEKTOR_TAG_MAX * sizeof(char));
 
     reti = regexec(&regex, mkvfile, nmatch, pmatch, 0);
-
     if (!reti) {
         /* Match */
-        exit(100);
+        memcpy(meta->category, mkvfile + pmatch[2].rm_so, pmatch[2].rm_eo - pmatch[2].rm_so);
+        memcpy(meta->language, mkvfile + pmatch[3].rm_so, pmatch[3].rm_eo - pmatch[3].rm_so);
+        memcpy(meta->author_name, mkvfile + pmatch[4].rm_so, pmatch[4].rm_eo - pmatch[4].rm_so);
+        memcpy(meta->source_name, mkvfile + pmatch[5].rm_so, pmatch[5].rm_eo - pmatch[5].rm_so);
+        memcpy(meta->song_type, mkvfile + pmatch[6].rm_so, pmatch[6].rm_eo - pmatch[6].rm_so);
+        memcpy(msgbuf, mkvfile + pmatch[7].rm_so, pmatch[7].rm_eo - pmatch[7].rm_so);
+        memcpy(meta->song_name, mkvfile + pmatch[8].rm_so, pmatch[8].rm_eo - pmatch[8].rm_so);
     } else if (REG_NOMATCH == reti) {
         fprintf(stderr, "No match for: %s\n", mkvfile);
         goto error;
@@ -171,6 +175,12 @@ metadata_from_path(char *const mkvfile, struct kara_metadata *meta)
         goto error;
     }
 
+    if (msgbuf[0] != '\0') {
+        meta->song_number = atoi(msgbuf);   /* TODO: Use strtol */
+        meta->song_number = MAX(1, meta->song_number);
+    } else
+        meta->song_number = 1;
+
     sta = true;
 error:
     regfree(&regex);