Skip to content

Instantly share code, notes, and snippets.

@lotuc
Created April 12, 2023 13:41
Show Gist options
  • Save lotuc/81010f9f4267d1c29efe0966caa5a43a to your computer and use it in GitHub Desktop.
Save lotuc/81010f9f4267d1c29efe0966caa5a43a to your computer and use it in GitHub Desktop.
Format youtube transcript
;; Go to video.
;; Click the three dot menu below the video.
;; Click open transcript.
;; Click and drag to highlight the whole transcript.
;; Save to /tmp/a.txt
;; Run this with clj/babashka
(require '[clojure.string :as str])
(->> (iterate (fn [[r lines]]
(let [[x xs] (split-at 2 lines)]
[(conj r x) (seq xs)]))
[[] (-> (slurp "/tmp/a.txt")
(str/split #"\n"))])
(take-while second)
last
(apply conj)
(map #(str/join ": " %))
(str/join "\n\n")
(spit "/tmp/b.txt"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment