-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkvattachcover.sh
executable file
·60 lines (59 loc) · 2.57 KB
/
mkvattachcover.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
# mkvattachcover -- attach cover and fanart images downloaded with
# MediaElch to mkv files.
#
# Author: Peter Keel <[email protected]>
# License: MIT License
#
if ! command -v convert mkvpropedit >/dev/null 2>&1; then
echo >&2 "convert and mkvpropedit are required"
exit 1
fi
for filename in ./*.mkv; do
filename_no_ext=$(basename "$filename" .mkv);
if [ -e "$filename_no_ext-poster.jpg" ]; then
convert -scale 600x\> "$filename_no_ext-poster.jpg" \
"$filename_no_ext-poster2.jpg"
convert -scale 120x\> "$filename_no_ext-poster.jpg" \
"$filename_no_ext-poster3.jpg"
mkvpropedit --attachment-name cover.jpg "$filename" \
--add-attachment "$filename_no_ext-poster2.jpg"
mkvpropedit --attachment-name small_cover.jpg "$filename" \
--add-attachment "$filename_no_ext-poster3.jpg"
rm "$filename_no_ext-poster2.jpg" "$filename_no_ext-poster3.jpg"
elif [ -e "season-all-poster.jpg" ]; then
# It's a series
convert -scale 600x\> "season-all-poster.jpg" \
"$filename_no_ext-poster2.jpg"
convert -scale 120x\> "season-all-poster.jpg" \
"$filename_no_ext-poster3.jpg"
mkvpropedit --attachment-name cover.jpg "$filename" \
--add-attachment "$filename_no_ext-poster2.jpg"
mkvpropedit --attachment-name small_cover.jpg "$filename" \
--add-attachment "$filename_no_ext-poster3.jpg"
rm "$filename_no_ext-poster2.jpg" "$filename_no_ext-poster3.jpg"
fi
if [ -e "$filename_no_ext-fanart.jpg" ]; then
convert -scale x600\> "$filename_no_ext-fanart.jpg" \
"$filename_no_ext-fanart2.jpg"
convert -scale x120\> "$filename_no_ext-fanart.jpg" \
"$filename_no_ext-fanart3.jpg"
mkvpropedit --attachment-name cover_land.jpg "$filename" \
--add-attachment "$filename_no_ext-fanart2.jpg"
mkvpropedit --attachment-name small_cover_land.jpg "$filename" \
--add-attachment "$filename_no_ext-fanart3.jpg"
rm "$filename_no_ext-fanart2.jpg" "$filename_no_ext-fanart3.jpg"
elif [ -e "$filename_no_ext-thumb.jpg" ]
then
convert -scale x600\> "$filename_no_ext-thumb.jpg" \
"$filename_no_ext-fanart2.jpg"
convert -scale x120\> "$filename_no_ext-thumb.jpg" \
"$filename_no_ext-fanart3.jpg"
mkvpropedit --attachment-name cover_land.jpg "$filename" \
--add-attachment "$filename_no_ext-fanart2.jpg"
mkvpropedit --attachment-name small_cover_land.jpg "$filename" \
--add-attachment "$filename_no_ext-fanart3.jpg"
rm "$filename_no_ext-fanart2.jpg" "$filename_no_ext-fanart3.jpg" "$filename_no_ext-thumb.jpg"
fi
done