diff options
author | Jesús <heckyel@hyperbola.info> | 2021-01-17 15:28:32 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-01-17 15:28:32 -0500 |
commit | 6d12908ab81e43b3a4b11a8a6e5b09ca5497a948 (patch) | |
tree | 89cd4b63bb45cb538aec4c3c817e5398c420d1d4 | |
parent | 15b2ecf65225449c5156251c616db982daf1150e (diff) | |
download | livie-6d12908ab81e43b3a4b11a8a6e5b09ca5497a948.tar.lz livie-6d12908ab81e43b3a4b11a8a6e5b09ca5497a948.tar.xz livie-6d12908ab81e43b3a4b11a8a6e5b09ca5497a948.zip |
Pretty code
-rw-r--r-- | livie-channel.el | 18 | ||||
-rw-r--r-- | livie-playlist.el | 2 | ||||
-rw-r--r-- | livie.el | 50 |
3 files changed, 35 insertions, 35 deletions
diff --git a/livie-channel.el b/livie-channel.el index ebf0e22..147a101 100644 --- a/livie-channel.el +++ b/livie-channel.el @@ -50,19 +50,19 @@ (defun livie--channel-query (uid n sort) "Query youtube for UID videos, return the Nth page of results, sorted bv SORT." (let ((videos (livie--API-call (concat "channels/videos/" uid) - `(("page" ,n) - ("sort_by" ,sort) - ("fields" ,livie-default-video-query-fields))))) + `(("page" ,n) + ("sort_by" ,sort) + ("fields" ,livie-default-video-query-fields))))) (dotimes (i (length videos)) (let ((v (aref videos i))) (aset videos i (livie-video--create :title (assoc-default 'title v) - :author (assoc-default 'author v) - :authorId (assoc-default 'authorId v) - :length (assoc-default 'lengthSeconds v) - :id (assoc-default 'videoId v) - :views (assoc-default 'viewCount v) - :published (assoc-default 'published v))))) + :author (assoc-default 'author v) + :authorId (assoc-default 'authorId v) + :length (assoc-default 'lengthSeconds v) + :id (assoc-default 'videoId v) + :views (assoc-default 'viewCount v) + :published (assoc-default 'published v))))) videos)) (defun livie-channel () diff --git a/livie-playlist.el b/livie-playlist.el index 5419b6c..cd0b9e0 100644 --- a/livie-playlist.el +++ b/livie-playlist.el @@ -105,7 +105,7 @@ (defun livie-playlist--query (playlistID page) "Query Invidious for videos from PLAYLISTID on PAGE." (let* ((results (livie--API-call (concat "playlists/" livie-playlistId) '(("fields" "videos") - ("page" ,livie-current-page))))) + ("page" ,livie-current-page))))) (setf livie-videos (livie--process-playlist-videos (assoc-default 'videos results))))) (defun livie--quit-playlist-buffer () @@ -59,16 +59,16 @@ :group 'livie) (defvar livie--insert-functions '((video . livie--insert-video) - (playlist . livie--insert-playlist) - (channel . livie--insert-channel))) + (playlist . livie--insert-playlist) + (channel . livie--insert-channel))) (defvar livie--default-action-functions '((video . livie--default-video-action) - (playlist . livie--default-playlist-action) - (channel . livie--default-channel-action)) + (playlist . livie--default-playlist-action) + (channel . livie--default-channel-action)) "Functions to call on an entry. To modify an action, set the appropiate variable instead.") (defvar livie--default-video-action #'(lambda () - (message (livie-video-title (livie-get-current-video)))) + (message (livie-video-title (livie-get-current-video)))) "Action to open a video. By default it just prints the title to the minibuffer.") (defvar livie--default-playlist-action #'livie--open-playlist @@ -383,7 +383,7 @@ too long)." "Switch to the next page of the current search. Redraw the buffer." (interactive) (setf livie-videos (livie--process-results (livie--query livie-search-term - (1+ livie-current-page)))) + (1+ livie-current-page)))) (setf livie-current-page (1+ livie-current-page)) (livie--draw-buffer)) @@ -392,7 +392,7 @@ too long)." (interactive) (when (> livie-current-page 1) (setf livie-videos (livie--process-results (livie--query livie-search-term - (1- livie-current-page)))) + (1- livie-current-page)))) (setf livie-current-page (1- livie-current-page)) (livie--draw-buffer))) @@ -533,7 +533,7 @@ If ARG is given, format it as a Invidious RSS feed." ;; Maybe type should be part of the struct. (cl-defstruct (livie-channel (:constructor livie-channel--create) - (:copier nil)) + (:copier nil)) "Information about a Youtube channel." (author "" :read-only t) (authorId "" :read-only t) @@ -541,7 +541,7 @@ If ARG is given, format it as a Invidious RSS feed." (videoCount 0 :read-only t)) (cl-defstruct (livie-playlist (:constructor livie-playlist--create) - (:copier nil)) + (:copier nil)) "Information about a Youtube playlist." (title "" :read-only t) (playlistId "" :read-only t) @@ -567,22 +567,22 @@ zero exit code otherwise the request body is parsed by `json-read' and returned. (json-read)))) (defun livie--query (string n) -"Query youtube for STRING, return the Nth page of results." -(let ((results (livie--API-call "search" `(("q" ,string) - ("sort_by" ,(symbol-name livie-sort-criterion)) - ("type" ,livie-type-of-results) - ("page" ,n) - ("fields" ,(pcase livie-type-of-results - ("video" livie-default-video-query-fields) - ("playlist" livie-default-playlist-query-fields) - ("channel" livie-default-channel-query-fields) - ;; I mean, it does get the job done... fix later. - ("all" (concat livie-default-channel-query-fields - "," - livie-default-playlist-query-fields - "," - livie-default-video-query-fields)))))))) - results)) + "Query youtube for STRING, return the Nth page of results." + (let ((results (livie--API-call "search" `(("q" ,string) + ("sort_by" ,(symbol-name livie-sort-criterion)) + ("type" ,livie-type-of-results) + ("page" ,n) + ("fields" ,(pcase livie-type-of-results + ("video" livie-default-video-query-fields) + ("playlist" livie-default-playlist-query-fields) + ("channel" livie-default-channel-query-fields) + ;; I mean, it does get the job done... fix later. + ("all" (concat livie-default-channel-query-fields + "," + livie-default-playlist-query-fields + "," + livie-default-video-query-fields)))))))) + results)) (defun livie--process-results (results &optional type) "Process RESULTS and turn them into objects, is TYPE is not given, get it from RESULTS." |