summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-07-20 14:30:57 +0300
committerThanos Apollo <[email protected]>2023-07-20 14:30:57 +0300
commitbd82655687325f159fcfc74e97ca854ee772aa65 (patch)
tree474cafcfb46dc4d3c9f6b6d14c3df2b754c63efc
parent18edc10a1aff1348d26c9d6b480f5f72940b78bf (diff)
yeetube-fix-title: Adjustments
Since uusing decode-region 'utf-8 does not fix much, I guess yeetube-fix-title is here to stay. Rewrote this and added adjustments for u0026 - '&'
-rw-r--r--yeetube.el14
1 files changed, 10 insertions, 4 deletions
diff --git a/yeetube.el b/yeetube.el
index 3e1f531..9a7ae01 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -159,12 +159,18 @@ It's recommended you keep it as the default value."
(message "mpv play/pause"))
(error "To use this function you need to have mpv installed & set yeetube-player to the default value")))
-;; this is a quick "duck-tape" fix.
+;; Usually titles from youtube get messed up,
+;; This should be fix some of the common issues.
(defun yeetube-fix-title (title)
"Adjust TITLE."
- (replace-regexp-in-string "&amp;" "&"
- (replace-regexp-in-string "&quot;" "\""
- (replace-regexp-in-string "&#39;" "'" title))))
+ (let ((replacements '(("&amp;" . "&")
+ ("&quot;" . "\"")
+ ("&#39;" . "'")
+ ("u0026" . "&"))))
+ (mapc (lambda (replacement)
+ (setq title (replace-regexp-in-string (car replacement) (cdr replacement) title)))
+ replacements)
+ title))
(defun yeetube-insert-content (prefix url video-titles video-ids)
"Insert video links with titles into the buffer.