Create a mirror-img system and package

This commit is contained in:
Jaidyn Ann 2024-05-24 20:58:37 -05:00
parent 8cbb3e338d
commit 7c6eb4d19c
2 changed files with 13 additions and 2 deletions

6
mirror-img.asd Normal file
View File

@ -0,0 +1,6 @@
(defsystem "mirror-img"
:version "0.1"
:license "GPLv3"
:author "Jaidyn Ann <jadedctrl@posteo.at>"
:depends-on (lquery dexador split-sequence)
:components ((:file "mirror-img")))

View File

@ -13,14 +13,19 @@
;; You should have received a copy of the GNU General Public License ;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(defpackage :mirror-img
(:use :cl)
(:export :mirror-img))
(in-package :mirror-img)
(defvar *src-tags* '("audio" "embed" "img" "input" "script" "source" "track" "video")) (defvar *src-tags* '("audio" "embed" "img" "input" "script" "source" "track" "video"))
(defvar *href-tags* '("link")) (defvar *href-tags* '("link"))
;;; Mirror-img ;;; Mirror-img
;;; ———————————————————————————————————————— ;;; ————————————————————————————————————————
(defun mirror-remote-urls (html-file base-dir &optional (tags '("img"))) (defun mirror-img (html-file base-dir &optional (tags '("img")))
"Attempt to mirror all remote HREF/SRC URLs of an HTML files tags, "Attempt to mirror all remote HREF/SRC URLs of an HTML files tags,
downloading them to base-dir. The remote URLs will be replaced with the downloading them to base-dir. The remote URLs will be replaced with the
local version, where downloading was successful. local version, where downloading was successful.