diff options
| author | Sacha Chua <sacha@sachachua.com> | 2025-12-30 19:26:55 -0500 |
|---|---|---|
| committer | Sacha Chua <sacha@sachachua.com> | 2025-12-30 19:26:55 -0500 |
| commit | 05e815dd879a14d43ea4a37074513f6c8143efeb (patch) | |
| tree | 2016a7635a394c3e6329b2520be8491ad82804b4 | |
| parent | 5a6f9f507be4d436a5db61bb25fbd17702b8edb9 (diff) | |
| download | emacsconf-el-05e815dd879a14d43ea4a37074513f6c8143efeb.tar.xz emacsconf-el-05e815dd879a14d43ea4a37074513f6c8143efeb.zip | |
| -rw-r--r-- | emacsconf-extract.el | 84 | ||||
| -rw-r--r-- | emacsconf-publish.el | 165 | ||||
| -rw-r--r-- | emacsconf.el | 7 |
3 files changed, 57 insertions, 199 deletions
diff --git a/emacsconf-extract.el b/emacsconf-extract.el index 5600494..194d86c 100644 --- a/emacsconf-extract.el +++ b/emacsconf-extract.el @@ -1652,90 +1652,6 @@ If QA is non-nil, treat it as a Q&A video." ;;; PeerTube -(defvar emacsconf-extract-toobnix-api-client nil) -(defvar emacsconf-extract-toobnix-api-bearer-token nil) -(defvar emacsconf-extract-toobnix-api-username "bandali") -(defvar emacsconf-extract-toobnix-api-channel-handle "emacsconf") - -(defun emacsconf-extract-toobnix-api-header () - `(("Authorization" . ,(concat "Bearer " - (if (stringp emacsconf-extract-toobnix-api-bearer-token) - emacsconf-extract-toobnix-api-bearer-token - (assoc-default 'access_token emacsconf-extract-toobnix-api-bearer-token)))))) - -(defun emacsconf-extract-toobnix-api-setup () - (interactive) - (require 'plz) - (require 'url-http-oauth) - (setq emacsconf-extract-toobnix-api-client - (plz 'get "https://toobnix.org/api/v1/oauth-clients/local" :as #'json-read)) - (setq emacsconf-extract-toobnix-api-bearer-token - (assoc-default - 'access_token - (plz 'post "https://toobnix.org/api/v1/users/token" - :body (mm-url-encode-www-form-urlencoded - `(("client_id" . ,(assoc-default 'client_id emacsconf-extract-toobnix-api-client)) - ("client_secret" . ,(assoc-default 'client_secret emacsconf-extract-toobnix-api-client)) - ("grant_type" . "password") - ("username" . ,emacsconf-extract-toobnix-api-username) - ("password" . ,(auth-info-password (car (auth-source-search :host "https://toobnix.org")))))) - :as #'json-read) - ) -) - (setq emacsconf-extract-toobnix-api-channels - (plz 'get (format "https://toobnix.org/api/v1/accounts/%s/video-channels" - emacsconf-extract-toobnix-api-username) - :headers - :as #'json-read)) - (setq emacsconf-extract-toobnix-api-videos - (plz 'get - (format "https://toobnix.org/api/v1/accounts/%s/videos?count=100&sort=-createdAt" - emacsconf-extract-toobnix-api-username) - :headers (emacsconf-extract-toobnix-api-header) - :as #'json-read)) - (setq emacsconf-extract-toobnix-api-playlists - (append - (assoc-default 'data - (plz 'get - (format "https://toobnix.org/api/v1/video-channels/%s/video-playlists?sort=-createdAt" - emacsconf-extract-toobnix-api-channel-handle) - :headers (emacsconf-extract-toobnix-api-header) - :as #'json-read)) - nil))) - -(defun emacsconf-extract-toobnix-publish-video-from-edit-page () - "Messy hack to set a video to public and store the URL." - (interactive) - (spookfox-js-injection-eval-in-active-tab "document.querySelector('label[for=privacy]').scrollIntoView(); document.querySelector('label[for=privacy]').closest('.form-group').querySelector('input').dispatchEvent(new Event('input'));" t) - (sit-for 1) - (spookfox-js-injection-eval-in-active-tab "document.querySelector('span[title=\"Anyone can see this video\"]').click()" t) - (sit-for 1) - (spookfox-js-injection-eval-in-active-tab "document.querySelector('button.orange-button').click()" t)(sit-for 3) - (emacsconf-extract-store-url) - (shell-command "xdotool key Alt+Tab sleep 1 key Ctrl+w Alt+Tab")) - -(defun emacsconf-extract-toobnix-set-up-playlist () - (interactive) - (mapcar - (lambda (o) - (when (plist-get o :toobnix-url) - (browse-url (plist-get o :toobnix-url)) - (read-key "press a key when page is loaded") - (spookfox-js-injection-eval-in-active-tab "document.querySelector('.action-button-save').click()" t) - (spookfox-js-injection-eval-in-active-tab "document.querySelector('my-peertube-checkbox').click()" t) - (read-key "press a key when saved to playlist")) - (when (plist-get o :qa-toobnix-url) - (browse-url (plist-get o :qa-toobnix-url)) - (read-key "press a key when page is loaded") - (spookfox-js-injection-eval-in-active-tab "document.querySelector('.action-button-save').click()" t) - (spookfox-js-injection-eval-in-active-tab "document.querySelector('my-peertube-checkbox').click()" t) - (read-key "press a key when saved to playlist"))) - (emacsconf-publish-prepare-for-display (emacsconf-get-talk-info)))) - -(defun emacsconf-extract-toobnix-view-qa (talk) - (interactive (list (emacsconf-complete-talk-info))) - (browse-url (plist-get (emacsconf-resolve-talk talk) :qa-toobnix-url))) - (defun emacsconf-extract-youtube-spookfox-add-playlist-numbers () "Number the playlist for easier checking. Related: `emacsconf-extract-check-playlists'." diff --git a/emacsconf-publish.el b/emacsconf-publish.el index cbaf233..590884b 100644 --- a/emacsconf-publish.el +++ b/emacsconf-publish.el @@ -649,8 +649,8 @@ ${categories} :public 1 :video-type "qanda" :video-id (concat "qanda-" (plist-get o :slug)) - :youtube-url (plist-get o :qa-youtube) - :toobnix-url (plist-get o :qa-toobnix) + :youtube-url (plist-get o :qa-youtube-url) + :toobnix-url (plist-get o :qa-toobnix-url) :captions-edited (plist-get o :qa-captions-edited) :caption-file (emacsconf-talk-file o "--answers.vtt") :video-file (plist-get o :qa-video-file) @@ -2041,8 +2041,8 @@ ${include} (if (file-exists-p qa-video) (string-trim (shell-command-to-string (concat "sha1sum -b " (shell-quote-argument qa-video) " | cut -d ' ' -f 1"))) "") - (or (plist-get o :qa-youtube) "") - (or (plist-get o :qa-toobnix) ""))))))) + (or (plist-get o :qa-youtube-url) "") + (or (plist-get o :qa-toobnix-url) ""))))))) (emacsconf-public-talks (emacsconf-get-talk-info)))))) (insert (orgtbl-to-csv (cons '("Conference" "Slug" "Title" "Speakers" "Talk page URL" "Video URL" "Date" "Duration" "SHA" "Youtube URL" "Toobnix URL") @@ -2287,40 +2287,6 @@ This video is available under the terms of the Creative Commons Attribution-Shar (throw 'done t)) (emacsconf-publish-youtube-step-through-publishing-talk talk))))) -(defun emacsconf-publish-toobnix-step-through-publishing-talk (talk) - (interactive (list (emacsconf-complete-talk-info - (seq-remove - (lambda (talk) - (or (not (plist-get talk :video-file)) - (plist-get talk :toobnix-url))) - (emacsconf-get-talk-info))))) - (kill-new (plist-get talk :video-file)) - (y-or-n-p - (format "Video: %s - create video and upload this filename. Done?" - (plist-get talk :video-file))) - (kill-new (emacsconf-publish-video-description talk t)) - (y-or-n-p "Copied description. Paste into description, move first line to title, add to playlist. Done?") - (when (emacsconf-talk-file talk "--main.vtt") - (kill-new (emacsconf-talk-file talk "--main.vtt")) - (y-or-n-p (format "Captions: %s. Add to video elements. Done?" - (emacsconf-talk-file talk "--main.vtt")))) - (emacsconf-set-property-from-slug - (plist-get talk :slug) - "TOOBNIX_URL" - (read-string (format "%s - Toobnix URL: " (plist-get talk :scheduled))))) - -(defun emacsconf-publish-toobnix-step-through-publishing-all () - (interactive) - (catch 'done - (while t - (let ((talk (seq-find (lambda (o) - (and (not (plist-get o :toobnix-url)) - (emacsconf-talk-file o "--main.webm"))) - (emacsconf-publish-prepare-for-display (emacsconf-get-talk-info))))) - (unless talk - (message "All done so far.") - (throw 'done t)) - (emacsconf-publish-toobnix-step-through-publishing-talk talk))))) ;; (emacsconf-publish-video-description (emacsconf-find-talk-info "async") t) @@ -2402,16 +2368,7 @@ This video is available under the terms of the Creative Commons Attribution-Shar (browse-url (format "https://studio.youtube.com/video/%s/edit" (match-string 1 url)))) (browse-url (concat "https://studio.youtube.com/channel/" emacsconf-youtube-channel-id))))) -(defun emacsconf-toobnix-edit () - (interactive) - (let ((url (org-entry-get (point) "TOOBNIX_URL"))) - (if url - (when (string-match "/w/\\([A-Za-z0-9]+\\)" url) - (browse-url (format "https://toobnix.org/videos/update/%s" (match-string 1 url)))) - (when (> (length (org-entry-get (point) "FILE_PREFIX")) 80) - (copy-file (expand-file-name (concat (org-entry-get (point) "FILE_PREFIX") "--main.webm") emacsconf-cache-dir) - (expand-file-name (concat "emacsconf-" emacsconf-year "-" (org-entry-get (point) "SLUG") ".webm") emacsconf-cache-dir) t)) - (browse-url "https://toobnix.org/videos/upload#upload")))) + (defun emacsconf-publish-files () (interactive) @@ -2886,43 +2843,7 @@ This video is available under the terms of the Creative Commons Attribution-Shar (emacsconf-with-talk-heading talk)) result)) -(defvar emacsconf-publish-toobnix-upload-command "peertube-cli") -(defvar emacsconf-publish-toobnix-channel "EmacsConf") -;; (defun emacsconf-publish-get-toobnix-token () -;; (let ((secrets (plz 'get "https://toobnix.org/api/v1/oauth-clients/local" :as #'json-read))) - -;; ) - -;; ) -(defun emacsconf-publish-upload-to-toobnix (properties) - "Uses peertube-cli: https://github.com/Chocobozzz/PeerTube/blob/develop/support/doc/tools.md" - (with-temp-buffer - (let ((arguments - (append - (list "upload" "-f" (plist-get properties :file)) - (when (plist-get properties :title) - (list "-n" (plist-get properties :title))) - (when (plist-get properties :description) - (list "-d" (plist-get properties :description))) - (list "-L" "en" - "-C" emacsconf-publish-toobnix-channel - "-l" "2" - "-c" "15" - "-P" (if (string= (plist-get properties :privacy) "public") "1" "2") "-t" - (cond - ((stringp (plist-get properties :tags)) - (plist-get properties :tags)) - ((listp (plist-get properties :tags)) - (string-join (plist-get properties :tags) ",")) - (t "emacs")))))) - (kill-new (mapconcat - #'shell-quote-argument - (append (list emacsconf-publish-toobnix-upload-command) arguments) - " ")) - (apply #'call-process - emacsconf-publish-toobnix-upload-command - nil t t arguments) - (buffer-string)))) + ;; YouTube (defun emacsconf-publish-spookfox-update-youtube-video () @@ -3074,7 +2995,7 @@ Tends to be quota-limited, though." :tags emacsconf-publish-talk-video-tags :playlist (concat emacsconf-name " " emacsconf-year) :date (plist-get talk :start-time) - :privacy (if (plist-get talk :public) "public" "unlisted") + :privacy (if (plist-get talk :qa-public) "public" "unlisted") :title (if (< (length title) 100) title (concat (substring title 0 97) "...")) :description (emacsconf-publish-answers-description talk platform)))) @@ -3083,19 +3004,32 @@ Tends to be quota-limited, though." (list (emacsconf-complete-talk-info) (intern (completing-read "Platform: " '("youtube" "toobnix"))))) (let ((file (emacsconf-talk-file talk "--main.webm")) + (props (emacsconf-publish-talk-video-properties talk platform)) + url output) (when (and file (not (plist-get talk (if (eq platform 'toobnix) :toobnix-url :youtube-url)))) (setq output (funcall (if (eq platform 'toobnix) - #'emacsconf-publish-upload-to-toobnix + #'emacsconf-toobnix-upload #'emacsconf-publish-upload-to-youtube) - (emacsconf-publish-talk-video-properties talk platform))) - (when (and (string-match "Video URL: \\(.*+\\)" output) (eq platform 'youtube)) - (setq output (match-string 1 output)) - (save-window-excursion - (emacsconf-go-to-talk talk) - (org-entry-put (point) "YOUTUBE_URL" output))) + props)) + (pcase platform + ('youtube + (when (string-match "Video URL: \\(.*+\\)" output) + (setq url (match-string 1 output)) + (save-window-excursion + (emacsconf-go-to-talk talk) + (org-entry-put (point) "YOUTUBE_URL" url)))) + ('toobnix + (setq url (emacsconf-toobnix-latest-video-url props)) + (save-window-excursion + (emacsconf-go-to-talk talk) + (org-entry-put + (point) + "TOOBNIX_URL" + url)))) + (message "Uploaded talk for %s: %s" (plist-get talk :slug) url) output))) (defun emacsconf-publish-upload-answers (talk platform) @@ -3103,25 +3037,32 @@ Tends to be quota-limited, though." (intern (completing-read "Platform: " '("youtube" "toobnix"))))) (let ((file (emacsconf-talk-file talk "--answers.webm")) (title (concat emacsconf-name " " emacsconf-year " Q&A: " (plist-get talk :title))) - output) - (when (and file (not (plist-get talk (if (eq platform 'toobnix) :qa-toobnix :qa-youtube)))) + output + (props (emacsconf-publish-answers-video-properties talk platform)) + url) + (when (and file (not (plist-get talk (if (eq platform 'toobnix) :qa-toobnix-url :qa-youtube-url)))) (setq output (funcall (if (eq platform 'toobnix) - #'emacsconf-publish-upload-to-toobnix + #'emacsconf-toobnix-upload #'emacsconf-publish-upload-to-youtube) - (list - :file file - :tags "emacs,emacsconf,answers" - :playlist (concat emacsconf-name " " emacsconf-year) - :date (plist-get talk :start-time) - :title (if (< (length title) 100) title (concat (substring title 0 97) "...")) - :description (emacsconf-publish-answers-description talk platform)))) - (when (string-match "Video URL: \\(.*+\\)" output) - (setq output (match-string 1 output)) - (save-window-excursion - (emacsconf-go-to-talk talk) - (org-entry-put (point) "QA_YOUTUBE" output))) + props)) + (pcase platform + ('youtube + (when (string-match "Video URL: \\(.*+\\)" output) + (setq url (match-string 1 output)) + (save-window-excursion + (emacsconf-go-to-talk talk) + (org-entry-put (point) "QA_YOUTUBE_URL" url)))) + ('toobnix + (setq url (emacsconf-toobnix-latest-video-url props)) + (save-window-excursion + (emacsconf-go-to-talk talk) + (org-entry-put + (point) + "QA_TOOBNIX_URL" + url)))) + (message "Uploaded Q&A for %s: %s" (plist-get talk :slug) url) output))) (defun emacsconf-publish-upload-answers-to-youtube (talk) @@ -3129,7 +3070,7 @@ Tends to be quota-limited, though." (let ((file (plist-get talk :qa-video-file)) (title (concat emacsconf-name " " emacsconf-year " Q&A: " (plist-get talk :title))) output) - (when (and file (not (plist-get talk :qa-youtube))) + (when (and file (not (plist-get talk :qa-youtube-url))) (setq output (emacsconf-publish-upload-to-youtube (list @@ -3265,8 +3206,8 @@ Tends to be quota-limited, though." (list :conf-name emacsconf-name :conf-year emacsconf-year - :youtube-url (plist-get talk :qa-youtube) - :toobnix-url (plist-get talk :qa-toobnix) + :youtube-url (plist-get talk :qa-youtube-url) + :toobnix-url (plist-get talk :qa-toobnix-url) :media-url (format "https://media.emacsconf.org/%s/%s--answers.webm" emacsconf-year (plist-get talk :file-prefix)) @@ -3299,7 +3240,7 @@ Tends to be quota-limited, though." " ))) (with-current-buffer (find-file-noselect emacstv-index-org) - (if (and (plist-get talk :qa-youtube) (emacstv-find-by-youtube-url (plist-get talk :qa-youtube))) + (if (and (plist-get talk :qa-youtube-url) (emacstv-find-by-youtube-url (plist-get talk :qa-youtube-url))) (progn (org-entry-put (point) "DATE" (format-time-string "%FT%T%z" (plist-get talk :start-time) t)) (org-entry-put (point) diff --git a/emacsconf.el b/emacsconf.el index d95a26d..cd82d54 100644 --- a/emacsconf.el +++ b/emacsconf.el @@ -662,8 +662,9 @@ If INFO is specified, limit it to that list." (:sched-note "SCHED_NOTE") (:hyperlist-note "HYPERLIST_NOTE") ;; Extraction - (:qa-youtube "QA_YOUTUBE") - (:qa-toobnix "QA_TOOBNIX") + (:qa-youtube-url "QA_YOUTUBE_URL") + (:qa-toobnix-url "QA_TOOBNIX_URL") + (:qa-video-file "QA_VIDEO_FILE") (:bbb-playback "BBB_PLAYBACK") ;; Old (:alternate-apac "ALTERNATE_APAC") @@ -800,7 +801,7 @@ The subheading should match `emacsconf-abstract-heading-regexp'." (time-less-p (plist-get o :start-time) (current-time))) (plist-put o :public t)) - (when (eq emacsconf-publishing-phase 'resource) + (when (eq emacsconf-publishing-phase 'resources) (plist-put o :qa-public t)) o) |
