aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/my/my-wget.el
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-06-17 17:20:29 +1000
committerYuchen Pei <id@ypei.org>2023-06-17 17:20:29 +1000
commit093ffa5fbf7143f4668bb0a3dc9659a5cc836e12 (patch)
tree1ed4e14b2a43b8e338f4ad6a04d969b99b9239be /.emacs.d/lisp/my/my-wget.el
parentabc686827ae38ee715d9eed1c5c29161c74127e6 (diff)
Moving things one level deeper
To ease gnu stow usage. Now we can do stow -t ~ emacs
Diffstat (limited to '.emacs.d/lisp/my/my-wget.el')
-rw-r--r--.emacs.d/lisp/my/my-wget.el79
1 files changed, 0 insertions, 79 deletions
diff --git a/.emacs.d/lisp/my/my-wget.el b/.emacs.d/lisp/my/my-wget.el
deleted file mode 100644
index 5349257..0000000
--- a/.emacs.d/lisp/my/my-wget.el
+++ /dev/null
@@ -1,79 +0,0 @@
-;;; my-wget.el -- Extensions for emacs-wget -*- lexical-binding: t -*-
-
-;; Copyright (C) 2023 Free Software Foundation.
-
-;; Author: Yuchen Pei <id@ypei.org>
-;; Package-Requires: ((emacs "28.2"))
-
-;; This file is part of dotfiles.
-
-;; dotfiles is free software: you can redistribute it and/or modify it under
-;; the terms of the GNU Affero General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; dotfiles 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 Affero General
-;; Public License for more details.
-
-;; You should have received a copy of the GNU Affero General Public
-;; License along with dotfiles. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Extensions for emacs-wget.
-
-;;; Code:
-
-
-;; wget
-(require 'wget)
-(require 'my-utils)
-(defvar my-wget-video-archive-directory)
-;; FIXME: this list is rather random...
-(setq my-wget-video-extensions '("mp4" "flv" "mkv" "webm" "ogv" "avi"
- "rmvb"))
-(defun my-wget-ensure-buffer-exists ()
- (get-buffer-create (or wget-process-buffer " *wget*")))
-(defun my-eww-wget-save-page ()
- (interactive)
- (my-wget-ensure-buffer-exists)
- (let* ((filename
- (concat (my-make-filename (plist-get eww-data :title)) ".html"))
- (full-path (concat wget-download-directory "/" filename)))
- (wget-uri (plist-get eww-data :url)
- wget-download-directory
- (list (concat "-O" filename)))
- (kill-new full-path)
- (message "Saved webpage to %s (path copied)." full-path)))
-
-(defun my-wget-async (url filename &optional no-tor move-if-video-or-large)
- (set-process-sentinel
- (my-start-process-with-torsocks
- no-tor "wget" "*wget*" "wget" url "-c" "-O" filename)
- (lambda (_process _event)
- (when (and move-if-video-or-large
- (or
- (> (file-attribute-size (file-attributes filename))
- my-wget-size-threshold)
- (member (file-name-extension filename) my-wget-video-extensions)))
- (setq filename
- (my-rename-and-symlink-back
- filename (expand-file-name my-wget-video-archive-directory) nil)))
- (message "Fetched %s and saved to: %s" url filename))))
-
-(defun wget-async-urls-with-prefix (urls prefix &optional no-tor move-if-video-or-large)
- (let ((i 1))
- (dolist (url urls)
- (my-wget-async
- url
- (concat prefix
- (make-string (- 4 (length (number-to-string i))) ?0)
- (number-to-string i)
- "." (file-name-extension url))
- no-tor move-if-video-or-large)
- (setq i (1+ i)))))
-
-(provide 'my-wget)
-;;; my-wget.el ends here