Compare commits
6
Commits
b67318b169
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1568dbca9d | ||
|
|
f4c9a65427 | ||
|
|
5463bdddc9 | ||
|
|
1bcc6cf6c4 | ||
|
|
13efc2c85c | ||
|
|
e144bc65ca |
No files matched your search
@@ -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.
|
||||||
@@ -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()
|
|
||||||
+11
-3
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env luajit
|
#!/usr/bin/env luajit
|
||||||
local version = "0.2.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,
|
||||||
@@ -32,6 +32,7 @@ for line in io.lines(input_file_name) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
local output_lines = {}
|
local output_lines = {}
|
||||||
|
local timecode_free_lines = {}
|
||||||
for index, line in ipairs(input_lines) do
|
for index, line in ipairs(input_lines) do
|
||||||
if not (line:sub(3, 3) == ":") then
|
if not (line:sub(3, 3) == ":") then
|
||||||
local previous_line = input_lines[index - 1]
|
local previous_line = input_lines[index - 1]
|
||||||
@@ -39,10 +40,12 @@ for index, line in ipairs(input_lines) do
|
|||||||
output_lines[#output_lines] = "```\n" .. previous_line
|
output_lines[#output_lines] = "```\n" .. previous_line
|
||||||
output_lines[#output_lines + 1] = string.rep(" ", 6) .. line .. "\n```"
|
output_lines[#output_lines + 1] = string.rep(" ", 6) .. line .. "\n```"
|
||||||
else
|
else
|
||||||
output_lines[#output_lines + 1] = "`" .. line .. "`"
|
output_lines[#output_lines + 1] = "`" .. string.rep(" ", 6) .. line .. "`" -- pandoc will ignore this margin
|
||||||
end
|
end
|
||||||
|
timecode_free_lines[#timecode_free_lines + 1] = line
|
||||||
else
|
else
|
||||||
output_lines[#output_lines + 1] = "`" .. line .. "`"
|
output_lines[#output_lines + 1] = "`" .. line .. "`"
|
||||||
|
timecode_free_lines[#timecode_free_lines + 1] = line:sub(7)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -52,9 +55,14 @@ assert(output_file, "Could not open \"" .. output_file_name .. "\"")
|
|||||||
output_file:write(table.concat(frontmatter, "\n"))
|
output_file:write(table.concat(frontmatter, "\n"))
|
||||||
output_file:write("\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(table.concat(output_lines, "\n"))
|
||||||
output_file:write("\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\"")
|
||||||
@@ -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()
|
|
||||||
Reference in new issue
Block a user