add ruby to a vtt file

This commit is contained in:
Nitsud Yarg 2026-05-15 11:46:39 -07:00
parent 4b33f6e113
commit 7bb75ae7d9

View File

@ -32,7 +32,7 @@ def main():
vocab = load_vocab('foo.json') vocab = load_vocab('foo.json')
with open("/run/media/deck/YF8SD/Video/[Retimed and Corrected] Yu-Gi-Oh! Duel Monsters - 001.srt", "r", encoding="utf-8") as f: with open("/run/media/deck/YF8SD/Video/Yu-Gi-Oh! Duel Monsters - 001.vtt", "r", encoding="utf-8") as f:
lines = f.readlines() lines = f.readlines()
@ -54,14 +54,17 @@ def main():
print(result['kana_reading']) print(result['kana_reading'])
notes_lines.append(result["ruby_html"] + "\n" ) notes_lines.append(result["ruby_html"] + "\n" )
notes_lines.append (result['notes_link'] + "\n") notes_lines.append (result['notes_link'] + "\n")
if lines[i] != result['kana_reading']: if lines[i] != result['ruby_html']:
lines[i] = result['kana_reading'] + "\n" # lost the new line lines[i] = result['ruby_html'] + "\n" # lost the new line
# if lines[i] != result['kana_reading']:
# lines[i] = result['kana_reading'] + "\n" # lost the new line
else: else:
#notes_lines.append("`" + lines[i].strip() + "`" + "\n") #notes_lines.append("`" + lines[i].strip() + "`" + "\n")
notes_lines.append(lines[i]) notes_lines.append(lines[i])
i+=1 i+=1
## Lookup vocab ## Lookup vocab
if False:
for word in vocab: for word in vocab:
#vocab_hash = hashlib.shake_256((word + dictionary_name).encode()).hexdigest(4) #vocab_hash = hashlib.shake_256((word + dictionary_name).encode()).hexdigest(4)
if Path(destination_path.joinpath('vocab/' + word + '.md')).exists() == False: if Path(destination_path.joinpath('vocab/' + word + '.md')).exists() == False:
@ -82,11 +85,11 @@ def main():
print("##### Other Definitions", file=vocab_note) print("##### Other Definitions", file=vocab_note)
print(entry['glossary-plain-no-dictionary'], file=vocab_note) print(entry['glossary-plain-no-dictionary'], file=vocab_note)
with open("subtitle.srt", "w", encoding="utf-8") as f: with open("/run/media/deck/YF8SD/Video/Yu-Gi-Oh! Duel Monsters - 001.vtt", "w", encoding="utf-8") as f:
f.writelines(lines) f.writelines(lines)
with open("notestest-newchunks.md", "w", encoding="utf-8") as f: # with open("notestest-newchunks.md", "w", encoding="utf-8") as f:
f.writelines(notes_lines) # f.writelines(notes_lines)
#vocab = load_vocab(args.vocab_file) #vocab = load_vocab(args.vocab_file)
#result = analyze(text, vocab) #result = analyze(text, vocab)