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.

23 lines
556 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. mpv $url
  9. exit 0
  10. filepath="$tmpdir/$(youtube-dl --id --get-filename $format $url)"
  11. youtube-dl -c -o $filepath $format $url &
  12. echo $! > $filepath.$$.pid
  13. while [ ! -r $filepath ] && [ ! -r $filepath.part ]; do
  14. echo "Waiting for youtube-dl..."
  15. sleep 3
  16. done
  17. [ -r $filepath.part ] && $player $filepath.part || $player $filepath
  18. kill $(cat $filepath.$$.pid)
  19. rm $filepath.$$.pid