Advertisement
Guest User

audio bookmark manager 2

a guest
Mar 13th, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.47 KB | None | 0 0
  1. ::::::::::::::
  2. fforward.bash
  3. ::::::::::::::
  4. #!/bin/bash
  5.  
  6. audtool playback-seek-relative 10
  7. spd-say -t female2 n::::::::::::::
  8. join_play.bash
  9. ::::::::::::::
  10. #!/bin/bash
  11.  
  12. function check_out_loc() {
  13.   w_dir="$(pwd)/joins"
  14.   echo $w_dir
  15.   if [ -d "$w_dir" ]; then
  16.     echo direcotry exists
  17.   else
  18.     mkdir "$(pwd)/joins"
  19.     echo direcotry created
  20.   fi
  21. }
  22.  
  23. function join_clips() {
  24.   # join clip files
  25.     readarray -t files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(mp3\|flac\)$' | sed "s/.*\///")
  26.   file_name=$(basename "${files[0]}" | cut -d. -f1)
  27.     file_extension=$(basename "${files[0]}" | cut -d. -f2)
  28.   date_str=$(date +%s)
  29.     out_loc=$(echo joins/"$date_str"_$file_name.$file_extension)
  30.     cat ./clips/*.* > ./"$out_loc"
  31.   # get original file
  32.   date_str=$((date_str + 1))
  33.   mv "$file_name.$file_extension" "$(pwd)/joins/"$date_str"_$file_name.$file_extension"
  34.   # get marks file
  35.   readarray -t files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(txt\)$' | sed "s/.*\///")
  36.   file_name=$(basename "${files[0]}" | cut -d. -f1)
  37.   file_extension=$(basename "${files[0]}" | cut -d. -f2)
  38.   date_str=$((date_str + 1))
  39.   mv "$file_name.$file_extension" "$(pwd)/joins/"$date_str"_$file_name.$file_extension"
  40.     audacious "$(echo $(pwd)/$out_loc)"
  41. }
  42.  
  43. cd /media/$(whoami)/extsd/Music
  44. check_out_loc
  45. join_clips
  46. spd-say -t female2 "join & play"::::::::::::::
  47. load_file.bash
  48. ::::::::::::::
  49. #!/bin/bash
  50.  
  51. function check_out_loc() {
  52.   w_dir="$(pwd)/joins"
  53.   echo $w_dir
  54.   if [ -d "$w_dir" ]; then
  55.     echo direcotry exists
  56.   else
  57.     mkdir "$(pwd)/joins"
  58.     echo direcotry created
  59.   fi
  60. }
  61.  
  62. function load_file() {
  63.     cd /media/$(whoami)/extsd/recordings
  64.     readarray -t files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(mp3\|flac\)$' | sed "s/.*\///" | sort)
  65.     if [ ${#files[@]} -gt 0 ]; then
  66.         file_name=$(basename "${files[0]}" | cut -d. -f1)
  67.         file_extension=$(basename "${files[0]}" | cut -d. -f2)
  68.         out_dir="/media/$(whoami)/extsd/Music/"
  69.         mv "$file_name.$file_extension" "$out_dir"
  70.         audacious "$out_dir$file_name.$file_extension"
  71.     fi
  72. }
  73.  
  74. function move_previous() {
  75.     cd /media/$(whoami)/extsd/Music
  76.     readarray -t files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(mp3\|flac\)$' | sed "s/.*\///" | sort)
  77.     if [ ${#files[@]} -gt 0 ]; then
  78.         file_name=$(basename "${files[0]}" | cut -d. -f1)
  79.         file_extension=$(basename "${files[0]}" | cut -d. -f2)
  80.         date_str=$(date +%s)
  81.         check_out_loc
  82.         out_dir="/media/$(whoami)/extsd/Music/joins/"
  83.         mv "$file_name.$file_extension" "$out_dir"$date_str"_$file_name.$file_extension"
  84.     fi
  85. }
  86.  
  87. move_previous
  88. load_file
  89. spd-say -t female2 "file loaded"::::::::::::::
  90. mark_in_out.bash
  91. ::::::::::::::
  92. #!/bin/bash
  93.  
  94. function mark_audio() {
  95.     out_loc="$(echo $(pwd)/marks.txt)"
  96.     status=$(audtool playback-status)
  97.     current_song_pos=$(audtool --current-song-output-length-seconds)
  98.     minutes=$((current_song_pos / 60))
  99.     if [[ "$minutes" -lt 10 ]]; then
  100.         minutes=$(printf "%02d" $minutes)
  101.     fi
  102.     seconds=$((current_song_pos % 60))
  103.     if [[ "$seconds" -lt 10 ]]; then
  104.         seconds=$(printf "%02d" $seconds)
  105.     fi
  106.     write_marker=$(echo $minutes":"$seconds)
  107.     if [[ -f "$out_loc" ]]; then
  108.         echo -n " $write_marker" >> $out_loc
  109.     else
  110.         echo -n "$write_marker" >> $out_loc
  111.     fi
  112. }
  113.  
  114. cd /media/$(whoami)/extsd/Music
  115. mark_audio
  116. spd-say -t female2 m::::::::::::::
  117. play_pause.bash
  118. ::::::::::::::
  119. #!/bin/bash
  120.  
  121. function play_pause() {
  122.     status=$(audtool playback-status)
  123.     if grep 'paused\|stopped' <<< $status ; then
  124.         audtool playback-play
  125.     else
  126.         audtool playback-pause
  127.     fi
  128. }
  129.  
  130. play_pause
  131. spd-say -t female2 s::::::::::::::
  132. redshift.bash
  133. ::::::::::::::
  134. #!/bin/bash
  135.  
  136. redshift -O 3700
  137. spd-say -t female2 "redshift"::::::::::::::
  138. rewind.bash
  139. ::::::::::::::
  140. #!/bin/bash
  141.  
  142. audtool playback-seek-relative -10
  143. spd-say -t female2 p::::::::::::::
  144. screen_off.bash
  145. ::::::::::::::
  146. #!/bin/bash
  147.  
  148. xrandr --output DSI-1 --brightness 0.20
  149. spd-say -t female2 "screen off"
  150. xset dpms force off::::::::::::::
  151. split_audio.bash
  152. ::::::::::::::
  153. #!/bin/bash
  154.  
  155. function check_out_loc() {
  156.   w_dir="$(pwd)/clips"
  157.   echo $w_dir
  158.   if [ -d "$w_dir" ]; then
  159.     # re-creatates subdir clips in the current folder
  160.     rm -rf $w_dir
  161.     mkdir "$(pwd)/clips"
  162.     echo direcotry re-created
  163.   else
  164.     mkdir "$(pwd)/clips"
  165.     echo direcotry created
  166.   fi
  167. }
  168.  
  169. function cut_audio() {
  170.   readarray -t mp3_files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(mp3\|flac\)$' | sed "s/.*\///")
  171.   if [ ${#mp3_files[@]} -eq 1 ]; then
  172.     j=0
  173.     for i in "$@"; do
  174.       ((j++))
  175.       if [ $((j%2)) -eq 0 ]; then
  176.         end_time=$i
  177.         MPHR=60
  178.         IFS=':' read -ra start_array <<< "$start_time"
  179.         IFS=':' read -ra end_array <<< "$end_time"
  180.         len_start_min=${#start_array[0]}
  181.         len_start_sec=$(( $len_start_min + 1 ))
  182.         len_end_min=${#end_array[0]}
  183.         len_end_sec=$(( $len_end_min + 1 ))
  184.         start_time_sec=$(( ( 10#${start_time:0:$len_start_min} ) * MPHR + 10#${start_time:$len_start_sec} ))
  185.         duration=$(( ( 10#${end_time:0:$len_end_min} - 10#${start_time:0:$len_start_min} ) * MPHR + 10#${end_time:$len_end_sec} - 10#${start_time:$len_start_sec} ))
  186.         file_name=$(basename "${mp3_files[0]}" | cut -d. -f1)
  187.         file_extension=$(basename "${mp3_files[0]}" | cut -d. -f2)
  188.         escape=("[" "]" "~" "!" "{" "}" "(" ")" "$" "@" "<" ">" ":" ";" "," '`' "%" "+" "=" '"' "|" "?" '*' "&" " " "'")
  189.         for e in "${escape[@]}"
  190.         do
  191.           file_name=${file_name//[$e]/\\$e}
  192.         done
  193.         file_name=${file_name//"\\'"/"'\"\'\"'"}
  194.         w_dir="$(pwd)/clips/"
  195.         out_name=$w_dir$(echo $file_name"_"$start_time"-"$end_time"."$file_extension | sed s/:/_/g)
  196.         # removes metadata
  197.         cmd=$(echo ffmpeg -y -ss $start_time_sec -t $duration -i "$file_name"."$file_extension" -map_metadata -1 -c:a copy "$out_name")
  198.         # no metadata removal
  199.         # cmd=$(echo ffmpeg -y -ss $start_time_sec -t $duration -i "$file_name"."$file_extension" -c:a copy "$out_name")
  200.         # echo $cmd
  201.         bash -c "$cmd"
  202.       else
  203.         start_time=$i
  204.       fi
  205.     done
  206.     # backup marks.txt file
  207.     readarray -t files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(mp3\|flac\)$' | sed "s/.*\///")
  208.     file_name=$(basename "${files[0]}" | cut -d. -f1)
  209.     if [ -f "$(pwd)/marks.txt" ]; then
  210.       marks_out_loc="$file_name"_marks.txt
  211.       cp marks.txt "$marks_out_loc"
  212.       echo -n " $file_name"."$file_extension" >> ./"$marks_out_loc"
  213.       echo marks.txt backup done
  214.       rm marks.txt
  215.     fi
  216.   else
  217.     echo "error, only 1 mp3/flac file allowed in the current working directory"
  218.   fi
  219. }
  220.  
  221. cd /media/$(whoami)/extsd/Music
  222. check_out_loc
  223. cut_audio $(cat $(pwd)/marks.txt)
  224. spd-say -t female2 "split audio"::::::::::::::
  225. volume_down.bash
  226. ::::::::::::::
  227. #!/bin/bash
  228.  
  229. pactl -- set-sink-volume 0 -1%::::::::::::::
  230. volume_up.bash
  231. ::::::::::::::
  232. #!/bin/bash
  233.  
  234. pactl -- set-sink-volume 0 +1%::::::::::::::
  235. .xbindkeysrc
  236. ::::::::::::::
  237. "/media/$(whoami)/extsd/Music/rewind.bash"
  238. c:87
  239.  
  240. "/media/$(whoami)/extsd/Music/fforward.bash"
  241. c:88
  242.  
  243. "/media/$(whoami)/extsd/Music/play_pause.bash"
  244. c:89
  245.  
  246. "/media/$(whoami)/extsd/Music/mark_in_out.bash"
  247. c:104
  248.  
  249. "/media/$(whoami)/extsd/Music/split_audio.bash"
  250. c:83
  251.  
  252. "/media/$(whoami)/extsd/Music/join_play.bash"
  253. c:84
  254.  
  255. "/media/$(whoami)/extsd/Music/volume_up.bash"
  256. c:86
  257.  
  258. "/media/$(whoami)/extsd/Music/volume_down.bash"
  259. c:82
  260.  
  261. "/media/$(whoami)/extsd/Music/load_file.bash"
  262. c:90
  263.  
  264. "/media/$(whoami)/extsd/Music/screen_off.bash"
  265. c:91
  266.  
  267. "/media/$(whoami)/extsd/Music/redshift.bash"
  268. c:85
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement