Advertisement
mosaid

Untitled

Oct 22nd, 2017
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.74 KB | None | 0 0
  1. #!/bin/bash
  2. file="/media/$USER/My_Data/Videos/video clips/random.m3u"
  3. last="/media/$USER/WindowsDir/Users/$USER/GoogleDrive/linux/.lastNumber"
  4. DIR0="/media/mosaid/My_Data/Videos/video clips/videos 001/"
  5. N=$( cat "$file" | wc -l )
  6. function play (){
  7.     n=$1
  8.     if (( $n > $N )) ; then n=1; fi
  9.     #for i in 20 89 196 223 281 311 411 423
  10.     #   do
  11.     #       if(($i==$n))
  12.     #           then
  13.     #               let "n += 1"
  14.     #       fi
  15.     #done
  16.     fileToPlay=$( cat "$file" | sed -n "$n"p )
  17.     echo "$n" > "$last"
  18.     pid=$(pidof xplayer) # $( pgrep xplayer )
  19.     nohup xplayer "$fileToPlay" </dev/null >/dev/null 2>&1 &
  20.     sleep 1    
  21.     if (( ${#pid}==0 ))
  22.         then
  23.             xplayer --toggle-controls
  24.     fi
  25. }
  26.  
  27. function printhelp () {
  28.     string1=$1
  29.     string2=$2
  30.     pad=$( printf '%0.1s' " "{1..60} )
  31.     padlength=25
  32.     printf '\t%s' "$string1"
  33.     printf '%*.*s' 0 $(( padlength - ${#string1}  )) "$pad"
  34.     printf  "$string2"
  35.     printf '\n'
  36. }
  37.  
  38. case "$1" in
  39.         "" )
  40.             number=$(cat "$last" )
  41.             let "number += 1"
  42.             if (($number > $N))
  43.                 then
  44.                     number="1"
  45.             fi
  46.             echo "$number" 
  47.             play $number
  48.         ;;
  49.         "all" )
  50.           nohup xplayer "$file" </dev/null >/dev/null 2>&1 &
  51.         ;;
  52.         "l" | "L" )
  53.             cat  "$file" | awk -F'/' '{ if(length($NF)>70) $NF=substr($NF,0,70) ; print $NF}' | cat -n  |less
  54.         ;;
  55.         "a" )
  56.             mv "$2" "$DIR0"
  57.             echo "$DIR0/$2" >> "$file"
  58.         ;;
  59.         "e" )
  60.             nohup notepadqq "$file" </dev/null >/dev/null 2>&1 &
  61.         ;;
  62.         "h" )
  63.             printhelp "h" "print this help"
  64.             printhelp "" "play next"
  65.             printhelp "[number]" "play [number] of the list"
  66.             printhelp "l, L" "print list items"
  67.             printhelp "a" "move 2nd arg to videos folder and add to list"
  68.             printhelp "e" "edit vclips.m3u"
  69.         ;;
  70.         * )
  71.             number='^[0-9]+$'
  72.             if [[ $1 =~ $number ]] ; then play $1 ; fi
  73.         ;;
  74. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement