Grooming.

master
Karchnu 2021-04-30 01:13:53 +02:00
parent 95358ff18d
commit f58bfdde9c
1 changed files with 9 additions and 28 deletions

View File

@ -2,8 +2,7 @@
# From a single byte in hexadecimal per line # From a single byte in hexadecimal per line
# to lines ending with 0a (hex for '\n'). # to lines ending with 0a (hex for '\n').
regroup_lines(){ regroup_lines() awk '
awk '
BEGIN { BEGIN {
line_start=1 line_start=1
} }
@ -26,31 +25,20 @@ regroup_lines(){
print line print line
} }
' '
}
# From to ' # From to '
simple_quote(){ simple_quote() sed "s/e2 80 99/27/g"
sed "s/e2 80 99/27/g"
}
# From / to ' - ' # From / to ' - '
replace_slashes(){ replace_slashes() sed "s/2f/20 2d 20/g"
sed "s/2f/20 2d 20/g"
}
remove_multibyte_characters(){ remove_multibyte_characters() sed "s/e2 80 .. //g"
sed "s/e2 80 .. //g"
}
# Convert input into hexadecimal and a single byte per line. # Convert input into hexadecimal and a single byte per line.
to_hex_one_column(){ to_hex_one_column() xxd -p -c 1
xxd -p -c 1
}
# Reverse hexadecimal to original value. # Reverse hexadecimal to original value.
from_hex(){ from_hex() xxd -p -r
xxd -p -r
}
# Remove non ascii characters, convert "" to "'", or remove invalid filename characters. # Remove non ascii characters, convert "" to "'", or remove invalid filename characters.
to_ascii(){ to_ascii(){
@ -62,9 +50,7 @@ to_ascii(){
from_hex # Convert back from hex. from_hex # Convert back from hex.
} }
process_end_of_songs(){ process_end_of_songs() awk -v NONUMBER="$NONUMBER" -v SEPARATOR="$SEPARATOR" '
awk -v NONUMBER="$NONUMBER" -v SEPARATOR="$SEPARATOR" '
BEGIN { BEGIN {
OFS=" " OFS=" "
} }
@ -96,10 +82,8 @@ process_end_of_songs(){
print timestamp, "END_OF_FILE", title; print timestamp, "END_OF_FILE", title;
} }
' '
}
first_column_to_seconds(){ first_column_to_seconds() awk '
awk '
{ {
# from 10:30 to 630 # from 10:30 to 630
n = split ($1, arr, ":") n = split ($1, arr, ":")
@ -120,12 +104,9 @@ first_column_to_seconds(){
v = 0; v = 0;
} }
' '
}
# Get a more usable time representation for the beginning and the end of songs. # Get a more usable time representation for the beginning and the end of songs.
process_time_file(){ process_time_file(){ to_ascii | first_column_to_seconds | process_end_of_songs ; }
to_ascii | first_column_to_seconds | process_end_of_songs
}
run_ffmpeg(){ run_ffmpeg(){
file=$1 file=$1