Last active
January 16, 2016 02:54
-
-
Save ayosec/83c87765aa46d227edb8 to your computer and use it in GitHub Desktop.
mpv with bestaudio/bestvideo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
URL = ARGV.first || raise("Missing video URL") | |
audio = IO.popen(["youtube-dl", "-f", "bestaudio", "-g", URL]) | |
video = IO.popen(["youtube-dl", "-f", "bestvideo", "-g", URL]) | |
title = IO.popen(["youtube-dl", "-e", URL]) | |
audio_url = audio.read.chomp | |
video_url = video.read.chomp | |
window_title = title.read.chomp | |
[audio, video, title].each {|cmd| Process.waitpid(cmd.pid) } | |
puts "\033[1m#{window_title}\033[m" | |
exec( | |
"mpv", | |
"--no-ytdl", | |
"--cache-secs=45", | |
"--title", window_title, | |
"--audio-file=#{audio_url}", | |
video_url | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias mpv-yt-bests='mpv --cache-secs=45 --ytdl-format=bestvideo+bestaudio' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment