summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2022-12-05 14:22:44 -0500
committerSacha Chua <sacha@sachachua.com>2022-12-05 14:22:44 -0500
commita816549d8654b000e95fdf31e3fc0e8977761bee (patch)
treeba7275821210f21aeeb36db4253b784d619f21ae
parent98a5d9a08a0587fbf1ffe77e5944f76735699ccc (diff)
downloademacsconf-el-a816549d8654b000e95fdf31e3fc0e8977761bee.tar.xz
emacsconf-el-a816549d8654b000e95fdf31e3fc0e8977761bee.zip
add to_archive and pads
-rw-r--r--emacsconf-publish.el94
1 files changed, 71 insertions, 23 deletions
diff --git a/emacsconf-publish.el b/emacsconf-publish.el
index 3aed8a0..53a6d10 100644
--- a/emacsconf-publish.el
+++ b/emacsconf-publish.el
@@ -553,14 +553,19 @@ ${pad-info}${irc-info}${status-info}${schedule-info}\n"
(interactive (list (emacsconf-complete-talk-info)))
(unless (file-directory-p (expand-file-name "captions" (expand-file-name emacsconf-year emacsconf-directory)))
(make-directory (expand-file-name "captions" (expand-file-name emacsconf-year emacsconf-directory))))
- (let ((filename (expand-file-name (concat (plist-get talk :video-slug) "--main.vtt")
- (expand-file-name "captions" (expand-file-name emacsconf-year emacsconf-directory))))
- (cached-file (expand-file-name (concat (plist-get talk :video-slug) "--main.vtt") emacsconf-cache-dir)))
- (when (and (file-exists-p cached-file)
- (or
- (not (file-exists-p filename))
- (file-newer-than-file-p cached-file filename)))
- (copy-file cached-file filename t))))
+ (let ((default-directory emacsconf-directory))
+ (mapc
+ (lambda (ext)
+ (let ((filename (expand-file-name (concat (plist-get talk :video-slug) ext)
+ (expand-file-name "captions" (expand-file-name emacsconf-year emacsconf-directory))))
+ (cached-file (expand-file-name (concat (plist-get talk :video-slug) ext) emacsconf-cache-dir)))
+ (when (and (file-exists-p cached-file)
+ (or
+ (not (file-exists-p filename))
+ (file-newer-than-file-p cached-file filename)))
+ (copy-file cached-file filename t)
+ (shell-command (concat "git add " (shell-quote-argument filename))))))
+ (seq-filter (lambda (o) (string-match "vtt$" o)) emacsconf-main-extensions))))
(defun emacsconf-publish-before-page (talk &optional info)
"Info included before the abstract."
@@ -618,23 +623,24 @@ ${pad-info}${irc-info}${status-info}${schedule-info}\n"
(mapconcat
(lambda (sub)
(let ((msecs (elt sub 1)))
- (format "[[!template %stext=\"%s\" start=\"%s\" video=\"%s\" id=\"subtitle\"%s]]"
+ (format "[[!template %stext=\"\"\"%s\"\"\" start=\"%s\" video=\"%s\" id=\"subtitle\"%s]]"
(if (and paragraphs (>= msecs (elt (car paragraphs) 1)))
(progn
(while (and paragraphs (>= (elt sub 1) (elt (car paragraphs) 1)))
(setq paragraphs (cdr paragraphs)))
"new=\"1\" ")
"")
- (replace-regexp-in-string "\"" "&quot;" (elt sub 3))
+ (replace-regexp-in-string "^#" "\\\\#"
+ (replace-regexp-in-string "\"" "&quot;" (elt sub 3)))
(concat (format-seconds "%02h:%02m:%02s" (/ (floor msecs) 1000))
"." (format "%03d" (mod (floor msecs) 1000)))
video-id
(emacsconf-surround " lang=\"" lang "\"" ""))))
subtitles "\n"))
-(defun emacsconf-format-transcript (talk &optional video-id)
+(defun emacsconf-publish-format-transcript (talk &optional video-id lang)
"Format the transcript for TALK, adding paragraph markers when possible."
- (require 'subed)
+ (require 'subed)
(let* ((paragraphs (expand-file-name
(concat (plist-get talk :video-slug) "--main--paragraphs.vtt")
emacsconf-cache-dir))
@@ -643,22 +649,26 @@ ${pad-info}${irc-info}${status-info}${schedule-info}\n"
emacsconf-cache-dir))
(subtitles
(subed-parse-file (expand-file-name
- (concat (plist-get talk :video-slug) "--main.vtt")
+ (concat (plist-get talk :video-slug)
+ (if lang
+ (format "--main_%s.vtt" lang)
+ "--main.vtt"))
emacsconf-cache-dir)))
(pars (or
(subed-parse-file paragraphs)
(subed-parse-file chapters))))
(if subtitles
- (format "<a name=\"%s-%s-transcript\"></a>
-# Transcript
+ (format "<a name=\"%s-%s-transcript%s\"></a>
+# %s
%s
-
"
- (plist-get talk :slug)
+ (plist-get talk :slug)
(or video-id "mainVideo")
- (emacsconf-format-transcript-from-list
+ (emacsconf-surround "-" lang "" "")
+ (if lang (assoc-default lang emacsconf-publish-subtitle-languages) "Transcript")
+ (emacsconf-format-transcript-from-list
subtitles pars (concat "mainVideo-" (plist-get talk :slug))))
"")))
@@ -671,9 +681,28 @@ ${pad-info}${irc-info}${status-info}${schedule-info}\n"
(insert
"<!-- Automatically generated by emacsconf-publish-after-page -->\n"
"\n\n"
- (if (and (plist-get talk :public)
- (plist-get talk :captions-edited))
- (emacsconf-format-transcript talk) "")
+ (if (plist-get talk :public)
+ (let ((transcripts (mapconcat
+ (lambda (lang)
+ (let ((filename (expand-file-name
+ (concat (plist-get talk :video-slug)
+ (emacsconf-surround "--main_" lang ".vtt" "--main.vtt"))
+ emacsconf-cache-dir)))
+ (if (emacsconf-captions-edited-p filename) ; todo: cache this somewhere
+ (emacsconf-publish-format-transcript talk "mainVideo" lang)
+ "")))
+ (cons nil (mapcar 'car emacsconf-publish-subtitle-languages))
+ "")))
+ (if (> (length transcripts) 0)
+ (concat transcripts
+ (emacsconf-surround
+ (if (string-match "[,;]" (or (plist-get talk :captioner) ""))
+ "\n\nCaptioners: "
+ "\n\nCaptioner: ")
+ (plist-get talk :captioner)
+ "\n\n"))
+ ""))
+ "")
(emacsconf-format-email-questions-and-comments talk) "\n"
"\n\n<!-- End of emacsconf-publish-after-page -->\n")))
@@ -1046,7 +1075,7 @@ Entries are sorted chronologically, with different tracks interleaved."
(assoc-default status by-status)
", ")
"</li>"))
- '("TO_PROCESS" "PROCESSING" "TO_ASSIGN" "TO_CAPTION" "TO_STREAM") "")
+ '("TO_PROCESS" "PROCESSING" "TO_ASSIGN" "TO_CAPTION" "TO_STREAM" "TO_ARCHIVE") "")
"</ul>"
(let ((list (append
(assoc-default "TO_PROCESS" by-status)
@@ -1135,6 +1164,23 @@ Entries are sorted chronologically, with different tracks interleaved."
:files (emacsconf-publish-talk-files f files)))
emacsconf-main-extensions)))
(assoc-default "TO_STREAM" by-status) "\n"))
+ (let ((status "TO_ARCHIVE"))
+ (format
+ "<h1>%d talk(s) to archive (%d minutes)</h1><ol class=\"videos\">%s</ol>"
+ (length (assoc-default status by-status))
+ (emacsconf-sum :video-time (assoc-default status by-status))
+ (mapconcat (lambda (f)
+ (format "<li><a name=\"%s\"></a><strong><a href=\"%s%s\">%s</a></strong><br />%s (id:%s)<br />%s</li>"
+ (plist-get f :slug)
+ emacsconf-base-url
+ (plist-get f :url)
+ (plist-get f :title)
+ (plist-get f :speakers-with-pronouns)
+ (plist-get f :slug)
+ (emacsconf-index-card (append f (list :extra (concat "Captioned by " (plist-get f :captioner))
+ :files (emacsconf-publish-talk-files f files)))
+ emacsconf-main-extensions)))
+ (assoc-default status by-status) "\n")))
(if (file-exists-p (expand-file-name "include-in-index.html" emacsconf-cache-dir))
(with-temp-buffer (insert-file-contents (expand-file-name "include-in-index.html" emacsconf-cache-dir)) (buffer-string))
"")
@@ -1277,6 +1323,8 @@ Entries are sorted chronologically, with different tracks interleaved."
chapters
"\n"))))))
+(defvar emacsconf-publish-subtitle-languages '(("fr" . "French") ("ja" . "Japanese") ("es" . "Spanish")))
+
(defun emacsconf-video-subtitle-tracks (filename track-base-url &optional files)
(setq files (or files (directory-files emacsconf-cache-dir)))
(concat
@@ -1293,7 +1341,7 @@ Entries are sorted chronologically, with different tracks interleaved."
(car lang)
(concat (or track-base-url "") (file-name-nondirectory lang-file)))
"")))
- '(("fr" . "French") ("ja" . "Japanese") ("es" . "Spanish"))
+ emacsconf-publish-subtitle-languages
"")))
(defun emacsconf-link-file-formats (video-slug extensions)