一个非常不完美的shell,功能就是一直放动漫的中间部分(跳过片头和片尾)。对我这种喜欢直接看完结动漫而且在床上看的来说挺不错的。虽然经常会多跳一点,或者少跳一些,不过总比在床上起来好:)
慢慢的多加些东西进去,以后打算用C写一个:)
ps:这个文件在我的项目里也有,有空就更新一点功能什么的
#!/bin/bash
#this is a shell for play anime videos.
#maplebeats'shell
temp_file=/tmp/cdb.$$
video_time(){
echo -e "请输入片头曲完的时间点 "
read x
echo -e "请输入片尾曲开始的时间分钟,"
read y
echo -e "请输入片尾曲开始的时间秒,"
read z
end_time=`expr 60 \* $y + $z - $x`
return 0
}
creat_lst () {
find . \( -name "*.rmvb" -or -name "*.mp4" \) -type f | vim -c 'sort nr /\d\+/' -c 'w '$temp_file'' -c 'q' - && cat $temp_file >anime.lst && rm $temp_file
#find . \( -name "*.rmvb" \) -type f | sort > anime.lst
}
skip_open(){
exec mplayer -fs -ss $x -playlist anime.lst >>/dev/null
return 0
}
skip_end(){
sleep $end_time && killall mplayer && sed -i '1d' anime.lst &&play_video >>/dev/null
return 0
}
play_video(){
if [ -s anime.lst ];then
skip_end&
skip_open
else
rm -rf anime.lst
exit 0
fi
}
#列表是否存在
lst_presence(){
if [ -f ./anime.lst ]
then
return 0
else
return 1
fi
}
#主函数
video_time
if lst_presence
then
play_video
else
creat_lst
play_video
fi
exit 0