Magic-tape is an image supporting fuzzy finder command line interface YouTube client.
Downloading data is achieved with yt-dlp and cURL, while selections are achieved mainly with fzf.
Image support is achieved either with kitty terminal, ueberzugpp, ueberzug or chafa.
With magic-tape, through the main menu, the user can
-
Browse videos from subscriptions.
-
Browse videos suggested by YT algorithm.
-
Browse through trending video feed.
-
make a video search, using keywords or phrases.
-
Watch a previously watched video (watch history).
-
Browse videos from a subcsribed channel.
-
Watch a liked video.
-
Repeat the previous selection.
-
Repeat a previous search (search history).
-
Watch/download video/audio content, in various formats.
Through the miscellaneous menu the user can
-
Edit Preferences file (configuration).
-
Easily Update yt-dlp command (the driving force of this script).
-
Like / Unlike a video.
-
Synchronize the above actions with their YouTube account.
-
Import subscriptions from YouTube.
-
Subscribe to/ Unsubscribe from a channel.
-
Clear their watch/search history, liked videos, thumbnail cache.
Instructions on installing yt-dlp can be found here:
https://github.com/yt-dlp/yt-dlp#installation
Easily install yt-dlp using pip:
pip install yt-dlp
Other dependencies include:
- Bash (version >= 4.2)
Regarding image support, it can either be achived with
sudo apt install kitty
with
-
ueberzugpp (install instructions in the page)
Ueberzugpp works great with older hardware, where installing kitty is not an option.
with
sudo apt install chafa
or with
The ueberzug project has been archived. However, in order to install ueberzug
one can follow these steps:
- Install dependencies
sudo apt install libx11-dev libxres-dev libxext-dev
If during the installation process, errors appear due to absence of other depedencies, the user is encouraged to search the error message in the internet in order to locate the misssing dependency.
- Follow the install instructions found in this ueberzug fork:
git clone "https://github.com/gokberkgunes/ueberzug-tabbed.git"
cd ueberzug-tabbed
python -m pip install .
NOTE: One may need to call above pip install
commands as pip install --break-system-packages
to successfully install the packages.
To install these magic-tape.sh
dependencies, run the following command:
sudo apt install curl fzf mpv jq xclip
To install rofi
:
sudo apt install rofi
To install dmenu
:
sudo apt install dmenu
macOS has an outdated version of Bash (v3). You need to install the latest bash version using Homebrew:
brew install bash
Then install GNU utils used by the script (echo
, sed
, head
, tail
):
brew install gnu-sed coreutils
# Add this to your shellrc (.basrc, .zshrc, ...)
# Adapt to the location of your homebrew installation path.
export HOMEBREW_PREFIX=/opt/homebrew
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$HOMEBREW_PREFIX/opt/gnu-sed/libexec/gnubin:$PATH"
Finally install the remaining dependencies:
brew install curl fzf mpv jq yt-dlp
Clone the magic-tape
repo, and then get to the magic-tape/
directory:
git clone https://gitlab.com/christosangel/magic-tape.git
cd magic-tape/
Make install.sh
executable, then run it:
chmod +x install.sh&&./install.sh
That's it, the script is now installed.
To run the script from the same directory, run:
./magic-tape.sh
or from any directory, provided that ~/.local/bin/
is added to the $PATH:
magic-tape.sh
Through the P Option
in the Miscellaneous Menu
, the user can configure many pamaters of this script. The same can be equally well achieved by editing the ~/.config/magic-tape/magic-tape.conf
file, outside the script :
n | Variable | Explanation | Default Value | Acceptable Values |
---|---|---|---|---|
1 | PREF_SELECTOR |
Preferred selector is the program used to select actions | rofi |
dmenu rofi fzf |
2 | PREF_EDITOR |
Editor used to edit the configuration file | ${EDITOR-nano } |
nano, vim, gedit, xed, or any other terminal or graphical text editor |
3 | PREF_BROWSER |
Preferred browser is the browser the cookies of which are used to login to YouTube | firefox |
brave-browser-stable, chrome, chromium, edge, firefox, opera, vivaldi |
4 | LINK_BROWSER |
The browser to use to open links with | firefox |
Any Browser |
5 | LIST_LENGTH |
The length of the list of videos to choose from | 40 |
5 - 99 (the smaller the length, the faster the response) |
6 | TERMINAL_MESSAGE_DURATION |
Terminal message duration (sleep command) | 2 |
1 - 5 sec (or more, if you love sleeping) |
7 | COLORED_MESSAGES |
Tui messages in color | yes |
yes / no |
8 | NOTIFICATION_ENABLED |
Enable desktop notifications | yes |
yes / no |
9 | NOTIFICATION_DURATION |
Notification duration | 6000 |
1 - 10000 msec |
10 | IMAGE_SUPPORT |
Image support, the program used to render image previews in the terminal window. | ueberzug |
kitty ueberzugpp ueberzug chafa none |
11 | COMMENTS_TOGGLE |
Show comments and description in the terminal, while video is reproduced. | yes |
yes / no |
12 | COMMENTS_MAX |
Maximum comments number loaded. | 100 |
any number, or all for all comments. |
13 | COMMENTS_REPLIES_MAX |
Maximum comment replies, number of replies loaded per comment. (Further info:$ man yt-dlp ). |
5 |
any number, or all for all comment replies. |
14 | COMMENTS_SORT |
Comments sort method, the order in which comments are shown. Choose comment sorting mode(on YouTube's side). (Further info:$ man yt-dlp ). |
new |
new, old, top |
15 | PINNED_COMMENTS |
Show pinned comment (if any) as first or last in the comment section. | last |
first / last |
16 | SHOW_MPV_KEYBINDINGS |
Show mpv keybindings while playing | yes |
yes / no |
17 | DOWNLOAD_DIRECTORY |
Directory to download audio video into | /Downloads |
$HOME is the root directory, e.g. if you want to download your files in the Desktop directory, instead of $HOME/Desktop , just put /Desktop |
Finally, by editing the ~/.config/magic-tape/magic-tape.conf file
, the format of the preferred selector program can be also configured. However the user is advised to avoid such editing, unless they know what they are doing.
When the script is run for the first time, it would be advisable for the user to import their subcsribed channels from YouTube.
The user user can do that by navigating to the Miscellaneous Menu (option m), then selecting Import Subscriptions from YouTube (option I).
{height=300}then: {height=300}
Once the program is run, the user is presented with the Main Menu:
Entering the respective key, the user can :
key | Action |
---|---|
f | Browse their Subscriptions Feed. |
y | Browse YT algorithm Feed |
t | Browse YouTube Trending Feed. |
s | Search for a key word/phrase |
r | Repeat previous selection. |
c | Select a Subscribed Channel Feed. |
l | Browse Liked Videos. |
h | Browse Watch History. |
j | Browse Search History. |
m | Open Miscellaneous Menu. |
q | Quit the program. |
-
In order for the
f and y Options
to function, the user must already be logged in to YT in the browser. -
Selecting channel feed, Browsing watch history, search history & liked videos is done with
rofi
,fzf
ordmenu
:
{width=320} {width=320} {width=320} {width=320}
The user can search for a video using a keyword or phrase. Also the user can browse Search history and repeat a previous search.
There is now a duration filter prompt in the search and search history option:
Video selection is done with fzf:
Shortcut | Function |
---|---|
Enter, Right Arrow | Accept |
Esc | Abort Selection |
Shift+Right Arrow | Next Page |
Shift+Left Arrow | Previous Page |
Once a video is selected, the user is prompted to select action:
-
Play ⭐ Video 144p
-
Play ⭐⭐ Video 360p
-
Play ⭐⭐⭐ Video 720p
-
Play ⭐⭐⭐⭐ Best Video
-
Play ⭐⭐⭐⭐ Best Audio
-
Download Video 🔽
-
Download Audio 🔽
-
Like Video ❤️
-
Browse Feed of channel that uploaded the video 📺
-
Subscribe to the channel that uploaded the video 📋
-
Open in browser 🌐
-
Copy link 🔗
-
Quit ❌
{height=180} {height=180} {height=180}
While the video is reproduced, a shortcut cheatsheet will be printed to help the user control the mpv playing the video:
The m option of the Main Menu opens up the Miscellaneous Menu:
Entering the respective key, the user can :
key | Action |
---|---|
P | Set Up Preferences. |
Y | Update yt-dlp . |
l | LIKE a video. |
L | UNLIKE a video. |
I | Import subscriptions from YouTube. |
n | Subscribe to a new channel. |
u | Unsubscribe to a new channel. |
H | Clear watch history. |
S | Clear search history. |
T | Clear thumbnail cache. |
q | Quit this menu, Return to Main Menu. |
With a hit of a key (option Y in the Miscellaneous Menu), the user can update yt-dlp
command, and keep using it (and magic-tape) without any hiccups:
NOTICE: Updating yt-dlp
with this option works only when yt-dlp
has been installed using pip.
Selecting the n option of the Miscellaneous Menu, the user can subscribe to a new channel.
Initially, the user is asked to enter a keyword / keyphrase to search channels with.
Channel selection then is made with fzf:
- In the n & u options of the Miscellaneous Menu (subcribe/unsubscribe to a channel), after a selection, the user will be asked to sync the changes manually to their YouTube account.
Provided that the COMMENTS_TOGGLE
variable is configured to yes
in ~/.config/magic-tape/magic-tape.conf
file (default yes
), the video description as well as the comments written by YT viewers will be shown in the terminal window, while the video is reproduced.
{height=300} {height=300} {height=300}
Thus, the user can be satisfied reading other viewers having a swing at the politicians/celebrities/stars they love to hate, or, watch closely to their heart's content, as cyber nuclear attacks are launched between self-righteous, valiant and livid keyboard fighters.
The user can configure comments number, replies number and sorting, through three more variables in ~/.config/magic-tape/magic-tape.conf
file.
The user is also able to show pinned comments (if any) as first or last in the comment section.
Pinned comments will be marked accordingly and will be printed in different color to the other comments, in order to stand out.
Comment loading is asynchronous to video loading, so it is possible that there will be some delay in the appearence of the comments. That depends on the number of comments, network speed etc.
Also, it would be helpful to mention enabling limitless scrolling through your terminal emulator's preferences, in order not to miss a post in video with many many comments.
If the user runs the script with zsh
, the $SHELL
will be automatically exported to /bin/bash
. If any compatibility problrms arise, create an issue.
The vast majority of the issues mentioned, had only to do with:
If the user does't install properly the script, the script will not function. Proper installation is very easy, just one line command in the terminal.
In my experience, the best way to keep the driving force of this script, that is yt-dlp
up-to-date, one might:
- preferably install it with
pip
:
pip install yt-dlp
- Check regularly for updates, and update easily with one command:
python3 -m pip install -U "yt-dlp[default]"
- To make things easier, just hit Y and select Update yt-dlp option from within the Miscellaneous Menu.
yt-dlp
uses browser cookies to function properly. So, Before opening magic-tape, make sure that you log in to yt in your browser, and the right values arre assigned to PREF_BROWSER
and LINK_BROWSER
in the config file.
If the user takes notice of these few points, chances are the experience with magic-tape will be at least satisfactory.
Enjoy!