spec updates: project episode num & different metadata

This commit is contained in:
Alex Baines 2017-06-19 17:04:48 +01:00
parent 4e5102ac59
commit e8f9869461
2 changed files with 36 additions and 18 deletions

View File

@ -9,11 +9,14 @@
typedef struct {
char* member;
char* twitch;
char* stream_platform;
char* stream_username;
char* project;
char* title;
char* platform;
char* vod_platform;
char* id;
char* co_host;
char* guest;
char* annotator;
} HMML_VideoMetaData;
@ -42,6 +45,7 @@ typedef struct {
HMML_MarkerType type;
char* marker;
char* parameter;
char* episode;
int offset;
} HMML_Marker;

View File

@ -109,15 +109,18 @@ RB \]
<INITIAL>. { HMML_ERR("Missing video tag."); }
<VIDEO>{S}
<VIDEO>member{S}= { yyextra->attr = V_(member); BEGIN(V_ATTR); }
<VIDEO>twitch_username{S}= { yyextra->attr = V_(twitch); BEGIN(V_ATTR); }
<VIDEO>project{S}= { yyextra->attr = V_(project); BEGIN(V_ATTR); }
<VIDEO>title{S}= { yyextra->attr = V_(title); BEGIN(V_ATTR); }
<VIDEO>platform{S}= { yyextra->attr = V_(platform); BEGIN(V_ATTR); }
<VIDEO>id{S}= { yyextra->attr = V_(id); BEGIN(V_ATTR); }
<VIDEO>annotator{S}= { yyextra->attr = V_(annotator); BEGIN(V_ATTR); }
<VIDEO>member{S}= { yyextra->attr = V_(member); BEGIN(V_ATTR); }
<VIDEO>stream_platform{S}= { yyextra->attr = V_(stream_platform); BEGIN(V_ATTR); }
<VIDEO>stream_username{S}= { yyextra->attr = V_(stream_username); BEGIN(V_ATTR); }
<VIDEO>project{S}= { yyextra->attr = V_(project); BEGIN(V_ATTR); }
<VIDEO>title{S}= { yyextra->attr = V_(title); BEGIN(V_ATTR); }
<VIDEO>vod_platform{S}= { yyextra->attr = V_(vod_platform); BEGIN(V_ATTR); }
<VIDEO>id{S}= { yyextra->attr = V_(id); BEGIN(V_ATTR); }
<VIDEO>co_host{S}= { yyextra->attr = V_(co_host); BEGIN(V_ATTR); }
<VIDEO>guest{S}= { yyextra->attr = V_(guest); BEGIN(V_ATTR); }
<VIDEO>annotator{S}= { yyextra->attr = V_(annotator); BEGIN(V_ATTR); }
<VIDEO>\] { BEGIN(ANNOTATION); };
<VIDEO>. { HMML_ERR("Invalid char '%c' in video tag.", *yytext); }
<VIDEO>. { HMML_ERR("Invalid char '%s' in video tag.", yytext); }
<V_ATTR>{S} { BEGIN(VIDEO); }
<V_ATTR>{ATTR_SIMPLE} { *yyextra->attr = strndup(yytext , yyleng ); BEGIN(VIDEO); }
@ -134,7 +137,7 @@ RB \]
<TEXT_START>{LB}@ { M_(MEMBER , TEXT); BEGIN(MARKER); }
<TEXT_START>{LB}~ { M_(PROJECT , TEXT); BEGIN(MARKER); }
<TEXT_START>{LB} { yyless(0); BEGIN(TEXT); }
<TEXT_START>. { HMML_ERR("Unknown character '%c' after timecode.", *yytext); }
<TEXT_START>. { HMML_ERR("Unknown character '%s' after timecode.", yytext); }
<TEXT>{TEXT_BREAK}+ { memcpy(sb_add(yyextra->an.text, yyleng), yytext, yyleng); }
<TEXT>\\. { CHECKESCAPE(yytext[1]); memcpy(sb_add(yyextra->an.text, yyleng-1), yytext+1, yyleng-1); }
@ -154,10 +157,20 @@ RB \]
<MARKER>{ATTR_QUOTED} { M_ADD(yytext+1, yyleng-2); BEGIN(yyextra->mnext); };
<MARKER>. { HMML_ERR("Cannot parse Marker. Expected quoted or alphanumeric attribute."); }
<MARKER_XTRA>\\] { MX_ADD(']'); }
<MARKER_XTRA>\] { MX_ADD('\0'); BEGIN(TEXT); }
<MARKER_XTRA>[ ] { if(sb_last(yyextra->an.markers).parameter){ MX_ADD(' '); } }
<MARKER_XTRA>. { MX_ADD(*yytext); }
<MARKER_XTRA>\\] { MX_ADD(']'); }
<MARKER_XTRA>\\# { MX_ADD('#'); }
<MARKER_XTRA>\] { MX_ADD('\0'); BEGIN(TEXT); }
<MARKER_XTRA>[ ]\#[0-9]+ {
HMML_Marker* m = &sb_last(yyextra->an.markers);
if(m->type == HMML_PROJECT){
m->episode = strdup(yytext+2);
} else {
memcpy(sb_add(m->parameter, yyleng-1), yytext+1, yyleng-1);
memcpy(sb_add(yyextra->an.text, yyleng-1), yytext+1, yyleng-1);
}
}
<MARKER_XTRA>[ ] { if(sb_last(yyextra->an.markers).parameter){ MX_ADD(' '); } }
<MARKER_XTRA>. { MX_ADD(*yytext); }
<REF>{S}
<REF>site{S}= { yyextra->attr = R_(site); BEGIN(R_ATTR); }
@ -189,11 +202,11 @@ RB \]
<AUTHOR>{S}
<CATEGORIES>{S}
<CATEGORIES>:{ATTR_SIMPLE} { HMML_Marker m = { HMML_CATEGORY, strndup(yytext+1, yyleng-1), NULL, -1 }; sb_push(yyextra->an.markers, m); }
<CATEGORIES>:{ATTR_QUOTED} { HMML_Marker m = { HMML_CATEGORY, UNQUOTE(strndup(yytext+2, yyleng-3)), NULL, -1 }; sb_push(yyextra->an.markers, m); }
<CATEGORIES>:{ATTR_SIMPLE} { HMML_Marker m = { HMML_CATEGORY, strndup(yytext+1, yyleng-1), NULL, NULL, -1 }; sb_push(yyextra->an.markers, m); }
<CATEGORIES>:{ATTR_QUOTED} { HMML_Marker m = { HMML_CATEGORY, UNQUOTE(strndup(yytext+2, yyleng-3)), NULL, NULL, -1 }; sb_push(yyextra->an.markers, m); }
<CATEGORIES>\]{LB} { BEGIN(QUOTES); }
<CATEGORIES>\] { BEGIN(ANNOTATION); }
<CATEGORIES>. { HMML_ERR("Unexpected character in category tag: '%c'\n", *yytext); }
<CATEGORIES>. { HMML_ERR("Unexpected character in category tag: '%s'\n", yytext); }
<QUOTES>{S}
<QUOTES>[0-9]+{S}\] { yyextra->an.is_quote = true; yyextra->an.quote.id = atoi(yytext); BEGIN(ANNOTATION); }
@ -271,6 +284,7 @@ static void _hmml_free_anno(HMML_Annotation* a){
for(size_t j = 0; j < sb_count(a->markers); ++j){
free(a->markers[j].marker);
free(a->markers[j].episode);
sb_free(a->markers[j].parameter);
}
sb_free(a->markers);