Ytdl: Add patch to support Tor.

master
Pierre Neidhardt 2021-02-25 18:24:44 +01:00
parent 491f6f6fbb
commit a112e1ac13
2 changed files with 35 additions and 1 deletions

View File

@ -419,7 +419,13 @@
(with-eval-after-load 'ytdl
(setq ytdl-always-query-default-filename 'yes)
(setq ytdl-max-mini-buffer-download-type-entries 0)
(setq ytdl-download-extra-args '("-f" "best")))
(setq ytdl-download-extra-args '("-f" "best"))
(require 'patch-ytdl)
(defun ytdl-no-proxy ()
(interactive)
(let ((ytdl-download-extra-args (cons "--proxy="
ytdl-download-extra-args)))
(ytdl-download))))
(with-eval-after-load 'ztree
(set-face-foreground 'ztreep-diff-model-add-face "deep sky blue"))

View File

@ -0,0 +1,28 @@
(defun ytdl--get-default-filename (url)
"Get default filename from web server.
Query the default-filename of URL using '--get-filename' argument
of ytdl."
(if (equal ytdl-always-query-default-filename
'never)
nil
(with-temp-buffer
(apply #'call-process ytdl-command nil t nil
(append ytdl-download-extra-args
(list
"--get-filename"
"--restrict-filenames"
"--" url)))
(goto-char (point-min))
(if (search-forward-regexp "^ERROR" nil t)
(progn
(beginning-of-line)
(error (buffer-substring-no-properties (line-beginning-position)
(line-end-position))))
(search-forward ".")
(replace-regexp-in-string "/\\|_"
"-"
(buffer-substring-no-properties (line-beginning-position)
(1- (point))))))))
(provide 'patch-ytdl)