2018-09-18 04:30:46 +02:00
#!/usr/bin/env zsh
2018-09-18 04:14:09 +02:00
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?) ,/ 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?) ,/ 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?),/ 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?) ,/ d
/^Dialogue:.*,( JapOP| EngOP) ,/ d
# /^Dialogue:.*,(English|Romaji),/ d
EOF
) > " $target "