~yoctocell/peertube

13afb8a5521bfd662402aef09581b32c92be4736 — yoctocell 2 years ago 6ad6743
Add function to preview thumbnail
2 files changed, 18 insertions(+), 3 deletions(-)

M README.org
M peertube.el
M README.org => README.org +1 -1
@@ 26,8 26,8 @@
- [X] Change sorting method
- [X] Open channel link
- [X] Select resolution when downloading
- [X] Preview thumbnail
- [ ] Let users specify other fields
- [ ] Preview thumbnail
- [ ] Show more metadata
- [ ] Add to MELPA


M peertube.el => peertube.el +17 -2
@@ 237,6 237,19 @@ Format to thousands (K) or millions (M) if necessary."
  (let ((url (peertube-video-channelUrl (peertube--get-current-video))))
    (browse-url url)))

(defun peertube-preview-thumbnail ()
  "View the thumbnail of the current video."
  (interactive)
  (let ((url (peertube-video-thumbnailUrl (peertube--get-current-video)))
	(temp-file (make-temp-file "thumbnail")))
    (progn
      (call-process "curl" nil nil nil url "-o" temp-file)
      (find-file temp-file)
      ;; (ignore-errors
      ;; 	(rename-buffer "*peertube-thumbnail*"))
      ;; (kill-buffer (replace-regexp-in-string ".*/\\(.*$\\)" "\1" temp-file))
      (image-transform-set-scale 4))))

(defun peertube-change-sort-method ()
  "Change sorting method used for `peertube' and update the results buffer."
  (interactive)


@@ 270,7 283,8 @@ Format to thousands (K) or millions (M) if necessary."
  (views 0 :read-only t)
  (likes 0 :read-only t)
  (dislikes 0 :read-only t)
  (nsfw nil :read-only t))
  (nsfw nil :read-only t)
  (thumbnailUrl "" :read-only t))

(defun peertube--get-sort-method ()
  "Given a sorting method SORT, return the 'real' name of the method."


@@ 322,7 336,8 @@ parsed by `json-read'."
	       :views (assoc-default 'views v)
	       :likes (assoc-default 'likes v)
	       :dislikes (assoc-default 'dislikes v)
	       :nsfw (assoc-default 'nsfw v)))))
	       :nsfw (assoc-default 'nsfw v)
	       :thumbnailUrl (assoc-default 'thumbnailUrl v)))))
    videos))