scripts: Init medialinter, remove tc-* scripts

master
Pierre Neidhardt 2016-10-18 10:33:38 +05:30
parent 5b54489c96
commit 2e0cb65544
5 changed files with 63 additions and 124 deletions

63
.scripts/medialinter Executable file
View File

@ -0,0 +1,63 @@
#!/bin/sh
usage () {
cat <<EOF>&2
Usage: ${0##*/} FOLDER
Print lints in mediafiles:
- CBR audio
- Less of more than 2 channels
- Non-HD files
- HD files without resolution in their names
- Misspellings in subtitles (oe, `, ´)
- Embedded covers
- Leading zeros in tags
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
if ! command -v mediainfo >/dev/null 2>&1; then
echo >&2 "mediainfo required."
exit 1
fi
subtitle () {
buffer=$(cat "$1")
echo "$buffer" | grep -q "\`" && echo "$i: Misspelling (\`)"
echo "$buffer" | grep -q "´" && echo "$i: Misspelling (´)"
echo "$buffer" | grep -q "oe" && echo "$i: Misspelling (oe)"
}
media () {
buffer=$(mediainfo "$1")
echo "$buffer" | grep -q "Bit rate mode *: Constant" && echo "$i: CBR audio"
echo "$buffer" | grep -q "Cover *: Yes" && echo "$i : Embedded cover(s)"
echo "$buffer" | grep -q "Track name/Position *: 0+" && echo "$i: Leading zeros in tags"
echo "$buffer" | grep -q "Channel(s) *: 1 channel" && echo "$i: Only 1 audio channel"
echo "$buffer" | grep -q "Channel(s) *: (2[0-9]+|[013-9]+) channels" && echo "$i: More than 2 audio channels"
width=$(echo "$buffer" | awk '/^Width *:/ {gsub(/[^0-9]/, ""); print; exit} ')
if [ -n "$width" ]; then
if [ "$width" -lt 1200 ]; then
echo "$i: Non-HD"
else
echo "$i" | grep -q "\[720\]|\[1080\]" || echo "$i: HD file without resolution in filename"
fi
fi
}
for i ; do
l=$(echo "$i" | awk '{print tolower($0)}')
case "$l" in
*.srt|*.sub|*.ass)
subtitle "$i"
exit ;;
esac
media "$i"
done

View File

@ -1,43 +0,0 @@
#!/bin/sh
usage () {
cat <<EOF>&2
Usage: ${0##*/} FOLDERS
Print audio files found in FOLDERS with
- constant bitrate;
- embedded covers;
- leading zeros in tags.
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
if ! command -v mediainfo >/dev/null 2>&1; then
echo >&2 "mediainfo required."
exit 1
fi
for j; do
while IFS= read -r i; do
BUFFER="$(mediainfo "$i")"
echo "$BUFFER" | grep -q "Bit rate mode *: Constant" && echo "$i : CBR"
echo "$BUFFER" | grep -q "Cover *: Yes" && echo "$i : Cover"
echo "$BUFFER" | grep -q "Track name/Position *: 0+" && echo "$i : Leading zeros"
done <<EOF
$(find "$j" \( \
-iname '*.mp3' -o \
-iname '*.flac' -o \
-iname '*.wv' -o \
-iname '*.aac' -o \
-iname '*.wav' -o \
-iname '*.wma' -o \
-iname '*.ogg' -o \
-iname '*.ac3' -o \
-iname '*.dts' -o \
-iname '*.ape' -o \
-iname '*.mpc' \) )
EOF
done

View File

@ -1,34 +0,0 @@
#!/bin/sh
usage () {
cat <<EOF>&2
Usage: ${0##*/} FOLDERS
Check for files containing common mispelling:
- "\`" and "´" instead of "'",
- "oe" instead of "œ".
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
if ! command -v recode >/dev/null 2>&1; then
echo >&2 "recode needed."
exit 1
fi
for i ; do
while IFS= read -r j; do
printf "# "
file "$j"
grep -m1 "\`" "$j"
grep -m1 "´" "$j"
grep -m1 "oe" "$j"
done <<EOF
$(find "$i" -type f -size -50M -print)
EOF
done

View File

@ -1,22 +0,0 @@
#!/bin/sh
usage () {
cat <<EOF>&2
Usage: ${0##*/} FOLDER
Print subfolders in FOLDER which have no file with either "720" or "1080" in their name.
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
while IFS= read -r i; do
if [ "$(find "$i" -type f \( -name '*720*' -o -name '*1080*' \))" = "" ]; then
echo "$i"
fi
done <<EOF
$(find "$1" -maxdepth 1 -type d)
EOF

View File

@ -1,25 +0,0 @@
#!/bin/sh
usage () {
cat <<EOF>&2
Usage: ${0##*/} FOLDER
Print movies in FOLDER which have strictly more than 1 audio channel.
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
while IFS= read -r i; do
## Some formats (e.g. m2ts) will also return an "audio" channel in the
## "programs" section. We skip that.
stream_count=$(ffprobe -v quiet "$i" -print_format flat=s=_ -show_entries stream=codec_type | grep -v '^programs' | cut -f2 -d= | grep -c "audio")
if [ -n "$stream_count" ] && [ "$stream_count" -gt 1 ]; then
echo "$i"
fi
done <<EOF
$(find "$1" -type f)
EOF