From b76f3ed03e6d80e514ff34ab078724c772bed901 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 27 Jan 2021 23:48:20 -0500 Subject: Add code for converting transcript to directives --- 2020/organizers-notebook.org | 53 +++++++++++++------------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) (limited to '2020') diff --git a/2020/organizers-notebook.org b/2020/organizers-notebook.org index 89792aab..1eb742dd 100644 --- a/2020/organizers-notebook.org +++ b/2020/organizers-notebook.org @@ -823,44 +823,21 @@ If TALK is not specified, do it in the current buffer." ,@body) ,@body)) -(defun conf/add-transcript (&optional talk) - "Try to add transcript for the current talk." - (interactive) - (conf/with-talk-info-file talk - (goto-char (point-min)) - (let (subtitles subed-auto-find-video all) - (while (re-search-forward "subtitles=\"/\\(.+?\\)\"" nil t) - (setq subtitles (cons (match-string 1) subtitles)) - (when (re-search-forward "^$\\|\\[View transcript" nil t) - (unless (string= (match-string 0) "[View transcript") - (insert - (if (string-match "questions" (car subtitles)) - "[View transcript for Q&A](#transcript-questions)\n" - "[View transcript](#transcript)\n"))))) - (when subtitles - (mapc - (lambda (subtitle-file) - (with-current-buffer (find-file-noselect (expand-file-name subtitle-file conf/wiki-directory)) - (goto-char (point-min)) - (subed-mode) - (let (text) - (while (subed-forward-subtitle-text) - (setq text (cons (subed-subtitle-text) text))) - (setq all (mapconcat 'identity (reverse text) "\n")))) - (if (re-search-forward (format "[ \t]*\n\\([.\r\n]*?\\)" (regexp-quote subtitle-file)) nil t) - (progn - (goto-char (match-beginning 1)) - (delete-region (match-beginning 1) (match-end 1))) - (goto-char (point-max)) - (insert (format "\n\n\n\n" subtitle-file)) - (insert (if (string-match "questions" subtitle-file) - "\n# Transcript: Q&A\n\n" - "\n# Transcript\n\n")) - (save-excursion (insert "\n\n\n"))) - (save-excursion (insert all))) - (reverse subtitles)))))) - -;; (conf/add-transcript (conf/find-talk "03")), or call from a talk info page +(defun my/convert-transcript-to-directives (id) + (interactive "MID: ") + (goto-char (point-min)) + (kill-new + (concat + "\n# Transcript\n\n" + (cl-loop while (subed-forward-subtitle-text) + concat (format "[[!template text=\"%s\" start=\"%s\" video=\"%s\" id=subtitle]]\n" + (replace-regexp-in-string + "\n" " " + (replace-regexp-in-string + "\"" """ + (replace-regexp-in-string "[][]" "" (subed-subtitle-text)))) + (subed-vtt--msecs-to-timestamp (subed-subtitle-msecs-start)) + id))))) #+end_src * Other useful tidbits -- cgit v1.2.3