Last active
December 7, 2024 08:56
-
-
Save iluvcapra/246e0f25627d84adcca1ab3f2782bd50 to your computer and use it in GitHub Desktop.
A REAPER script for post-production
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
I, Jamie Hardt, the author, hereby release this work to the public domain. | |
This script accepts an EDL from the file selection dialogue and then creates a marker region | |
for each target clip, named after the clip name in the source. | |
]] | |
currentEvent = {} | |
function parseEdlHeader() | |
fh:read("l") -- title line | |
fh:read("l") -- fcm line | |
lineNumber = lineNumber + 2 | |
end | |
function createRegionForCurrentEvent() | |
if #currentEvent == 9 then | |
local clipName = currentEvent[9]:match("%* FROM CLIP NAME:%s*(%S+)") or ("Event:" .. currentEvent[1]) | |
local startTime = reaper.parse_timestr_pos(currentEvent[7],5) | |
local endTime = reaper.parse_timestr_pos(currentEvent[8],5) | |
local requestIndex = 1000 + tonumber(currentEvent[1]) | |
reaper.AddProjectMarker(0, true, startTime, endTime, clipName, requestIndex) | |
end | |
end | |
function parseComment(line) | |
currentEvent[9] = currentEvent[9] .. "\n" .. line | |
end | |
function parseEvent(line) | |
createRegionForCurrentEvent() | |
local matchPattern = "(%d%d%d) (........) (.....) (........) (%d%d:%d%d:%d%d:%d%d) (%d%d:%d%d:%d%d:%d%d) (%d%d:%d%d:%d%d:%d%d) (%d%d:%d%d:%d%d:%d%d)" | |
currentEvent = {line:match(matchPattern)} | |
currentEvent[9] = "" | |
end | |
function parseUnrecognized(line) | |
-- reaper.ShowConsoleMsg("Parsed Unrecognized Line " .. lineNumber .. "\n" ) | |
end | |
function completeParsing() | |
reaper.ShowMessageBox("Finished importing EDL, " .. lineNumber .. " total lines.","Finished Importing EDL",0) | |
end | |
function parseEdlEvents(onEvent) | |
while true do | |
local line = fh:read("l") | |
lineNumber = lineNumber + 1 | |
if line == nil then break end | |
if line:sub(1,1) == "*" then | |
parseComment(line) | |
else | |
if line:len() == 78 and line:sub(1,4):match("%d%d%d ") then | |
parseEvent(line) | |
else | |
parseUnrecognized(line) | |
end | |
end | |
end | |
completeParsing() | |
end | |
function parseEdl() | |
parseEdlHeader() | |
parseEdlEvents() | |
end | |
ok, path = reaper.GetUserFileNameForRead("","Select EDL File to Import...","edl") | |
if ok then | |
lineNumber = 1 | |
fh = io.open(path, "r") | |
parseEdl() | |
fh:close() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment