brickviking

paste-pastebin.sh

Apr 12th, 2021
1,232
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Might need some sort of loop param or a from-to param
  3. # If we have for--to, then I'll need to run dmenu twice and store
  4. # all intermediate results into a list to feed to mpv
  5. # We need to grab the playlist from $arg
  6. if [ -z "$1" ]; then
  7.     echo "$0: We need a filename"
  8.     exit 1
  9. fi
  10. if [ ! -f "$1" ]; then
  11.     echo "$0: filename $1 doesn't exist. Please check again."
  12.     exit 1
  13. fi
  14. FN="$1"
  15.  
  16. MPVARGS="--video-aspect=16:9"
  17. # Filename exists, let's rock and roll
  18. OLD_XMODIFIERS="${XMODIFIERS}"
  19. unset XMODIFIERS
  20. FStr1="$(dmenu -l 40 -p "Start from: " < <(cat ""$1"" | cut -f2 -d#))"
  21. if [ -z "${FStr1}" ]; then
  22.     echo "$0: no entry chosen, leaving."
  23.     XMODIFIERS="${OLD_XMODIFIERS}"
  24.     exit 0
  25. fi
  26. unset XMODIFIERS
  27. FStr2="$(dmenu -l 40 -p "Play to: " < <(cat ""$1"" | cut -f2 -d#))"
  28. if [ -z "${FStr2}" ]; then
  29.     echo "$0: no entry chosen, playing one episode."
  30.     FINDSTRING=${FStr1}
  31. else
  32.     # A suggestion was to use sed to grab all lines from FStr1 to FStr2
  33.     # FINDSTRING="$(sed -e '/'$FStr1'/,/'$FStr2'/!d' < <(cat ""$1"" | cut -f2 -d#))"
  34.     echo "FStr1: ${FStr1}"
  35.     echo "FStr2: ${FStr2}"
  36.     echo "\$1: $1"
  37.    
  38.     bang="$(awk -v s1="$FStr1" -v s2="$FStr2" -F' *# *' 'index( $2, s1 ) , index( $2, s2 ) { print $1 }' "${FN}"  )"
  39.     declare -p bang
  40.     mapfile -t FINDSTRING < <( awk -v s1="$FStr1" -v s2="$FStr2" -F' *# *' 'index( $2, s1 ) , index( $2, s2 ) { print $1 }' "${FN}" )
  41.     echo "FINDSTRING:  ${FINDSTRING[@]}"
  42.     #mapfile -t FINDSTRING < <( awk -v s1="$FStr1" -v s2="$FStr2" -F' *# *' 'index( $2, s1 ) , index( $2, s2 ) { print $1 }' "$1" )
  43. fi
  44. XMODIFIERS="${OLD_XMODIFIERS}"
  45.  
  46.  
  47. # Let's go!
  48. echo "FINDSTRING:  ${FINDSTRING[@]}"
  49. # mpv "${urls[@]}"
  50. #mpv "${MPVARGS}" "$(grep "${FINDSTRING}" "$1" )"
  51. XMODIFIERS="${OLD_XMODIFIERS}"
  52.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×