summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yeetube.el15
1 files changed, 14 insertions, 1 deletions
diff --git a/yeetube.el b/yeetube.el
index d928b9f..3e6e761 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -221,6 +221,18 @@ then for item."
("u0026" . "&")
("\\\\" . ""))
"Unicode character replacements.")
+
+;; Usually titles from youtube get messed up,
+;; This should fix some of the common issues.
+(defun yeetube---fix-title (title)
+ "Adjust TITLE."
+ (mapc (lambda (replacement)
+ (setf title (replace-regexp-in-string (car replacement) (cdr replacement) title)))
+ yeetube--title-replacements)
+ (if yeetube-buffer-display-emojis
+ title
+ (yeetube-buffer-strip-emojis title)))
+
(defun yeetube-get-content ()
"Get content from youtube."
(setf yeetube-content nil)
@@ -230,7 +242,8 @@ then for item."
(let ((videoid (buffer-substring (+ (point) 3) (- (search-forward ",") 2))))
(unless (member videoid (car yeetube-content))
(yeetube-get-item "title") ;; Video Title
- (let ((title (buffer-substring (+ (point) 3) (- (search-forward ",\"") 5))))
+ (let ((title (yeetube---fix-title
+ (buffer-substring (+ (point) 3) (- (search-forward ",\"") 5)))))
(unless (member title (car yeetube-content))
(yeetube-get-item "viewcounttext") ;; View Count
(let ((view-count (buffer-substring (+ (point) 3) (- (search-forward " ") 0))))