add publication_date and output to hmml metadata
This commit is contained in:
parent
9b26d109be
commit
21814d1e48
|
@ -30,6 +30,9 @@ typedef struct {
|
||||||
|
|
||||||
char* custom[HMML_CUSTOM_ATTR_COUNT];
|
char* custom[HMML_CUSTOM_ATTR_COUNT];
|
||||||
|
|
||||||
|
long publication_date;
|
||||||
|
char* output;
|
||||||
|
|
||||||
} HMML_VideoMetaData;
|
} HMML_VideoMetaData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -71,7 +74,7 @@ typedef struct {
|
||||||
char* time;
|
char* time;
|
||||||
char* text;
|
char* text;
|
||||||
char* author;
|
char* author;
|
||||||
|
|
||||||
HMML_Reference* references;
|
HMML_Reference* references;
|
||||||
size_t reference_count;
|
size_t reference_count;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "stb_sb.h"
|
#include "stb_sb.h"
|
||||||
#include "hmmlib.h"
|
#include "hmmlib.h"
|
||||||
|
|
||||||
const struct HMML_Version hmml_version = { 0, 3, 0 };
|
const struct HMML_Version hmml_version = { 0, 4, 0 };
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int line;
|
int line;
|
||||||
|
@ -58,10 +58,10 @@
|
||||||
yyextra->first = false;\
|
yyextra->first = false;\
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define UNQUOTE(_attr) ({ \
|
#define UNQUOTE_LEN(_attr, _len) ({ \
|
||||||
typeof(_attr) attr = (_attr); \
|
typeof(_attr) attr = (_attr); \
|
||||||
size_t len = strlen(attr); \
|
typeof(_len) len = (_len); \
|
||||||
for(char* c = attr; *c; ++c){\
|
for(char* c = attr; c < attr+len; ++c){\
|
||||||
if(*c == '\\'){ \
|
if(*c == '\\'){ \
|
||||||
CHECKESCAPE(c[1]); \
|
CHECKESCAPE(c[1]); \
|
||||||
memmove(c, c+1, len-(c-attr)); \
|
memmove(c, c+1, len-(c-attr)); \
|
||||||
|
@ -71,6 +71,8 @@
|
||||||
attr; \
|
attr; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
#define UNQUOTE(_attr) UNQUOTE_LEN(_attr, strlen(attr))
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%option reentrant
|
%option reentrant
|
||||||
|
@ -91,6 +93,7 @@ RB \]
|
||||||
%s VIDEO
|
%s VIDEO
|
||||||
%s V_ATTR
|
%s V_ATTR
|
||||||
%s V2_ATTR
|
%s V2_ATTR
|
||||||
|
%s V3_ATTR
|
||||||
%s ANNOTATION
|
%s ANNOTATION
|
||||||
%s TEXT_START
|
%s TEXT_START
|
||||||
%s TEXT
|
%s TEXT
|
||||||
|
@ -140,6 +143,8 @@ RB \]
|
||||||
<VIDEO>co\-host{S}= { yyextra->attr = V_(co_hosts); BEGIN(V2_ATTR); }
|
<VIDEO>co\-host{S}= { yyextra->attr = V_(co_hosts); BEGIN(V2_ATTR); }
|
||||||
<VIDEO>guest{S}= { yyextra->attr = V_(guests); BEGIN(V2_ATTR); }
|
<VIDEO>guest{S}= { yyextra->attr = V_(guests); BEGIN(V2_ATTR); }
|
||||||
<VIDEO>annotator{S}= { yyextra->attr = V_(annotators); 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>\] { BEGIN(ANNOTATION); };
|
||||||
<VIDEO>. { HMML_ERR("Unknown attribute in video tag, beginning with '%s'.", yytext); }
|
<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>{ATTR_QUOTED} { sb_push(*(char***)yyextra->attr, UNQUOTE(strndup(yytext+1, yyleng-2))); BEGIN(VIDEO); }
|
||||||
<V2_ATTR>\] { yyless(0); 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}{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>{TIMECODE} { NEWANNO(); yyextra->an.time = strndup(yytext+1, yyleng-2); BEGIN(TEXT_START); }
|
||||||
<ANNOTATION>{BAD_TIMECODE} { HMML_ERR("Timecode %s out of range.", yytext); }
|
<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.id);
|
||||||
free(hmml->metadata.template);
|
free(hmml->metadata.template);
|
||||||
free(hmml->metadata.medium);
|
free(hmml->metadata.medium);
|
||||||
|
free(hmml->metadata.output);
|
||||||
|
|
||||||
for(size_t i = 0; i < HMML_CUSTOM_ATTR_COUNT; ++i){
|
for(size_t i = 0; i < HMML_CUSTOM_ATTR_COUNT; ++i){
|
||||||
free(hmml->metadata.custom[i]);
|
free(hmml->metadata.custom[i]);
|
||||||
|
@ -383,7 +394,6 @@ void hmml_dump(HMML_Output* hmml){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
puts("Annotations:");
|
puts("Annotations:");
|
||||||
for(size_t i = 0; i < hmml->annotation_count; ++i){
|
for(size_t i = 0; i < hmml->annotation_count; ++i){
|
||||||
HMML_Annotation* a = hmml->annotations + i;
|
HMML_Annotation* a = hmml->annotations + i;
|
||||||
|
|
Loading…
Reference in New Issue