diff options
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-wget.el')
| -rw-r--r-- | emacs/.emacs.d/lisp/my/my-wget.el | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-wget.el b/emacs/.emacs.d/lisp/my/my-wget.el index e7283aa..f3f6771 100644 --- a/emacs/.emacs.d/lisp/my/my-wget.el +++ b/emacs/.emacs.d/lisp/my/my-wget.el @@ -30,6 +30,7 @@ ;; wget (require 'wget) (require 'my-utils) +(require 'tor) (defvar my-wget-video-archive-directory) ;; FIXME: this list is rather random... (setq my-wget-video-extensions '("mp4" "flv" "mkv" "webm" "ogv" "avi" @@ -53,8 +54,7 @@ (my-start-process-with-torsocks no-tor "wget" "*wget*" "wget" url "-c" "-O" filename) (lambda (proc event) - (let ((ps (process-status proc)) - (status (process-exit-status proc))) + (let ((status (process-exit-status proc))) (if (eq status 0) (progn (message "[DONE] Fetched %s to %s" url filename) @@ -86,5 +86,22 @@ no-tor move-if-video-or-large) (setq i (1+ i))))) +(defun my-wget-out-internal (url buffer-processor &optional no-tor) + "Run wget on url, dump the results in a temp buffer, then apply BUFFER-PROCESSOR" + (with-temp-buffer + (my-call-process-with-torsocks no-tor "wget" nil '(t nil) nil "-O" "-" url) + (call-interactively 'delete-trailing-whitespace) + (funcall buffer-processor) + )) + +(defun my-wget-dom (url &optional no-tor) + (my-wget-out-internal + url + (lambda () (libxml-parse-html-region (point-min) (point-max))) + no-tor)) + +(defun my-wget-raw (url &optional no-tor) + (my-wget-out-internal url 'buffer-string no-tor)) + (provide 'my-wget) ;;; my-wget.el ends here |
