Skip to content

spiderbit/ytdious

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ytdious

ytdious is an experimental YouTube "frontend" for Emacs. You can search and list YouTube videos sort them and play them either one by one or continiously. ytdious can be used to launch operations on videos with external tools, to learn how to do that refer to the usage section below.

demonstration

This project uses the Invidious API.

Installation

This project is on MELPA: you should be able to M-x package-install RET ytdious. Another option is to clone this repository under your load-path.

Dependencies

While ytdious does not depend on any Emacs package it does depend on curl so, if you happen not to have it, install it through your package manager (meme distros aside it is probably in your repos).

Usage

Once everything is loaded M-x ytdious creates a new buffer and puts it in ytdious-mode. This major mode has just a few bindings (for now):

key binding
q ytdious-quit
d ytdious-rotate-date
D ytdious-rotate-date-backwards
r ytdious-rotate-sort
R ytdious-rotate-sort-backwards
o ytdious-toggle-sort-direction
t ytdious-display-full-title
s ytdious-search
S ytdious-search-recent
c ytdious-view-channel
C ytdious-view-channel-at-point
> ytdious-search-next-page
< ytdious-search-previous-page
RET ytdious-play
C-return ytdious-play-continiously
C-escape ytdious-stop-continiously

Pressing s will prompt for some search terms or c for a channel name ** and populate the buffer once the results are available. One can access information about a video via the function ytdious-get-current-video that returns the video at point. ** channel name can't include spaces but you can use the UCID

You can create a buffer or file with content like that with a optional date limiter:

Linux date:week
Emacs date:today

mark a line and start ytdious-region-search on them, so that you don't have to remember and don't have to manually input all your searches. Also you can keep open 1 buffer per search and operate them in parralel.

You can implement a function to stream a video in mpv (provided you have youtube-dl installed) as follows:

(defun ytdious-watch ()
    "Stream video at point in mpv."
    (interactive)
    (let* ((video (ytdious-get-current-video))
     	   (id    (ytdious-video-id-fun video)))
      (start-process "ytdious mpv" nil
		     "mpv"
		     (concat "https://www.youtube.com/watch?v=" id))
		     "--ytdl-format=bestvideo[height<=?720]+bestaudio/best")
      (message "Starting streaming..."))

And bind it to a key in ytdious-mode with

(define-key ytdious-mode-map "y" #'ytdious-watch)

This is of course just an example. You can similarly implement functions to:

  • open a video in the browser,
  • download a video,
  • download just the audio of a video,

by relying on the correct external tool.

It is also possible to customize the sorting criterion of the results by setting the variable ytdious-sort-criterion to one of the following symbols relevance, rating, upload_date or view_count. The default value is relevance.

Potential problems and potential fixes

ytdious does not use the official YouTube APIs but relies on the Invidious APIs (that in turn circumvent YouTube ones). The variable ytdious-invidious-api-url points to the invidious instance (by default https://invidio.us) to use, this server is not up anymore therefor you have to choose another instance. Sometimes ytdious might hang; in that case C-g and retry.

Contributing

Feel free to open an issue or send a pull request, help is appreciated. To prevent redundant work I suggest to give me a heads up first, I don't always push out changes for immediately till I am happy with the quality and have it tested for a while, I could add then a TODO list or we can coordinate through bug reports.

FAQ

Why?

One can easily subscribe to YouTube channels via an RSS feed and access it in Emacs via elfeed but sometimes I want to search YouTube for videos of people I don't necessarily follow (e.g. for searching a tutorial, or music, or wasting some good time) and being able to do that without switching to a browser is nice.

What about helm-youtube and ivy-youtube?

First of all those packages require you to get a Google API key, while ytdious uses the Invidious APIs that in turn do not use the official Google APIs.

Moreover those packages are designed to select a YouTube search result and play it directly in your browser while ytdious is really a way to collect search results in an elfeed-like buffer and make them accessible to the user via functions such as ytdious-get-current-video so the user gets to decide what to to with them.

About

Youtube "front-end" for Emacs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Emacs Lisp 100.0%