Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
540 B

  1. #!/bin/sh
  2. format="-f34" # leave empty for default
  3. player="mpv --quiet --geometry=50%:50% --idx --keep-open"
  4. tmpdir="/tmp"
  5. url="$1"
  6. echo $url
  7. echo $format
  8. filepath="$tmpdir/$(youtube-dl --id --get-filename $format $url)"
  9. youtube-dl -c -o $filepath $format $url &
  10. echo $! > $filepath.$$.pid
  11. while [ ! -r $filepath ] && [ ! -r $filepath.part ]; do
  12. echo "Waiting for youtube-dl..."
  13. sleep 3
  14. done
  15. [ -r $filepath.part ] && $player $filepath.part || $player $filepath
  16. kill $(cat $filepath.$$.pid)
  17. rm $filepath.$$.pid