aboutsummaryrefslogtreecommitdiffstats
path: root/yeetube.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-08-17 05:47:21 +0300
committerThanos Apollo <[email protected]>2023-08-17 05:47:21 +0300
commite03b45def5d0646881d34fc966ee52a2c7c8ec16 (patch)
tree4f8f86c6c73b8f42415b0281ece5819c2ce0de68 /yeetube.el
parent9e2e7454c0d2238cf8a09f07495c9f9a62824abd (diff)
yeetube-get-content-youtube: get view-count
Diffstat (limited to 'yeetube.el')
-rw-r--r--yeetube.el62
1 files changed, 35 insertions, 27 deletions
diff --git a/yeetube.el b/yeetube.el
index 026ca73..28827d8 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -306,35 +306,43 @@ It's recommended you keep it as the default value."
;; yeetube-content
(let ((video-ids nil)
(video-titles nil))
- (while (and (< (length video-ids) yeetube-results-limit)
- (search-forward "videoId" nil t))
- (let* ((videoid-start (point))
- (videoid-end (search-forward ","))
- (videoid (buffer-substring
- (+ videoid-start 3)
- (- videoid-end 2))))
- (unless (or (member videoid video-ids)
- (not (and (>= (length videoid) 9)
- (<= (length videoid) 13)
- (string-match-p "^[a-zA-Z0-9_-]*$" videoid))))
- (push videoid video-ids)
- (search-forward "text")
- (let* ((title-start (point))
- (title-end (search-forward ",\""))
- (title (buffer-substring
- (+ title-start 3)
- (- title-end 5))))
- (if (string-match-p "vssLoggingContext" title)
- (pop video-ids)
- (push title video-titles)
- (push `(,videoid ,title) yeetube-content))))))))
+ (while (and (< (length video-ids) yeetube-results-limit)
+ (search-forward "videoId" nil t))
+ (let* ((videoid-start (point))
+ (videoid-end (search-forward ","))
+ (videoid (buffer-substring
+ (+ videoid-start 3)
+ (- videoid-end 2))))
+ (unless (or (member videoid video-ids)
+ (not (and (>= (length videoid) 9)
+ (<= (length videoid) 13)
+ (string-match-p "^[a-zA-Z0-9_-]*$" videoid))))
+ (push videoid video-ids)
+ (search-forward "text")
+ (let* ((title-start (point))
+ (title-end (search-forward ",\""))
+ (title (buffer-substring
+ (+ title-start 3)
+ (- title-end 5))))
+ (if (string-match-p "vssLoggingContext" title)
+ (pop video-ids)
+ (push title video-titles)
+ (search-forward "viewCountText")
+ (search-forward "text")
+ (let* ((view-count-start (point))
+ (view-count-end (search-forward " "))
+ (view-count (buffer-substring
+ (+ view-count-start 3)
+ (- view-count-end 1))))
+ ;; Don't remove this!
+ (search-backward "videoid")
+ ;; Just in case something gets messed
+ (if (string-match-p "text" view-count)
+ (push `(,videoid ,title "nil") yeetube-content)
+ (push `(,videoid ,title ,view-count) yeetube-content))))))))))
;; same as youtube but with different values, it's easier this way
-;; even though it's "wrong". It would be better if we could have a
-;; (yeetube-get-content (platform)) that depending on the platform value
-;; we could have different search-forward, videoid/title-start/end, in
-;; a way that would not require too much time to maintain. If you have
-;; any ideas feel free to email them.
+;; even though it's "wrong".
(defun yeetube-get-content-invidious ()
"Get content from an invidious instance."
(setq yeetube-content nil)