summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2022-12-06 20:36:39 -0500
committerSacha Chua <sacha@sachachua.com>2022-12-06 20:36:39 -0500
commit25eac53e84661c02adf0764a84f66e3d1d4caf90 (patch)
treebf8f8961cd5b53eeb863279da0847f63de84246a
parentc5a4eab85deb982ff850d70c599bf4c3b7415fcf (diff)
downloademacsconf-el-25eac53e84661c02adf0764a84f66e3d1d4caf90.tar.xz
emacsconf-el-25eac53e84661c02adf0764a84f66e3d1d4caf90.zip
initial
-rw-r--r--emacsconf-extract.el101
1 files changed, 101 insertions, 0 deletions
diff --git a/emacsconf-extract.el b/emacsconf-extract.el
new file mode 100644
index 0000000..bdd5b75
--- /dev/null
+++ b/emacsconf-extract.el
@@ -0,0 +1,101 @@
+;;; emacsconf-extract.el --- BigBlueButton -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2022 Sacha Chua
+
+;; Author: Sacha Chua <sacha@sachachua.com>
+
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(defun emacsconf-extract-extract-chat (filename)
+ (when (file-exists-p filename)
+ (message "%s" filename)
+ (mapcar
+ (lambda (node)
+ (when (string= (dom-attr node 'target) "chat")
+ (let ((message
+ (replace-regexp-in-string
+ "\\[<u>\\([^<]+\\)?</u>\\](\"\\([^<]+\\)\")"
+ "<\\2>"
+ (condition-case nil
+ (html-to-markdown-string (dom-attr node 'message))
+ (error
+ (replace-regexp-in-string
+ "<a href=\"\\(.+?\\)\" rel=\"nofollow\"><u>\\(.+?\\)</u></a>"
+ "<\\2>"
+ (dom-attr node 'message)))))))
+ (list (string-to-number (dom-attr node 'in)) (dom-attr node 'name) message))))
+ (dom-by-tag (xml-parse-file filename) 'chattimeline))))
+;; (emacsconf-extract-extract-chat (expand-file-name "bbb-playbacks/haskell/slides_new.xml" emacsconf-cache-dir))
+
+(defvar emacsconf-extract-bbb-chat-use-wall-clock-time nil
+ "Non-nil means use wall clock time for logs.")
+(defun emacsconf-extract-chats ()
+ (interactive)
+ (mapc (lambda (o)
+ (let* ((playback-dir (expand-file-name (plist-get o :slug)
+ (expand-file-name "bbb-playbacks" emacsconf-cache-dir)))
+ (chat
+ (emacsconf-extract-extract-chat
+ (expand-file-name
+ "slides_new.xml"
+ playback-dir)))
+ metadata)
+ (when chat
+ (setq metadata (xml-parse-file (expand-file-name "metadata.xml"
+ playback-dir)))
+ (let ((recording-start (/ (string-to-number (dom-text
+ (dom-by-tag metadata 'start_time)))
+ 1000)))
+ (with-temp-file (expand-file-name (concat (plist-get o :video-slug) "--extract.txt")
+ emacsconf-cache-dir)
+ (insert
+ (mapconcat
+ (lambda (line)
+ (format "`%s` _%s_ %s \n"
+ (if emacsconf-extract-bbb-chat-use-wall-clock-time
+ (format-time-string "%H:%M:%S"
+ (seconds-to-time
+ (+ recording-start
+ (elt line 0))))
+ (format-seconds "%h:%.2m:%.2s"
+ (elt line 0)))
+ (elt line 1)
+ (elt line 2)))
+ chat
+ "")))))))
+ (emacsconf-prepare-for-display (emacsconf-get-talk-info))))
+
+(defun emacsconf-extract-bbb-copy-files ()
+ (interactive)
+ (mapc
+ (lambda (o)
+ (let ((playback-dir (expand-file-name (plist-get o :slug)
+ (expand-file-name "bbb-playbacks" emacsconf-cache-dir))))
+ (mapc (lambda (file)
+ (when (and (file-exists-p (expand-file-name file playback-dir))
+ (not (file-exists-p (expand-file-name (concat (plist-get o :video-slug) "--bbb-" file) emacsconf-cache-dir))))
+ (copy-file (expand-file-name file playback-dir)
+ (expand-file-name (concat (plist-get o :video-slug) "--bbb-" file) emacsconf-cache-dir)
+ t)))
+ '("webcams.webm" "metadata.xml" "deskshare.webm" "deskshare.xml" "slides_new.xml" "webcams.opus"))))
+ (emacsconf-prepare-for-display (emacsconf-get-talk-info))))
+
+
+(provide 'emacsconf-extract)
+;;; emacsconf-extract.el ends here