-
Notifications
You must be signed in to change notification settings - Fork 0
/
rip-episodes
executable file
·40 lines (31 loc) · 1 KB
/
rip-episodes
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
#!/bin/bash -
# Rip Episodes
# ============
#
# Rip TV episodes from a DVD using Handbrake.
#
# `rip-episodes -h` for more.
source _rip-disc
## Main logic
# If passing a range of episodes, parse out
if grep -E -- '^[0-9]+-[0-9]+$' <<< "$*" > /dev/null; then
ep1=$(cut -d- -f1 <<< "$1")
ep2=$(cut -d- -f2 <<< "$1")
episodes=$(gseq -s' ' -w "$ep1" "$ep2")
else
episodes="$@"
fi
a_episodes=($episodes)
a_episode_files=("$source"/*.mkv)
if (("${#a_episodes[@]}" > "${#a_episode_files[@]}")); then
_report_error "more episodes listed to rip than number of source files available"
fi
for index in "${!a_episodes[@]}"; do
episode="${a_episodes[$index]}"
episode_file="${a_episode_files[$index]}"
_get_media_info "$episode_file"
_set_video_settings
_set_audio_settings
_run mkdir -p "${outputdir}/${prefix}/S${season}/"
_run HandBrakeCLI -i "$episode_file" -t1 -o "${outputdir}/${prefix}/S${season}/${prefix}-S${season}E${episode}.mkv" ${video_settings} ${audio_settings}
done