yt.py

Logo

Play or download YouTube videos from the terminal

View the Project on GitHub cybardev/ytpy

yt.py

A Python script to play media from YouTube without needing API keys

Sections

Click to navigate.

Dependencies

Installation

Usage

usage: yt.py [-h] [-u] [-v] [-d] [-n NUM] [-o DIR] [SEARCH_STRING ...]

Play YouTube media without API

positional arguments:
  SEARCH_STRING         media to play

options:
  -h, --help            show this help message and exit
  -u, --url             display URL instead of playing
  -v, --video           play video instead of music
  -d, --download        download media instead of playing
  -n NUM, --num NUM     nth result to play or download
  -o DIR, --output DIR  folder to save downloaded media

List of mpv hotkeys: https://defkey.com/mpv-media-player-shortcuts

Examples

PS: Here’s a list of mpv keyboard shortcuts for your convenience.

Credits

Extras

About the .pyx file

I’m currently not updating it anymore. Please consider using the .py file instead

Cython is supposed to be faster but I don’t really know Cython so I couldn’t optimize it as well. If you can do so, feel free to make a fork, and maybe even a pull request so the script can be improved. It’ll be a learning experience for me as well.

As for the performance… It may be slightly faster but the program is still network-bound. Which means, faster internet = faster query = media is played sooner.

Compile an executable file using this shell script if you want.