;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\305\306\307\310\311\312%\210\313\314\307\315\316\317\311\306&\210\313\320\321\322\316\323\311\320&\210\313\324\325\326\316\327\311\306&\210\313\330\331\332\316\333\311\306&\207" [require cl-lib ivy request json custom-declare-group ivy-youtube nil "Ivy-youtube settings." :group tools custom-declare-variable ivy-youtube-key "Your Google API key." :type (string) ivy-youtube-play-at "browser" "Where do you want to play the video. You can set browser or process." (string) ivy-youtube-history-file (format "%sivy-youtube-history" user-emacs-directory) "History file for your searches.\n\nIf nil then don't keep a search history" (string) ivy-youtube-max-results 50 "The max amount of results displayed after search\n\nIncreasing this value too much might result in getting connection errors" (integer)] 8) #@47 Return a list of lines of a file at FILEPATH. (defalias 'ivy-youtube-read-lines #[(filePath) "\302\303\304\"rq\210\305\216\306 !\210\307\310 \311\304#+\207" [#1=#:temp-buffer filePath generate-new-buffer " *temp*" t #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] insert-file-contents split-string buffer-string "\n"] 4 (#$ . 963)]) #@54 Return a list with content of file or an empty list. (defalias 'ivy-youtube-history-list #[nil "\205 \301!\205 \302!\207" [ivy-youtube-history-file file-readable-p ivy-youtube-read-lines] 2 (#$ . 1320)]) (defalias 'ivy-youtube #[nil "\204\302\303!\210\304\305\306\307\310\311 B\312\313\314 !B\315B\257\316\317\320\321\322\323\324\325\326!& \207" [ivy-youtube-key ivy-youtube-max-results error "You must set `ivy-youtube-key' to use this command" request "https://www.googleapis.com/youtube/v3/search" :params ("part" . "snippet") "q" ivy-youtube-search ("type" . "video") "maxResults" int-to-string "key" :parser json-read :success #[(&rest #1=#:--cl-rest--) "\302\303\"A@\304 !)\207" [#1# data plist-member :data ivy-youtube-wrapper] 3 "\n\n(fn &key DATA &allow-other-keys)"] :status-code ((400 lambda (&rest _) (message "Got 400.")) (418 lambda (&rest _) (message "Got 418.")) (403 lambda (&rest _) (message "403: Unauthorized. Maybe you need to enable your youtube api key"))) :complete message "searching..."] 13 nil nil]) #@55 Build the tree-assoc from KEY TREE for youtube query. (defalias 'ivy-youtube-tree-assoc #[(key tree) ":\2052\211\203 \211A\242\202\304\305\306 GD\"\307\n \"\203&\2021\310 \n\"\2061\310 \"*\207" [tree y x key signal wrong-number-of-arguments (x . y) eql ivy-youtube-tree-assoc] 5 (#$ . 2365)]) #@39 Play the video based on users choice. (defalias 'ivy-youtube-playvideo #[(video-url) "\302\267\202\303 !\207\303 !\207\303 !\207\304 !\207" [ivy-youtube-play-at video-url #s(hash-table size 3 test equal rehash-size 1.5 rehash-threshold 0.8125 purecopy t data ("browser" 6 nil 10 "" 14)) ivy-youtube-play-on-browser ivy-youtube-play-on-process] 2 (#$ . 2679)]) #@35 Open your browser with VIDEO-URL. (defalias 'ivy-youtube-play-on-browser #[(video-url) "\301\302!\210\303!\207" [video-url message "Opening your video on browser..." browse-url] 2 (#$ . 3048)]) #@74 Start a process based on ivy-youtube-play-at variable passing VIDEO-URL. (defalias 'ivy-youtube-play-on-process #[(video-url) "\302\303\304 #!\210\305\306\307\310\311\312\313\314 D&\207" [ivy-youtube-play-at video-url message format "Starting a process with: [%s %s]" make-process :name "Ivy Youtube" :buffer "*Ivy Youtube Output*" :sentinel #[(process event) "\301\302\303\"!\207" [event message format "Ivy Youtube: Process %s (Check buffer *Ivy Youtube Output*)"] 4] :command] 10 (#$ . 3249)]) #@44 Create a usable youtube URL with VIDEO-ID. (defalias 'ivy-youtube-build-url #[(video-id) "\301P\207" [video-id "http://www.youtube.com/watch?v="] 2 (#$ . 3756)]) #@72 Parse the json provided by *QQJSON* and provide search result targets. (defalias 'ivy-youtube-wrapper #[(*qqJson*) "\306\211\307\310\n\"A\211G\311\f W\203.\307\312 \fH\"A\307\313 \fH\"AB B\fT\211\202+\314\315\316 !\317\320$*\207" [quote results *qqJson* search-results i --dotimes-limit-- nil ivy-youtube-tree-assoc items 0 title videoId ivy-read "Youtube Search Results" reverse :action #[(cand) "\301\302A!!\207" [cand ivy-youtube-playvideo ivy-youtube-build-url] 3]] 6 (#$ . 3925)]) #@45 Use ivy-read to select your search history. (defalias 'ivy-youtube-search #[nil "\300\301\302 \303\304$\207" [ivy-read "Search YouTube: " ivy-youtube-history-list :action #[(cand) "\301!\207" [cand ivy-youtube-append-history] 2]] 5 (#$ . 4428)]) #@45 Save the new CANDIDATE to the history file. (defalias 'ivy-youtube-append-history #[(candidate) "\205)\305 \n \235\203 \202\n B\211\306\307\310 !\"\311\312\313\f\314#\307\307$+\207" [ivy-youtube-history-file history-words candidate history-words-with-candidate unique-words ivy-youtube-history-list delq nil delete-dups write-region mapconcat identity "\n"] 5 (#$ . 4681)]) (provide 'ivy-youtube)