Compare commits

...
9 Commits
Author SHA1 Message Date
tangent 1568dbca9d Update ReadMe.md 2026-09-14 02:47:47 -06:00
tangent f4c9a65427 remove unnecessary partial scripts 2026-08-30 18:35:36 -06:00
tangent 5463bdddc9 better output 2026-08-28 03:12:27 -06:00
tangent 1bcc6cf6c4 Update ReadMe.md 2026-08-28 02:35:55 -06:00
tangent 13efc2c85c usage 2026-08-26 20:17:17 -06:00
tangent e144bc65ca note to future self about pandoc ignoring a case 2026-08-26 20:16:25 -06:00
tangent b67318b169 cleaner frontmatter writing 2026-08-26 20:12:49 -06:00
tangent ecc77d4269 split codeblocks have to be used 2026-08-26 20:10:50 -06:00
tangent 6066e69b45 only open the file WHEN you need to 2026-08-26 19:50:49 -06:00
4 changed files with 48 additions and 51 deletions

No files matched your search

+13
View File
@@ -1,3 +1,10 @@
# yt-transcript-tools
Getting transcripts into epub format.
Download a transcript, place it in this directory, run
`./convert_transcript.lua FILE`, fill in author and link as
requested, and you will have a usable epub.
This is heavily WIP. This is heavily WIP.
I used the apply_margin script on a transcript downloaded from I used the apply_margin script on a transcript downloaded from
@@ -14,3 +21,9 @@ the export will be different enough to fuck up the margin fix.
I am really frustrated because pandoc doesn't support plain text. I am really frustrated because pandoc doesn't support plain text.
I went through many tests and iterations before coming to even I went through many tests and iterations before coming to even
this minimal start and it was extremely frustrating. this minimal start and it was extremely frustrating.
## Tasks
- [x] I need an option / 2nd script to output a version with no
timecode formatting for easier text extraction.
- I made it actually just combine both in the same document,
easier to manage that way.
-16
View File
@@ -1,16 +0,0 @@
#!/usr/bin/env luajit
local a, b = arg[1], arg[2]
local file = io.open(b, "w")
assert(file, "Couldn't open \"" .. b .. "\"")
for line in io.lines(a) do
if not (line:sub(3, 3) == ":") then
file:write(string.rep(" ", 6))
end
file:write(line)
file:write("\n")
end
file:close()
+35 -21
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env luajit #!/usr/bin/env luajit
local version = "0.1" local version = "0.4.0"
local input_file_name = arg[1] local input_file_name = arg[1]
assert(input_file_name, assert(input_file_name,
@@ -13,9 +13,6 @@ local link = io.read("*line")
local title = input_file_name:sub(1, -5) -- assumes .txt extension local title = input_file_name:sub(1, -5) -- assumes .txt extension
local output_file_name = title .. ".md" local output_file_name = title .. ".md"
local output_file = io.open(output_file_name, "w")
assert(output_file, "Could not open \"" .. output_file_name .. "\"")
local frontmatter = { local frontmatter = {
"---", "---",
"title: \"" .. title .. "\"", "title: \"" .. title .. "\"",
@@ -29,26 +26,43 @@ if link and #link > 0 then
frontmatter[#frontmatter + 1] = "From [" .. link .. "](" .. link .. ")\n" frontmatter[#frontmatter + 1] = "From [" .. link .. "](" .. link .. ")\n"
end end
for _, line in ipairs(frontmatter) do local input_lines = {}
output_file:write(line)
output_file:write("\n")
end
for line in io.lines(input_file_name) do for line in io.lines(input_file_name) do
output_file:write("`") -- make this line a code block on its own input_lines[#input_lines + 1] = line
-- if not appearing to start with a timecode,
-- indent by the width of a timecode
if not (line:sub(3, 3) == ":") then
output_file:write(string.rep(" ", 6))
end
output_file:write(line)
output_file:write("`") -- close the code block
output_file:write("\n")
end end
local output_lines = {}
local timecode_free_lines = {}
for index, line in ipairs(input_lines) do
if not (line:sub(3, 3) == ":") then
local previous_line = input_lines[index - 1]
if previous_line and previous_line:sub(3, 3) == ":" then
output_lines[#output_lines] = "```\n" .. previous_line
output_lines[#output_lines + 1] = string.rep(" ", 6) .. line .. "\n```"
else
output_lines[#output_lines + 1] = "`" .. string.rep(" ", 6) .. line .. "`" -- pandoc will ignore this margin
end
timecode_free_lines[#timecode_free_lines + 1] = line
else
output_lines[#output_lines + 1] = "`" .. line .. "`"
timecode_free_lines[#timecode_free_lines + 1] = line:sub(7)
end
end
local output_file = io.open(output_file_name, "w")
assert(output_file, "Could not open \"" .. output_file_name .. "\"")
output_file:write(table.concat(frontmatter, "\n"))
output_file:write("\n")
output_file:write("# Raw Transcript\n\n")
output_file:write(table.concat(timecode_free_lines, "\n"))
output_file:write("\n\n")
output_file:write("# Timecoded Transcript\n\n")
output_file:write(table.concat(output_lines, "\n"))
output_file:write("\n")
output_file:close() output_file:close()
os.execute("pandoc --from markdown+hard_line_breaks \"" os.execute("pandoc --from markdown+hard_line_breaks \""
.. output_file_name .. "\" -o \"" .. title .. ".epub\"") .. output_file_name .. "\" --toc=true -o \"" .. title .. ".epub\"")
-14
View File
@@ -1,14 +0,0 @@
#!/usr/bin/env luajit
local a, b = arg[1], arg[2]
local file = io.open(b, "w")
assert(file, "Couldn't open \"" .. b .. "\"")
for line in io.lines(a) do
file:write("`")
file:write(line)
file:write("`")
file:write("\n")
end
file:close()