Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file: -- http://anggtwu.net/LUA/EmacsConf2023.lua.html -- http://anggtwu.net/LUA/EmacsConf2023.lua -- (find-angg "LUA/EmacsConf2023.lua") -- Author: Eduardo Ochs <eduardoochs@gmail.com> -- -- (defun e () (interactive) (find-angg "LUA/EmacsConf2023.lua")) -- (find-fline "~/LOGS/2023dec09.emacs") -- (find-fline "~/LOGS/2023dec09.emacs" ".m3u") -- (find-fline "~/LOGS/2023dec09.emacs" "json") -- https://media.emacsconf.org/2023/index.m3u -- https://media.emacsconf.org/2023/talks.json -- https://media.emacsconf.org/2023/ -- https://media.emacsconf.org/2023/emacsconf-2023-emms--emacs-multimedia-system-emms--yoni-rabkin--main.webm -- "emms" -> "emacs-multimedia-system-emms--yoni-rabkin" -- (find-fline "$S/https/media.emacsconf.org/2023/index.m3u") -- «.EmacsConf2023» (to "EmacsConf2023") -- «.EmacsConf2023-tests» (to "EmacsConf2023-tests") require "GetOpt1" -- (find-angg "LUA/GetOpt1.lua") -- _____ ____ __ ____ ___ ____ _____ -- | ____|_ __ ___ __ _ ___ ___ / ___|___ _ __ / _|___ \ / _ \___ \|___ / -- | _| | '_ ` _ \ / _` |/ __/ __| | / _ \| '_ \| |_ __) | | | |__) | |_ \ -- | |___| | | | | | (_| | (__\__ \ |__| (_) | | | | _|/ __/| |_| / __/ ___) | -- |_____|_| |_| |_|\__,_|\___|___/\____\___/|_| |_|_| |_____|\___/_____|____/ -- -- «EmacsConf2023» (to ".EmacsConf2023") EmacsConf2023 = Class { type = "EmacsConf2023", __index = { m3u = ee_readfile "$S/https/media.emacsconf.org/2023/index.m3u", pat0 = "#EXTINF:%-1,([^\n]*)\n([^\n]*)", pat1 = "emacsconf%-2023%-(.-)%-%-(.-)%-%-main.webm", gmatch0 = function (ec) return ec.m3u:gmatch(ec.pat0) end, parse1 = function (ec,b) return b:match(ec.pat1) end, parse2 = function (ec) local A = VTable {} for a,b in ec:gmatch0() do local short,long = ec:parse1(b) local B = VTable {a=a, b=b, short=short, long=long} table.insert(A, B) end return A end, parse3 = function (ec) ec.A = ec:parse2() ec.byshort = VTable {} for i,B in ipairs(ec.A) do if B.short then ec.byshort[B.short] = B end end return ec end, subst = function (ec,short,str) local f = function (s) local B = ec.byshort[short] if B[s] then return B[s] end local mname = "_"..s return ec[mname](ec, B) end return (str:gsub("<(.-)>", f)) end, _mainvtt = function (ec,B) return "BLA" end, _mainvtt = function (ec,B) return (B.b:gsub("webm$", "vtt")) end, }, } ec = EmacsConf2023({}):parse3() mygetopt = GetOpt { ["-short"] = function (g,short) g.short = short; g:rest(2) end, ["-subst"] = function (g,str) print(ec:subst(g.short, str)) end, } -- «EmacsConf2023-tests» (to ".EmacsConf2023-tests") --[[ * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) dofile "EmacsConf2023.lua" -- ec = EmacsConf2023 {} -- = ec:parse3().byshort = ec.A = ec.A[36] = ec.A[37] = ec.byshort = VTable(sortedkeys(ec.byshort)) = ec:subst("repl", "foo") = ec:subst("repl", "long") = ec:subst("repl", "<long>") = ec:subst("repl", "<b>") = ec:subst("repl", "<mainvtt>") mygetopt:run("-short", "repl", "-subst", "<mainvtt>") = EmacsConf2023_m3u -- for a,b in EmacsConf2023_m3u:gmatch("#EXTINF:%-1,([^\n]*)\n([^\n]*)") do print(a); print(b) end ec = EmacsConf2023 {} for a,b in ec:gmatch0() do print(a); print(b) end for a,b in ec:gmatch0() do local c,d = b:match(ec.pat1); print(c); print(d) end A = ec:parse2() = A for i,B in ipairs(A) do print(B.short) end --]] -- Local Variables: -- coding: utf-8-unix -- End: