SKRS-Fansub/tools/strip_cpas.zsh

67 lines
1.8 KiB
Bash

#!/usr/bin/env zsh
dirname "$1" | read -r dir
basename "$1" | read -r name
sed -re 's/.* - ([0-9]+).*/\1/' <<< "$name" | read -r num
targetdir="$dir/.."
targetname="[FGT] SKRS - $num.ass"
# echo "$dir/$name"
# echo "$targetdir/$targetname"
# exit
target="$targetdir/$targetname"
echo Writing "$target"
<"$1" sed -rf <(<< EOF
/^Style:.*-furigana,/ d
# /^Comment:/ d
# /^Dialogue:.*,(Default|Alt),/ d
/^Dialogue:.*,(Hybrid|Tenebris)-signs,/ d
/^Dialogue:.*,Insert/ d
/^Dialogue:.*,(Both|Futaba|Kaoru|Hikari2?|Nana2?|Suns|Stars|Karen2?|TENDOMAYA),/ d
/^Dialogue:.*,(JapOP|EngOP),/ d
/^Dialogue:.*,(English|Romaji),/ d
EOF
) > "$target"
target="$targetdir/${targetname%%.ass}_typeset.ass"
echo Writing "$target"
<"$1" sed -rf <(<< EOF
/^Style:.*-furigana,/ d
/^Comment:/ d
/^Dialogue:.*,(Default|Alt),/ d
# /^Dialogue:.*,(Hybrid|Tenebris)-signs,/ d
/^Dialogue:.*,Insert/ d
/^Dialogue:.*,(Both|Futaba|Kaoru|Hikari2?|Nana2?|Suns|Stars|Karen2?|TENDOMAYA),/ d
/^Dialogue:.*,(JapOP|EngOP),/ d
/^Dialogue:.*,(English|Romaji),/ d
EOF
) > "$target"
target="$targetdir/${targetname%%.ass}_insert.ass"
echo Writing "$target"
<"$1" sed -rf <(<< EOF
/^Style:.*-furigana,/ d
/^Comment:/ d
/^Dialogue:.*,(Default|Alt),/ d
/^Dialogue:.*,(Hybrid|Tenebris)-signs,/ d
# /^Dialogue:.*,Insert/ d
# /^Dialogue:.*,(Both|Futaba|Kaoru|Hikari2?|Nana2?|Suns|Stars|Karen2?|TENDOMAYA),/ d
/^Dialogue:.*,(JapOP|EngOP),/ d
/^Dialogue:.*,(English|Romaji),/ d
EOF
) > "$target"
target="$targetdir/${targetname%%.ass}_ED.ass"
echo Writing "$target"
<"$1" sed -rf <(<< EOF
/^Style:.*-furigana,/ d
/^Comment:/ d
/^Dialogue:.*,(Default|Alt),/ d
/^Dialogue:.*,(Hybrid|Tenebris)-signs,/ d
/^Dialogue:.*,Insert/ d
/^Dialogue:.*,(Both|Futaba|Kaoru|Hikari2?|Nana2?|Suns|Stars|Karen2?|TENDOMAYA),/ d
/^Dialogue:.*,(JapOP|EngOP),/ d
# /^Dialogue:.*,(English|Romaji),/ d
EOF
) > "$target"