Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
--   http://anggtwu.net/LUA/Subtitles2.lua.html
--   http://anggtwu.net/LUA/Subtitles2.lua
--          (find-angg "LUA/Subtitles2.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun s1 () (interactive) (find-angg "LUA/Subtitles.lua"))
-- (defun s2 () (interactive) (find-angg "LUA/Subtitles2.lua"))

-- Complements: (find-angg "LUA/Subtitles.lua" "Subtitles")
-- Used by:  (find-THgrep "grep --color=auto -nH --null -e Subtitles2 *.blogme")
--           (find-TH "2021-1-C2-somas-1-dicas")
-- Based on: (find-TH "2021aulas-por-telegram" "legendas" "ipairs")



Subtitle = Class {
  type = "Subtitle",
  hash = "1234567890a",
  from = function (line)
      local time,text = line:match('^.-"(.-)".-"(.*)"%)$')
      if text then text = text:gsub("\\(.)", "%1") end
      return Subtitle {line=line, time=time, text=text}
    end,
  --
  blogmelines = function (bigstr, method, i, j)
      local lines = splitlines(bigstr)
      local outs  = VTable {}
      local method = method or "blogmeorline"
      local f = function (k) return Subtitle.from(lines[k]):m(method) end
      for k=(1 or 1),(j or #lines) do
        table.insert(outs, Subtitle.from(lines[k]):m(method or "blogmeorline"))
      end
      return outs
    end,
  --
  __tostring = function (st) return st:tostring() end,
  __index = {
    tostring     = function (st) return st.time and st.time.."  "..st.text or st.line end,
    url          = function (st) return youtube_make_url(Subtitle.hash, st.time) end,
    blogmetime   = function (st) return R(st:url(), st.time) end,
    blogmeatime  = function (st) return NAME(st.time, st:blogmetime()) end,
    blogme       = function (st) return st:blogmeatime().." "..st.text end,
    blogmeorline = function (st) return st.time and st:blogme() or st.line end,
  },
}

SubtitleLines = Class {
  type = "SubtitleLines",
  from = function (bigstr)
      lines = VTable(splitlines(bigstr))
      return SubtitleLines {bigstr=bigstr, lines=lines}
    end,
  __index = {
    m = function (sls, k, method)
        method = method or "blogmeorline"
        local st = Subtitle.from(sls.lines[k])
        return st[method](st)
      end,
    ms = function (sls, method, sep, i, j)
        local range = seq(i or 1, j or #sls.lines)
        local f = function (k) return sls:m(k, method) end
        local outs = VTable(map(f, range))
        if sep then return table.concat(outs, sep) end
        return outs
      end,
    blogme   = function (sls,i,j) return sls:ms(nil, BR(), i,j) end,
    tostring = function (sls,i,j) return sls:ms("tostring", "\n", i,j) end,
  },
}




--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "Subtitles2.lua"
-- (find-fline "~/SUBTITLES/2021-1-C2-somas-1-dicas.lua")
ee_dofile      "~/SUBTITLES/2021-1-C2-somas-1-dicas.lua"

lines = splitlines(subs_bigstr)
st = Subtitle.from(lines[4])
= st

loadblogme3()
sls = SubtitleLines.from(subs_bigstr)
= sls.lines
= sls:tostring(1, 10)
= sls:blogme  (1, 10)

= sls:ms("tostring", "\n")
= sls:ms("tostring", "\n", 1, 10)
= sls:ms("tostring")
= sls:ms("tostring", nil, 1, 10)
= sls:ms(nil, nil, 1, 10)
= sls:ms(nil, BR(), 1, 10)
Subtitle.hash = "000000000"
= sls:ms(nil, BR(), 1, 10)

--]]





-- Local Variables:
-- coding:  utf-8-unix
-- End: