Created
April 12, 2023 13:41
-
-
Save lotuc/81010f9f4267d1c29efe0966caa5a43a to your computer and use it in GitHub Desktop.
Format youtube transcript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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