Add osx/youtube/vlc scripts

This commit is contained in:
Henrik Lissner 2015-03-15 15:41:25 -04:00
parent 8e0d67f625
commit 24bf342a63
4 changed files with 47 additions and 0 deletions

Binary file not shown.

View file

@ -0,0 +1,39 @@
(defconst yt-stopwatch-script-path (file-name-directory load-file-name))
(defun yt-stopwatch-record-time ()
(interactive)
(beginning-of-line)
(insert (format "* %ss - " (yt-stopwatch--reformat-time (cdr (yt-stopwatch--probe))))))
(defun yt-stopwatch--reformat-time (seconds)
(format-time-string "%H:%M:%S" (encode-time (string-to-number (car seconds)) 0 0 0 0 0)))
(defun yt-stopwatch-video-name ()
(interactive)
(beginning-of-line)
(insert (format "%s\n" (car (yt-stopwatch--probe)))))
(defun yt-stopwatch--probe ()
(let ((out (shell-command-to-string (format "osascript %s/probe.scpt" yt-stopwatch-script-path))))
(if (string-equal out "---\n")
(user-error "VLC isn't running or no video playing")
(split-string out " || " t "[\n \t]+"))))
(defun yt-stopwatch-test ()
(interactive)
(let ((data (yt-stopwatch--probe)))
(message "Video: %s \n Time: %ss" (car data) (cdr data))))
(defvar yt-stopwatch-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c y") 'yt-stopwatch-record-time)
(define-key map (kbd "C-c C-y") 'yt-stopwatch-video-name)
map))
(define-minor-mode yt-stopwatch-mode
:keymap yt-stopwatch-mode-map
:group yt-stopwatch-mode)
(provide 'yt-stopwatch)
;;; yt-stopwatch.el ends here

View file

@ -42,6 +42,7 @@
(let ((default-directory my-elisp-dir))
(normal-top-level-add-subdirs-to-load-path))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Just the... bear necessities...
(mapc 'require
@ -85,6 +86,7 @@
;; init-vala
init-web
init-yasnippet ; type for me
init-youtube ; tools for youtube vids
my-bindings
my-settings

6
init/init-youtube.el Normal file
View file

@ -0,0 +1,6 @@
(require 'yt-stopwatch)
(provide 'init-youtube)
;;; init-youtube.el ends here