tube - Youtube CLI
tube is a Python script for extracting video metadata (I.E. the actual video stream URL) from an arbitrary Youtube (youtube.com, youtu.be) URL and then launch a player of choice (such as MPV or VLC) to watch the video.
In tube version 1.0.15, a rudimentary and experimental function for searching Youtube was added.
Together with tubeshell, a small bash script providing a readline-style shell for tube, it is an easy way of watching videos and handling tube's built-in history function, which stores previously watched videos.
tube does not handle Google accounts or API tokens, and it doesn't download the video stream - it simply facilitates viewing it. It is intended as a way of enjoying publicly available videos without the distraction of algorithmic content suggestions and autoplaying of suggested videos. A suitably pruned tube history will instead serve as a searchable library of interesting videos worth returning to and re-watching.
tube has been developed on and for Linux, but will probably work on other Unix-like systems as well. tube and tubeshell are both released under the MIT license. tube requires Python 3.5 to work and is linted with these settings. tubeshell is linted with shellcheck.
I surprised myself greatly with this little piece of software: since I wrote it, I have been using it (almost) every day, adding features and polishing the existing ones to my suit my personal preference. Perhaps someone else will find it useful, too.
The latest release is v1.1.0 (2020-12-23)
Simply pasting a video URL into tubeshell and hitting enter will suffice for watching it. Other than that, the following list of tubeshell commands should give a good overview of the features provided:
- search <keyword1> [<keyword2> ... <keywordN>] (Alias: s)
- Search Youtube for given keywords.
- list [<string>] (Aliases: ls, l)
- List the 100 latest viewed videos or, if supplied, search the complete history for <string>.
- listall (Aliases: lsa, la)
- List complete view history.
- listl [<string>] (Aliases: lsl, ll)
- List or search complete view history and display the result using less.
- hist <index> (Aliases: view, v, h)
- View video matching supplied history <index>.
- nohist <url> (Alias: nh)
- View video without writing to history, regardless of history settings.
- delhist <index1> [<idx2> ... <idxN>] | <idx1>-<idx2> | last (Aliases: rm, del)
- Delete videos matching indices or index range from history.
- geturl <index> (Aliases: gurl, gu)
- Recreate Youtube URL from video in history matching <index>.
Example tubeshell session, showing the search function.