Skip to content

Instantly share code, notes, and snippets.

@louisswarren
Last active May 11, 2017 23:10
Show Gist options
  • Save louisswarren/723be8a02f1286b4a8499f19857d326a to your computer and use it in GitHub Desktop.
Save louisswarren/723be8a02f1286b4a8499f19857d326a to your computer and use it in GitHub Desktop.
Play audio from a youtube search in the terminal
#!/usr/bin/env python3
from os import system
from sys import argv
# Example:
# youtube-terminal.py foo bar baz
# calls youtube-dl 'ytsearch:foo bar baz' --max-downloads 1 -o - | cvlc - --no-video
call_str = 'youtube-dl "ytsearch:{}" --max-downloads 1 -o -'
call_str += ' | cvlc - --no-video --play-and-exit'
system(call_str.format(' '.join(argv[1:])))
@louisswarren
Copy link
Author

I wanted to do this in bash but it wasn't working for some reason. Why doesn't

youtube-dl "ytsearch:$@" --max-downloads 1 -o - | cvlc - --no-video

work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment