Skip to content

Instantly share code, notes, and snippets.

@Ruin0x11
Last active March 22, 2019 19:48
Show Gist options
  • Save Ruin0x11/c14392936bf91820fe0b to your computer and use it in GitHub Desktop.
Save Ruin0x11/c14392936bf91820fe0b to your computer and use it in GitHub Desktop.
play videos/episodes in sequential order
#!/bin/bash
# mpv-seq - Play files in a directory in order, starting from given file
# caveat: needs the filename as first argument, then arguments to pass to mpv
playlist=/var/tmp/.playlist
thisfile="$0"
qa="$1"
q=$(printf '%s\n' "$qa" | sed 's/[[\.*^$/]/\\&/g')
ext="${q##*.}"
dir=`pwd`
pl=`find "$dir" -iname "*.$ext" \
| sort \
| sed -n "/${q}/,\$ p" \
| tee $playlist`
shift
mpv "$@" -playlist "$playlist"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment