Commit bd743749 authored by Alex Baines's avatar Alex Baines

hmmlib-js: multiple guests/annotators/co-hosts update

parent f23eceac
This diff is collapsed.
...@@ -3,19 +3,16 @@ function HMML_parse(contents) { ...@@ -3,19 +3,16 @@ function HMML_parse(contents) {
var state = { var state = {
line: 0, line: 0,
annos: [], annos: [],
meta: {}, meta: {
annotators: [],
guests: [],
co_hosts: []
},
an: { an: {
line: 0, line: 0,
time: "",
text: "", text: "",
author: "",
references: [], references: [],
markers: [], markers: [],
quote: {
id: 0,
author: ""
},
is_quote: false
}, },
ref: {}, ref: {},
first: true first: true
...@@ -27,13 +24,6 @@ function HMML_parse(contents) { ...@@ -27,13 +24,6 @@ function HMML_parse(contents) {
do { do {
r = l.next(); r = l.next();
} while (!r); } while (!r);
state.annos.forEach(function(a) {
if (!a.is_quote) {
delete a.quote;
}
if (a.author === "") delete a.author;
delete a.is_quote;
});
return { return {
metadata: state.meta, metadata: state.meta,
annotations: state.annos annotations: state.annos
......
...@@ -49,16 +49,9 @@ ...@@ -49,16 +49,9 @@
if(!yy.first) yy.annos.push(yy.an); if(!yy.first) yy.annos.push(yy.an);
yy.an = { yy.an = {
line: yy.line, line: yy.line,
time: "",
text: "", text: "",
author: "",
references: [], references: [],
markers: [], markers: [],
quote: {
id: 0,
author: ""
},
is_quote: false
}; };
yy.an.line = yy.line; yy.an.line = yy.line;
yy.first = false; yy.first = false;
...@@ -82,6 +75,7 @@ RB \] ...@@ -82,6 +75,7 @@ RB \]
%s VIDEO %s VIDEO
%s V_ATTR %s V_ATTR
%s V2_ATTR
%s ANNOTATION %s ANNOTATION
%s TEXT_START %s TEXT_START
%s TEXT %s TEXT
...@@ -110,9 +104,9 @@ RB \] ...@@ -110,9 +104,9 @@ RB \]
<VIDEO>title{S}\= { yy.attr = "title"; yy_.begin("V_ATTR"); } <VIDEO>title{S}\= { yy.attr = "title"; yy_.begin("V_ATTR"); }
<VIDEO>vod_platform{S}\= { yy.attr = "vod_platform"; yy_.begin("V_ATTR"); } <VIDEO>vod_platform{S}\= { yy.attr = "vod_platform"; yy_.begin("V_ATTR"); }
<VIDEO>id{S}\= { yy.attr = "id"; yy_.begin("V_ATTR"); } <VIDEO>id{S}\= { yy.attr = "id"; yy_.begin("V_ATTR"); }
<VIDEO>co_host{S}\= { yy.attr = "co_host" yy_.begin("V_ATTR"); } <VIDEO>co\-host{S}\= { yy.attr = "co_hosts" yy_.begin("V2_ATTR"); }
<VIDEO>guest{S}\= { yy.attr = "guest" yy_.begin("V_ATTR"); } <VIDEO>guest{S}\= { yy.attr = "guests" yy_.begin("V2_ATTR"); }
<VIDEO>annotator{S}\= { yy.attr = "annotator"; yy_.begin("V_ATTR"); } <VIDEO>annotator{S}\= { yy.attr = "annotators"; yy_.begin("V2_ATTR"); }
<VIDEO>\] { yy_.begin("ANNOTATION"); }; <VIDEO>\] { yy_.begin("ANNOTATION"); };
<VIDEO>. { ERR(yy, "Invalid char '"+ yytext +"' in video tag."); } <VIDEO>. { ERR(yy, "Invalid char '"+ yytext +"' in video tag."); }
...@@ -121,6 +115,11 @@ RB \] ...@@ -121,6 +115,11 @@ RB \]
<V_ATTR>{ATTR_QUOTED} { yy.meta[yy.attr] = UNQUOTE(yy, yytext.substr(1, yyleng-2)); yy_.begin("VIDEO"); } <V_ATTR>{ATTR_QUOTED} { yy.meta[yy.attr] = UNQUOTE(yy, yytext.substr(1, yyleng-2)); yy_.begin("VIDEO"); }
<V_ATTR>\] { yy_.less(0); yy_.begin("VIDEO"); } <V_ATTR>\] { yy_.less(0); yy_.begin("VIDEO"); }
<V2_ATTR>{SP} { yy_.begin("VIDEO"); }
<V2_ATTR>{ATTR_SIMPLE} { yy.meta[yy.attr].push(yytext); yy_.begin("VIDEO"); }
<V2_ATTR>{ATTR_QUOTED} { yy.meta[yy.attr].push(UNQUOTE(yy, yytext.substr(1, yyleng-2))); yy_.begin("VIDEO"); }
<V2_ATTR>\] { yy_.less(0); yy_.begin("VIDEO"); }
<ANNOTATION>\[\/video\] { NEWANNO(yy); return 1; } <ANNOTATION>\[\/video\] { NEWANNO(yy); return 1; }
<ANNOTATION>{TIMECODE}{LB}\@ { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-4); yy_.begin("AUTHOR"); } <ANNOTATION>{TIMECODE}{LB}\@ { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-4); yy_.begin("AUTHOR"); }
<ANNOTATION>{TIMECODE} { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-2); yy_.begin("TEXT_START"); } <ANNOTATION>{TIMECODE} { NEWANNO(yy); yy.an.time = yytext.substr(1, yyleng-2); yy_.begin("TEXT_START"); }
...@@ -203,7 +202,7 @@ RB \] ...@@ -203,7 +202,7 @@ RB \]
<CATEGORIES>. { ERR(yy, "Unexpected character in category tag: " + yytext); } <CATEGORIES>. { ERR(yy, "Unexpected character in category tag: " + yytext); }
<QUOTES>{SP} {} <QUOTES>{SP} {}
<QUOTES>[0-9]+{S}\] { yy.an.is_quote = true; yy.an.quote.id = parseInt(yytext); yy_.begin("ANNOTATION"); } <QUOTES>[0-9]+{S}\] { yy.an.quote = { author: "", id: parseInt(yytext) }; yy_.begin("ANNOTATION"); }
<QUOTES>{ATTR_ALNUM} { yy.an.quote.author += yytext; } <QUOTES>{ATTR_ALNUM} { yy.an.quote.author += yytext; }
<QUOTES>. { ERR(yy, "Unexpected character in quotes tag: " + yytext); } <QUOTES>. { ERR(yy, "Unexpected character in quotes tag: " + yytext); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment