emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eev d73f329 04/20: Cleaned up and reorganized `find-you


From: Stefan Monnier
Subject: [elpa] externals/eev d73f329 04/20: Cleaned up and reorganized `find-youtubedl-links'.
Date: Mon, 4 Jan 2021 01:01:47 -0500 (EST)

branch: externals/eev
commit d73f3292eb573d816baf44fb960d1a22e835d2f5
Author: Eduardo Ochs <eduardoochs@gmail.com>
Commit: Eduardo Ochs <eduardoochs@gmail.com>

    Cleaned up and reorganized `find-youtubedl-links'.
---
 ChangeLog         |  13 +++++
 VERSION           |   4 +-
 eev-audiovideo.el |   4 +-
 eev-elinks.el     |  59 +++++++++----------
 eev-intro.el      |  26 +--------
 eev-pkg.el        |   2 +-
 eev-tlinks.el     | 172 ++++++++++++++++++++++++++++--------------------------
 eev.el            |   2 +-
 8 files changed, 137 insertions(+), 145 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f607555..ab89b0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2020-10-30  Eduardo Ochs  <eduardoochs@gmail.com>
+
+       * eev-tlinks.el (find-youtubedl-links): rewrote using
+       `find-find-links-links-new'. Deleted the sexps with `find-video'
+       and `code-video' that would point to a partially downloaded video.
+       (ee-youtubedl-dirs): new variable.
+       (ee-youtubedl-dir-links): new function.
+       (ee-youtubedl-dir2, ee-youtubedl-dir3, ee-youtubedl-dir4):
+       deleted.
+
+       * eev-elinks.el (find-eface-links, find-color-links): rewrote
+       using `find-find-links-links-new'.
+
 2020-10-27  Eduardo Ochs  <eduardoochs@gmail.com>
 
        * eev-audiovideo.el (ee-find-mpv-video): use "--start=1:23"
diff --git a/VERSION b/VERSION
index e4ca8b5..afeeaa4 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Tue Oct 27 06:43:11 GMT 2020
-Tue Oct 27 03:43:11 -03 2020
+Fri Oct 30 06:26:39 GMT 2020
+Fri Oct 30 03:26:39 -03 2020
diff --git a/eev-audiovideo.el b/eev-audiovideo.el
index c8ada3c..2f78287 100644
--- a/eev-audiovideo.el
+++ b/eev-audiovideo.el
@@ -476,8 +476,8 @@ See: (find-audiovideo-intro \"`eev-avadj-mode'\")"
 ;; Garbage?
 
 
-;; Tests: (ee-time-to-youtube-time "2")  
-;;        (ee-time-to-youtube-time "23") 
+;; Tests: (ee-time-to-youtube-time "2")
+;;        (ee-time-to-youtube-time "23")
 ;;        (ee-time-to-youtube-time "1:23")
 ;;        (ee-time-to-youtube-time "1:23:43")
 ;;
diff --git a/eev-elinks.el b/eev-elinks.el
index 0f6dc06..5199a19 100644
--- a/eev-elinks.el
+++ b/eev-elinks.el
@@ -19,7 +19,7 @@
 ;;
 ;; Author:     Eduardo Ochs <eduardoochs@gmail.com>
 ;; Maintainer: Eduardo Ochs <eduardoochs@gmail.com>
-;; Version:    2020oct11
+;; Version:    2020oct30
 ;; Keywords:   e-scripts
 ;;
 ;; Latest version: <http://angg.twu.net/eev-current/eev-elinks.el>
@@ -1022,23 +1022,20 @@ See the comments in the source code."
 ;;; |  _| | | | | (_| |_____|  __/  _| (_| | (_|  __/_____| | | | | |   <\__ \
 ;;; |_| |_|_| |_|\__,_|      \___|_|  \__,_|\___\___|     |_|_|_| |_|_|\_\___/
 ;;;                                                                           
-;; See: (find-links-intro)
-;;      (find-templates-intro)
-
 ;; «find-eface-links» (to ".find-eface-links")
-;; Skel: (find-find-links-links-old "\\M-s" "eface" "face-symbol")
-;; A test: (find-eface-links 'bold)
-
+;; Skel: (find-find-links-links-new "eface" "face-symbol" "")
+;; Test: (find-eface-links 'eepitch-star-face)
 ;; Moved to eev-mode.el:
-;; (define-key eev-mode-map "\M-h\M-s" 'find-eface-links)
-
-(defun find-eface-links (face-symbol &rest pos-spec-list)
-"Visit a temporary buffer containing hyperlinks about FACE-SYMBOL."
+;;   (define-key eev-mode-map "\M-h\M-s" 'find-eface-links)
+;;
+(defun find-eface-links (&optional face-symbol &rest pos-spec-list)
+"Visit a temporary buffer containing hyperlinks about FACE-SYMBOL.
+When called interactively generate hyperlinks about the face at point."
   (interactive (list (or (face-at-point) 'default)))
-  ;; (setq face-symbol (or face-symbol "{face-symbol}"))
-  ;; (setq face-symbol (or face-symbol (face-at-point)))
-  (apply 'find-elinks
-   `((find-eface-links ',face-symbol ,@pos-spec-list)
+  (setq face-symbol (or face-symbol "{face-symbol}"))
+  (apply
+   'find-elinks
+   `((find-eface-links ,face-symbol ,@pos-spec-list)
      ;; Convention: the first sexp always regenerates the buffer.
      (find-efunction 'find-eface-links)
      ""
@@ -1056,9 +1053,6 @@ See the comments in the source code."
      )
    pos-spec-list))
 
-;; Test: (find-eface-links 'eepitch-star-face)
-;; (find-eevfile "eev.el" "\\M-h\\M-s")
-
 
 
 
@@ -1069,21 +1063,19 @@ See the comments in the source code."
 ;;; |_| |_|_| |_|\__,_|     \___|\___\___/|_|\___/|_|      |_|_|_| |_|_|\_\___/
 ;;;                                                                            
  
 ;; «find-color-links» (to ".find-color-links")
-;; Skel: (find-find-links-links-old "c" "color" "initialcolor")
-;; Tests:
-;;   (find-ecolor-links)
-;;   (find-ecolor-links "sienna")
+;; Skel: (find-find-links-links-new "color" "initialcolor" "")
+;; Tests: (find-ecolor-links)
+;;        (find-ecolor-links "sienna")
 ;;
-
-;; Moved to eev-mode.el:
-;; (define-key eev-mode-map "\M-hc" 'find-ecolor-links)
-
-(defun find-ecolor-links (&optional initialcolor &rest pos-spec-list)
+(defun find-color-links (&optional initialcolor &rest pos-spec-list)
   "Visit a temporary buffer containing hyperlinks for the color INITIALCOLOR."
   (interactive)
   (setq initialcolor (or initialcolor "#123456"))
-  (apply 'find-elinks
-   `((find-ecolor-links ,initialcolor ,@pos-spec-list)
+  (apply
+   'find-elinks
+   `((find-color-links ,initialcolor ,@pos-spec-list)
+     ;; Convention: the first sexp always regenerates the buffer.
+     (find-efunction 'find-color-links)
      ""
      (find-ecolor-links (ee-color-choose-tk ,(or initialcolor "gray")))
      (find-ecolor-links ,(or initialcolor "gray"))
@@ -1093,7 +1085,6 @@ See the comments in the source code."
      ,`(ee-color-values ,initialcolor)
      (kill-new ,initialcolor)
      (kill-new ,(ee-color-values initialcolor))
-     (find-efunction 'find-ecolor-links)
      )
    pos-spec-list))
 
@@ -1102,6 +1093,14 @@ See the comments in the source code."
   (apply 'format "#%02x%02x%02x"
         (mapcar (lambda (c) (lsh c -8)) (color-values color))))
 
+;; `ee-color-choose-tk' is a VERY OLD hack that needs eetcl... see:
+;; http://angg.twu.net/eev-current/eev-langs.el.html
+;; http://angg.twu.net/eev-current/eev-langs.el
+;;   (find-sh0     "echo $EEVTMPDIR")
+;;   (find-fline        "$EEVTMPDIR")
+;;   (find-sh0 "mkdir -p $EEVTMPDIR")
+;;   (require 'eev-langs)
+;;
 (defun ee-color-choose-tk (&optional initialcolor)
   "Call Tcl/Tk to choose a color similar to INITIALCOLOR.
 This needs a temporary directory; see: (find-prepared-intro)"
diff --git a/eev-intro.el b/eev-intro.el
index 238afc5..5a074af 100644
--- a/eev-intro.el
+++ b/eev-intro.el
@@ -11181,30 +11181,6 @@ This can also be used to generate links to info nodes.
 
 (...)
 
-
-
-5.7. Refining hyperlinks
-------------------------
-(...)
-
-5.8. Pointing to anchors
-------------------------
-(...)
-
-5.9. Using a TODO file
-----------------------
-(...)
-
-5.10. Using several e-script files
-----------------------------------
-(...)
-
-5.11. Eepitch blocks in multi-line comments
--------------------------------------------
-(...)
-
-
-
 " pos-spec-list)))
 
 ;; (find-escripts-intro)
@@ -11281,7 +11257,7 @@ early draft.
 ==============
 Download the second URL below with `M-x brep',
 
-  http://peepcode.com/products/git-internals-pdf
+  https://github.com/pluralsight/git-internals-pdf/
   
https://github.com/pluralsight/git-internals-pdf/releases/download/v2.0/peepcode-git.pdf
 
 and run this eepitch block,
diff --git a/eev-pkg.el b/eev-pkg.el
index dc4434e..5f0950a 100644
--- a/eev-pkg.el
+++ b/eev-pkg.el
@@ -1,4 +1,4 @@
-(define-package "eev" "20201022" "Support for e-scripts (eepitch blocks, elisp 
hyperlinks, etc)"
+(define-package "eev" "20201030" "Support for e-scripts (eepitch blocks, elisp 
hyperlinks, etc)"
   '((emacs "24.1"))
   :keywords
   '("lisp" "e-scripts")
diff --git a/eev-tlinks.el b/eev-tlinks.el
index a37dac6..fac810d 100644
--- a/eev-tlinks.el
+++ b/eev-tlinks.el
@@ -19,7 +19,7 @@
 ;;
 ;; Author:     Eduardo Ochs <eduardoochs@gmail.com>
 ;; Maintainer: Eduardo Ochs <eduardoochs@gmail.com>
-;; Version:    2020oct13
+;; Version:    2020oct30
 ;; Keywords:   e-scripts
 ;;
 ;; Latest version: <http://angg.twu.net/eev-current/eev-tlinks.el>
@@ -905,20 +905,76 @@ emacs    -fg bisque -bg black                  
eev-readme.el
 ;;;  |___/                                                
 ;;
 ;; «find-youtubedl-links»  (to ".find-youtubedl-links")
+;; Skel: (find-find-links-links-new "youtubedl" "dir title hash ext- stem" "")
+;; Test: (find-youtubedl-links nil nil "K6LmZ0A1s9U")
+;; See:  (find-audiovideo-intro "6. Youtube-dl")
+;;
+(defun find-youtubedl-links (&optional dir title hash ext- stem &rest 
pos-spec-list)
+"Visit a temporary buffer containing hyperlinks for youtube-dl."
+  (interactive)
+  (setq dir   (or dir   ee-youtubedl-dir "{dir}"))
+  (setq hash  (or hash  (ee-youtubedl-hash-around-point)    "{hash}"))
+  (setq title (or title (ee-youtubedl-guess-title dir hash) "{title}"))
+  (setq ext-  (or ext-  (ee-youtubedl-guess-ext- dir hash)  "{ext-}"))
+  (setq stem  (or stem "{stem}"))
+  (apply
+   'find-elinks
+   `((find-youtubedl-links ,dir ,title ,hash ,ext- ,stem ,@pos-spec-list)
+    (find-youtubedl-links ,dir nil ,hash nil ,stem)
+     ;; Convention: the first sexp always regenerates the buffer.
+     (find-efunction 'find-youtubedl-links)
+     ""
+     ,@(ee-youtubedl-dir-links nil hash stem)
+     (setq ee-youtubedl-dirs ',ee-youtubedl-dirs)
+     (setq ee-youtubedl-dir   ,ee-youtubedl-dir)
+     ""
+     ,(ee-template0 "\
+ (eepitch-shell2)
+ (eepitch-kill)
+ (eepitch-shell2)
+# http://www.youtube.com/watch?v={hash}
+# http://www.youtube.com/watch?v={hash}#t=0m00s
+# http://www.youtube.com/watch?v={hash}#t=0h00m00s
+cd {dir}
+{ee-youtubedl-command} -f 18 --restrict-filenames 
'http://www.youtube.com/watch?v={hash}'
+
+# Or:
+{ee-youtubedl-command}       'http://www.youtube.com/watch?v={hash}'
+{ee-youtubedl-command} -F    'http://www.youtube.com/watch?v={hash}'
+{ee-youtubedl-command} -f 18 'http://www.youtube.com/watch?v={hash}'
+{ee-youtubedl-command} -f 18 --restrict-filenames --all-subs 
'http://www.youtube.com/watch?v={hash}'
+{ee-youtubedl-command}       --restrict-filenames --all-subs 
'http://www.youtube.com/watch?v={hash}'
+
+# (find-es \"video\" \"youtube-dl\")
+# (find-fline \"{dir}\" \"{hash}\")
+# (find-fline \"{dir}\" \"{title}-{hash}\")
+# (find-fline \"{dir}\" \"{title}-{hash}{ext-}\")
+# (find-video \"{dir}{title}-{hash}{ext-}\")
+# (code-video \"{stem}video\" \"{dir}{title}-{hash}{ext-}\")
+# (find-{stem}video)
+# (find-{stem}video \"0:00\")
+
+# Error messages (for the player):
+# (find-ebuffer \"*Messages*\")
+")
+     )
+   pos-spec-list))
+
+
+
+
+;; `find-youtubedl-links' uses LOTS of internal functions and
+;; variables. They are defined below.
 
 ;; Code for splitting filenames of downloaded videos into components.
+;; Test: (ee-youtubedl-split "~/tmp/videos/foo_bar-abF7go7RLTc.flv")
+;;       --> ("~/tmp/videos/" "foo_bar" "abF7go7RLTc" ".flv" ".flv")
 ;;
 (defvar ee-youtubedl-ext-re
-  "\\(\\.[A-Za-z0-9]\\{2,5\\}\\)\\{0,2\\}$")
-
-(setq ee-youtubedl-ext-re
   "\\(\\.[A-Za-z0-9]\\{2,5\\}\\)\\(\\.part\\)?$")
 
 (defun ee-youtubedl-split (fname)
-"Split FNAME into (dir title hash ext).
-Example:
-\(ee-youtubedl-split \"~/tmp/videos/foo_bar-abF7go7RLTc.flv\")
-   --> (\"~/tmp/videos/\" \"foo_bar\" \"abF7go7RLTc\" \".flv\")"
+  "Split FNAME into (dir title hash ext ext-)."
   (string-match ee-youtubedl-ext-re fname)
   (let (dir title hash ext- ext dth dt)
     (setq ext-  (match-string 1 fname))
@@ -952,97 +1008,45 @@ Example:
 (defun ee-youtubedl-guess-title (dir hash) (ee-youtubedl-guess dir hash 1))
 (defun ee-youtubedl-guess-ext-  (dir hash) (ee-youtubedl-guess dir hash 3))
 
-;; The function `find-youtubedl-links' itself.
-;; It will try to guess "dir", "title", "hash", and "ext" if they are nil.
-;; Its ancestor: (find-angg ".emacs.templates" "find-youtubedl-links")
-;;
-(defvar ee-youtubedl-dir     "~/videos/")
-(defvar ee-youtubedl-dir2    "~/videos/tech/")
-(defvar ee-youtubedl-dir3    "/tmp/videos/")
-(defvar ee-youtubedl-dir4    "/tmp/")
-(defvar ee-youtubedl-command "youtube-dl -t")
-
 (defun ee-youtubedl-hash-around-point ()
   (let ((hash (ee-stuff-around-point "-0-9A-Za-z_")))
     (if (>= (length hash) 11)
        (substring hash -11))))
 
-;; Test: (find-youtubedl-links nil nil "K6LmZ0A1s9U")
+;; The option `-t' has been deprecated! =(
+;; When we run youtube-dl with `-t' it says:
+;;   WARNING: --title is deprecated. Use -o "%(title)s-%(id)s.%(ext)s" instead.
+;; See: (find-man "1 youtube-dl")
+;;      (find-man "1 youtube-dl" "\nOUTPUT TEMPLATE")
 ;;
-(defun find-youtubedl-links (&optional dir title hash ext- stem &rest rest)
-  "Visit a temporary buffer containing hyperlinks for youtube-dl."
-  (interactive)
-  (setq dir   (or dir   ee-youtubedl-dir "{dir}"))
-  (setq hash  (or hash  (ee-youtubedl-hash-around-point)    "{hash}"))
-  (setq title (or title (ee-youtubedl-guess-title dir hash) "{title}"))
-  (setq ext-   (or ext-   (ee-youtubedl-guess-ext-   dir hash) "{ext-}"))
-  (setq stem  (or stem "{stem}"))
-  (apply 'find-elinks `(
-    ;; Convention: the first sexp always regenerates the buffer.
-    (find-youtubedl-links ,dir ,title ,hash ,ext- ,stem)
-    (find-youtubedl-links ,dir nil ,hash nil ,stem)
-    ""
-    (find-youtubedl-links ,ee-youtubedl-dir  nil ,hash nil ,stem)
-    (find-youtubedl-links ,ee-youtubedl-dir2 nil ,hash nil ,stem)
-    (find-youtubedl-links ,ee-youtubedl-dir3 nil ,hash nil ,stem)
-    (find-youtubedl-links ,ee-youtubedl-dir4 nil ,hash nil ,stem)
-    (find-efunction 'find-youtubedl-links)
-    ;;
-    ;; (find-youtubedl-links ee-youtubedl-dir ,title ,hash ,ext- ,stem)
-    ;; (setq ee-youtubedl-dir ,ee-youtubedl-dir)
-    ""
-    (find-ydbgrep ,(format "grep --color -nH -e %s db.lua" hash))
-    ;;
-    ;; Body:
-    ""
-    ,(ee-template0 "\
- (eepitch-shell2)
- (eepitch-kill)
- (eepitch-shell2)
-# http://www.youtube.com/watch?v={hash}
-# http://www.youtube.com/watch?v={hash}#t=0m00s
-# http://www.youtube.com/watch?v={hash}#t=0h00m00s
-cd {dir}
-{ee-youtubedl-command} -f 18 --restrict-filenames 
'http://www.youtube.com/watch?v={hash}'
-
-# Or:
-{ee-youtubedl-command}       'http://www.youtube.com/watch?v={hash}'
-{ee-youtubedl-command} -F    'http://www.youtube.com/watch?v={hash}'
-{ee-youtubedl-command} -f 18 'http://www.youtube.com/watch?v={hash}'
-{ee-youtubedl-command} -f 18 --restrict-filenames --all-subs 
'http://www.youtube.com/watch?v={hash}'
-{ee-youtubedl-command}       --restrict-filenames --all-subs 
'http://www.youtube.com/watch?v={hash}'
+(defvar ee-youtubedl-command "youtube-dl -t")
 
-# (find-es \"video\" \"youtube-dl\")
-# (find-fline \"{dir}\" \"{hash}\")
-# (find-fline \"{dir}\" \"{title}-{hash}\")
-# (find-fline \"{dir}\" \"{title}-{hash}{ext-}\")
-# (find-video \"{dir}{title}-{hash}{ext-}\")
-# (find-video \"{dir}{title}-{hash}{ext-}.part\")
-# (code-video \"{stem}video\" \"{dir}{title}-{hash}{ext-}\")
-# (code-video \"{stem}video\" \"{dir}{title}-{hash}{ext-}.part\")
-# (find-{stem}video)
-# (find-{stem}video \"0:00\")
+;; The directories into which we usually download videos.
+;; Tests: (find-elinks (ee-youtubedl-dir-links))
+;;        (find-elinks (ee-youtubedl-dir-links '("DIR1" "DIR2")))
+;;        (let ((ee-youtubedl-dirs '("DIR1" "DIR2"))) (find-youtubedl-links))
+;;
+(defvar ee-youtubedl-dir "~/videos/")
 
-# Error messages (for the player):
-# (find-ebuffer \"*Messages*\")
-")
-    ) rest))
+(defvar ee-youtubedl-dirs
+  '("~/videos/" "~/videos/tech/" "/tmp/videos/" "/tmp/"))
 
+(defun ee-youtubedl-dir-links (&optional dirs hash stem)
+  (setq dirs (or dirs ee-youtubedl-dirs))
+  (setq hash (or hash "{hash}"))
+  (setq stem (or stem "{stem}"))
+  (mapcar (lambda (dir) `(find-youtubedl-links ,dir nil ,hash nil ,stem))
+         dirs))
 
-;; Bonus (2013sep10): play a local copy of a video from its URL.
-;; I need to document this!
+;; This is a hack (written in 2013sep10) that plays a local copy of a
+;; video from its URL. To easiest way to use it is to put the point on
+;; a youtube URL and type `M-x bryl'.
 ;;
 (defun ee-youtubedl-guess** (dirs hash)
   (apply 'append (mapcar (lambda (d) (ee-youtubedl-guess* d hash)) dirs)))
 
-(defun ee-youtubedl-dirs ()
-  (list ee-youtubedl-dir
-       ee-youtubedl-dir2
-       ee-youtubedl-dir3
-       ee-youtubedl-dir4))
-
 (defun ee-youtubedl-hash-to-fname (hash)
-  (and hash (car (ee-youtubedl-guess** (ee-youtubedl-dirs) hash))))
+  (and hash (car (ee-youtubedl-guess** ee-youtubedl-dirs hash))))
 
 (defun ee-youtubedl-url-to-hash (url)
   (if (and url (string-match "[&?]v=\\([^&?#]+\\)" url))
diff --git a/eev.el b/eev.el
index 6fdad76..eff0fd3 100644
--- a/eev.el
+++ b/eev.el
@@ -6,7 +6,7 @@
 ;; Package-Requires: ((emacs "24.1"))
 ;; Keywords: lisp e-scripts
 ;; URL: http://angg.twu.net/#eev
-;; Version: 20201022
+;; Version: 20201030
 
 ;; 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]