summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-10-14 16:21:41 +0300
committerThanos Apollo <[email protected]>2023-10-17 09:24:22 +0300
commitfbf3a9309e52913fc80e5a82a292ff75e54c5068 (patch)
tree54ad44bf9ad569b03c6faf12668a74a81964ca39
parent8e8985293ea73e15637f10a4c40c05b4cbbca97e (diff)
yeetube: Add yeetube--fix-title
- Function that fixes scraped titles - Use in yeetube-get-content to push correct title values to yeetube-content
-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))))