From 6782e70a83773b84b5dedc534f99e467f0118d20 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 20 Jan 2024 10:16:49 +1100 Subject: [emacs] minor updates to url-rewrite and my-ytdl - url-rewrite: also redirect from x.com for xitter - luwak: use url-rw for rewrite - ytdl: get rid of silly full-width chars and emojis in file names --- emacs/.emacs.d/lisp/my/my-org.el | 2 +- emacs/.emacs.d/lisp/my/my-ytdl.el | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'emacs/.emacs.d/lisp/my') diff --git a/emacs/.emacs.d/lisp/my/my-org.el b/emacs/.emacs.d/lisp/my/my-org.el index 00a8a0f..4fea460 100644 --- a/emacs/.emacs.d/lisp/my/my-org.el +++ b/emacs/.emacs.d/lisp/my/my-org.el @@ -895,7 +895,7 @@ On success, also move everything from staging to to-dir." (defun my-org-attach-url-plaintext-internal (url &optional no-tor move-if-large save-all-media) (let* ((lynx-buffer (format "*lynx %s*" url)) - (url (my-rewrite-url url)) + (url (url-rw url)) (filename (expand-file-name (my-make-filename-from-url url) (org-attach-dir t))) (coding-system-for-write 'utf-8)) diff --git a/emacs/.emacs.d/lisp/my/my-ytdl.el b/emacs/.emacs.d/lisp/my/my-ytdl.el index 0571682..e902722 100644 --- a/emacs/.emacs.d/lisp/my/my-ytdl.el +++ b/emacs/.emacs.d/lisp/my/my-ytdl.el @@ -30,10 +30,18 @@ (defvar my-ytdl-program "yt-dlp") (defvar my-ytdl-video-args - '("--download-archive" "yt-dlp-archive" "-o" -;; "%(id)s.%(ext)s" ;; for long names - "%(playlist|.)s/%(playlist_index|)s%(playlist_index&-|)s%(title)s.%(ext)s" - ;; https://github.com/yt-dlp/yt-dlp/issues/5630 + '("--download-archive" "yt-dlp-archive" + ;; Get rid of silly full-width chars and emojis + ;; https://old.reddit.com/r/youtubedl/comments/yz9ozo/how_do_i_get_ytdlp_downloads_without_forbidden/ + "--replace-in-metadata" "title" + "[\U0000002A\U0000005C\U0000002F\U0000003A\U00000022\U0000003F\U0000007C\U00010000-\U0010FFFF]" "_" + ;; truncate filename length, but it will not work with the + ;; following file name format, as it will replace the leading ./ + ;; with / + ;; "--trim-filenames" "200" + "-o" + "%(playlist|.)s/%(playlist_index|)s%(playlist_index&-|)s%(title)s.%(ext)s" ;; https://github.com/yt-dlp/yt-dlp/issues/5630 + ;; "%(id)s.%(ext)s" ;; alternative for long names "-f" "bv*[height<=?720]+ba/best[height<=?720]" "--write-subs" "--sub-langs" "en" "--write-description" @@ -43,8 +51,13 @@ "Directory for ytdl to download videos to.") (defvar my-ytdl-audio-args - '("-x" "--download-archive" "yt-dlp-archive" "-o" - ;; "%(id)s.%(ext)s" ;; for long names + '("-x" "--download-archive" "yt-dlp-archive" + ;; Get rid of silly full-width chars and emojis + ;; https://old.reddit.com/r/youtubedl/comments/yz9ozo/how_do_i_get_ytdlp_downloads_without_forbidden/ + "--replace-in-metadata" "title" + "[\U0000002A\U0000005C\U0000002F\U0000003A\U00000022\U0000003F\U0000007C\U00010000-\U0010FFFF]" "_" + "-o" + ;; "%(id)s.%(ext)s" ;; for long names "%(playlist|.)s/%(playlist_index|)s%(playlist_index&-|)s%(title)s.%(ext)s" "--write-description" "--write-thumbnail")) -- cgit v1.2.3