aboutsummaryrefslogtreecommitdiffstats
path: root/yeetube.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-01-09 20:56:08 +0200
committerThanos Apollo <[email protected]>2024-01-09 20:56:31 +0200
commitaf874221aea1ef6e427a281096edbc7b2caad77e (patch)
treef6931d7ca6697f0ba474d5eceb458f655cb0e163 /yeetube.el
parent5a173df634c385fb87f6a4e873949ad8efb13c82 (diff)
Add yeetube-view-count-format
Diffstat (limited to 'yeetube.el')
-rw-r--r--yeetube.el13
1 files changed, 12 insertions, 1 deletions
diff --git a/yeetube.el b/yeetube.el
index d0bac18..604575f 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -248,6 +248,17 @@ then for item."
("\\\\" . ""))
"Unicode character replacements.")
+(defun yeetube-view-count-format (string)
+ "Add commas for STRING."
+ (let* ((string (replace-regexp-in-string "[^0-9]" "" string))
+ (len (length string))
+ (result ""))
+ (cl-loop for i from 0 to (1- len)
+ do (setf result (concat (substring string (- len i 1) (- len i)) result))
+ if (and (> (- len (1+ i)) 0)
+ (= (% (1+ i) 3) 0))
+ do (setf result (concat "," result)))
+ result))
(defun yeetube-get-content ()
"Get content from youtube."
@@ -273,7 +284,7 @@ then for item."
(- (search-forward ",") 2))))
(push (list :title title
:videoid videoid
- :view-count (format "% 10s" (replace-regexp-in-string "[^0-9]" "" view-count))
+ :view-count (yeetube-view-count-format view-count)
:duration video-duration
:channel channel)
yeetube-content))))))))))