add publication_date and output to hmml metadata

This commit is contained in:
Alex Baines 2019-02-05 20:45:59 +00:00
parent 9b26d109be
commit 21814d1e48
2 changed files with 19 additions and 6 deletions

View File

@ -30,6 +30,9 @@ typedef struct {
char* custom[HMML_CUSTOM_ATTR_COUNT];
long publication_date;
char* output;
} HMML_VideoMetaData;
typedef struct {
@ -71,7 +74,7 @@ typedef struct {
char* time;
char* text;
char* author;
HMML_Reference* references;
size_t reference_count;

View File

@ -5,7 +5,7 @@
#include "stb_sb.h"
#include "hmmlib.h"
const struct HMML_Version hmml_version = { 0, 3, 0 };
const struct HMML_Version hmml_version = { 0, 4, 0 };
typedef struct {
int line;
@ -58,10 +58,10 @@
yyextra->first = false;\
} while(0)
#define UNQUOTE(_attr) ({ \
#define UNQUOTE_LEN(_attr, _len) ({ \
typeof(_attr) attr = (_attr); \
size_t len = strlen(attr); \
for(char* c = attr; *c; ++c){\
typeof(_len) len = (_len); \
for(char* c = attr; c < attr+len; ++c){\
if(*c == '\\'){ \
CHECKESCAPE(c[1]); \
memmove(c, c+1, len-(c-attr)); \
@ -71,6 +71,8 @@
attr; \
})
#define UNQUOTE(_attr) UNQUOTE_LEN(_attr, strlen(attr))
%}
%option reentrant
@ -91,6 +93,7 @@ RB \]
%s VIDEO
%s V_ATTR
%s V2_ATTR
%s V3_ATTR
%s ANNOTATION
%s TEXT_START
%s TEXT
@ -140,6 +143,8 @@ RB \]
<VIDEO>co\-host{S}= { yyextra->attr = V_(co_hosts); BEGIN(V2_ATTR); }
<VIDEO>guest{S}= { yyextra->attr = V_(guests); BEGIN(V2_ATTR); }
<VIDEO>annotator{S}= { yyextra->attr = V_(annotators); BEGIN(V2_ATTR); }
<VIDEO>publication_date{S}= { yyextra->attr = V_(publication_date); BEGIN(V3_ATTR); }
<VIDEO>output{S}= { yyextra->attr = V_(output); BEGIN(V_ATTR); }
<VIDEO>\] { BEGIN(ANNOTATION); };
<VIDEO>. { HMML_ERR("Unknown attribute in video tag, beginning with '%s'.", yytext); }
@ -153,6 +158,11 @@ RB \]
<V2_ATTR>{ATTR_QUOTED} { sb_push(*(char***)yyextra->attr, UNQUOTE(strndup(yytext+1, yyleng-2))); BEGIN(VIDEO); }
<V2_ATTR>\] { yyless(0); BEGIN(VIDEO); }
<V3_ATTR>{S} { BEGIN(VIDEO); }
<V3_ATTR>{ATTR_SIMPLE} { *(long*)yyextra->attr = atol(yytext); BEGIN(VIDEO); }
<V3_ATTR>{ATTR_QUOTED} { *(long*)yyextra->attr = atol(UNQUOTE_LEN(yytext+1, yyleng-2)); BEGIN(VIDEO); }
<V3_ATTR>\] { yyless(0); BEGIN(VIDEO); }
<ANNOTATION>{TIMECODE}{LB}@ { NEWANNO(); yyextra->an.time = strndup(yytext+1, yyleng-4); BEGIN(AUTHOR); }
<ANNOTATION>{TIMECODE} { NEWANNO(); yyextra->an.time = strndup(yytext+1, yyleng-2); BEGIN(TEXT_START); }
<ANNOTATION>{BAD_TIMECODE} { HMML_ERR("Timecode %s out of range.", yytext); }
@ -340,6 +350,7 @@ void hmml_free(HMML_Output* hmml){
free(hmml->metadata.id);
free(hmml->metadata.template);
free(hmml->metadata.medium);
free(hmml->metadata.output);
for(size_t i = 0; i < HMML_CUSTOM_ATTR_COUNT; ++i){
free(hmml->metadata.custom[i]);
@ -383,7 +394,6 @@ void hmml_dump(HMML_Output* hmml){
return;
}
puts("Annotations:");
for(size_t i = 0; i < hmml->annotation_count; ++i){
HMML_Annotation* a = hmml->annotations + i;