summaryrefslogtreecommitdiff
path: root/yeetube.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2025-01-17 03:12:31 +0200
committerThanos Apollo <[email protected]>2025-01-17 03:12:31 +0200
commitfe4f8aea45c0ba9a6facb3c2146ddd887a63c7dc (patch)
treea7a2528603bd02d7af4acb2faed89d1108e56ba5 /yeetube.el
parent2fb3788100b6d7210ada9d45d660b7f3ba6e6c44 (diff)
get-content: Rewrite entry format.
* Rewrite entry format as a tabulated list entry with proper faces. * Minor scraping adjustments.
Diffstat (limited to 'yeetube.el')
-rw-r--r--yeetube.el56
1 files changed, 31 insertions, 25 deletions
diff --git a/yeetube.el b/yeetube.el
index afcfcb3..650ede0 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -493,46 +493,52 @@ Image is inserted in BUFFER for ENTRY."
(push id ids)
(save-excursion
;; Scrape necessary data and push to list of contents
- (let ((title (yeetube--scrape-string pos "title" (if videop "text" "simpleText")))
- (view-count (when videop (yeetube--scrape-string pos "viewCountText" "simpleText")))
+ (let ((title (yeetube--scrape-string pos "title"
+ (if videop "text"
+ "simpleText")))
+ (view-count (when videop
+ (yeetube--scrape-string pos "viewCountText" "simpleText")))
(duration (if videop
(yeetube--scrape-string pos "lengthText" "simpleText")
- (format "%s videos" (yeetube--scrape-string pos "videoCount"))))
+ (format "%s videos"
+ (yeetube--scrape-string pos "videoCount"))))
(channel (yeetube--scrape-string pos "longBylineText" "text"))
(channel-id (yeetube--scrape-string pos "canonicalBaseUrl"))
(thumbnail (yeetube--scrape-string pos "thumbnail" "url"))
- (date (when videop (yeetube--scrape-string pos "publishedTimeText" "simpleText")))
- (entry nil))
+ (date (when videop
+ (yeetube--scrape-string pos "publishedTimeText" "simpleText")))
+ (entry))
(when (string= channel title) (setf channel yeetube--channel-id))
(setq thumbnail (string-replace
"hq720" "default"
(substring thumbnail 0 (string-search "?" thumbnail))))
+ ;; Create an entry with properties.
(setq entry
- (list :title (if videop title (concat "Playlist: " title))
- :type (if videop 'video 'playlist)
- :id id
- :view-count (yeetube-view-count-format (or view-count ""))
- :duration duration
- :channel (propertize channel :channel-id channel-id)
- :thumbnail thumbnail
- :date (string-replace "Streamed " "" (or date ""))
- :image (if yeetube-display-thumbnails
- (format "[[%s.jpg]]" id)
- "disabled")))
- (yeetube--retrieve-thumnail thumbnail entry "*yeetube*")
- (push entry yeetube-content))))))
+ (list id
+ (format "[[%s.jpg]]" id)
+ (propertize
+ (if videop title (concat "Playlist: " title))
+ 'face 'yeetube-face-title)
+ (propertize
+ (yeetube-view-count-format (or view-count ""))
+ 'face 'yeetube-face-view-count)
+ (propertize duration 'face 'yeetube-face-duration)
+ (propertize (string-replace "Streamed " "" (or date ""))
+ 'face 'yeetube-face-date)
+ (propertize channel 'face 'yeetube-face-channel)
+ channel-id
+ (if videop 'video 'playlist)))
+ (yeetube--retrieve-thumbnail thumbnail entry "*yeetube*")
+ ;; Push entry in a format to be used with tabulated-list
+ (push (list (car entry) (if yeetube-display-thumbnails-p
+ (vconcat (cdr entry))
+ (vconcat (cddr entry))))
+ yeetube-content))))))
;; Reverse the list of entries before returning
(cl-callf nreverse yeetube-content))
(add-variable-watcher 'yeetube-saved-videos #'yeetube-update-saved-videos-list)
-;; View thumbnail using eww
-(defun yeetube-view-thumbnail ()
- "Open URL using eww in a new buffer."
- (interactive)
- (eww-browse-url (yeetube-get :thumbnail)))
-
-
;; Yeetube Downlaod:
(defvar yeetube-ytdlp (executable-find "yt-dlp")