2021-10-10 03:17:29 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
FQ="$1"
|
|
|
|
|
|
|
|
c() {
|
|
|
|
echo -e "\x1b[97m# $1\x1b[0m"
|
|
|
|
}
|
|
|
|
|
|
|
|
s() {
|
|
|
|
echo "\$ $1"
|
2021-10-10 18:24:43 +03:00
|
|
|
sh -c "${1/fq/$FQ -o unicode=true -C}"
|
2021-10-10 03:17:29 +03:00
|
|
|
}
|
|
|
|
|
2021-11-22 16:16:59 +03:00
|
|
|
c "Overview of mp3 file"
|
2021-10-10 03:17:29 +03:00
|
|
|
s "fq . file.mp3"
|
|
|
|
echo
|
2021-11-22 16:16:59 +03:00
|
|
|
c "Show ID3v2 tag inside mp3 file"
|
2021-10-10 03:17:29 +03:00
|
|
|
s "fq '.headers[0]' file.mp3"
|
|
|
|
echo
|
2022-11-17 13:10:08 +03:00
|
|
|
c "Show encoder software used"
|
2022-12-14 13:33:11 +03:00
|
|
|
s "fq -r '.frames[0].tag.encoder | tovalue' file.mp3"
|
2022-11-17 13:10:08 +03:00
|
|
|
echo
|
2022-07-30 21:21:35 +03:00
|
|
|
c "Decode at two offsets as mp3_frame and show bitrate"
|
2022-11-20 21:22:16 +03:00
|
|
|
s "fq -d bytes '.[0xb79,0xc49:] | mp3_frame.header.bitrate' file.mp3"
|
2022-07-30 21:21:35 +03:00
|
|
|
echo
|
2021-11-22 16:16:59 +03:00
|
|
|
c "Extract PNG file"
|
2021-10-10 03:17:29 +03:00
|
|
|
s "fq '.headers[].frames[] | select(.id == \"APIC\")?.picture | tobits' file.mp3 >file.png"
|
|
|
|
s "file file.png"
|
|
|
|
rm -f file.png
|
2022-07-29 17:34:27 +03:00
|
|
|
echo
|
|
|
|
c "Resolution of embedded PNG cover art as YAML"
|
2022-12-21 15:59:54 +03:00
|
|
|
s "fq -r '.headers[0].frames[] | grep_by(.id == \"APIC\") | grep_by(.type == \"IHDR\") | {res: {width, height}} | to_yaml' file.mp3"
|
2022-07-30 21:21:35 +03:00
|
|
|
#echo
|
2022-07-29 17:34:27 +03:00
|
|
|
c "Add query parameter to URL"
|
2022-12-21 15:59:54 +03:00
|
|
|
s "echo 'http://host?a=b' | fq -Rr 'from_url | .query.b = \"a b c\" | to_url'"
|
2022-07-30 21:21:35 +03:00
|
|
|
echo
|
|
|
|
c "Extract JSON and base64 encoded query parameter p"
|
2022-12-21 15:59:54 +03:00
|
|
|
s "echo 'https://host?p=eyJhIjoiaGVsbG8ifQ%3D%3D' | fq -R 'from_url.query.p | from_base64 | fromjson'"
|