Skip to content

Instantly share code, notes, and snippets.

@schiffty
Created October 19, 2022 06:54
Show Gist options
  • Save schiffty/4e9c9b09ad676f727062d9723717211a to your computer and use it in GitHub Desktop.
Save schiffty/4e9c9b09ad676f727062d9723717211a to your computer and use it in GitHub Desktop.
EDL parsing function for separating events, and then locators, ending up in a new array that has only events with locators
parseEDL: function() {
this.resetPanel();
//Output array: 1-In TC 2-Out TC 3-Color 4-Text
var matches,locators, i=0;
var eventregex = /(\d{3}[^\n]*([0-9:]{11})\s([0-9:]{11})\s?\n[\s\S]*?(?=^\d{3}|^>|^$))/gim;
var locatorsregex = /\* ?LOC.*[\d:]{10,11}\s+([\w]+) +([^\r\n]*?)\r?\n/gi;
var input_content = this.input.contents + "\n";
while ((matches = eventregex.exec(input_content)) !== null) {
var locatorarray = new Array();
while ((locators = locatorsregex.exec(matches[1])) !== null) {
locatorarray.push([locators[1], locators[2]]);
}
if (locatorarray.length == 0) continue;
this.events[i] = [matches[2], matches[3], locatorarray] ;
i++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment