caio.co/de/bash.d


Add mplayer options by Caio 13 years ago (log)

Blob lib/onepiece.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
#!/bin/bash

__wm_check() {
    if [ ! -d WATCHED ]; then
        echo "You must create a ./WATCHED dir to use this command" >&2
        return 2
    fi
    return 0
}

wm() {
    video="${@}"
    mplayer -ass -embeddedfonts "${video}"
    result=$?
    if test $result -eq 0; then
        mv "${video}" WATCHED/
        subfile="${video%.*}.srt"
        test -f "${subfile}" && mv "${subfile}" WATCHED
        return 0;
    fi
}

wnext() {
    __wm_check || return $?
    local target=""
    while read LINE; do
        test -d "${LINE}" && continue
        test ! -f "${LINE}" && continue
        target=${LINE}
        break
    done < <(/bin/ls -1 !(*.srt|WATCHED))
    test -z "${target}" && return 1
    wm "${target}"
}

wprev() {
    __wm_check || return $?
    local target=""
    while read LINE; do
        test -d "${LINE}" && continue
        test ! -f "${LINE}" && continue
        target=${LINE}
        break
    done < <(ls -1 WATCHED| egrep -v '.+\.srt'| tac| sed 's/^/WATCHED\//g')
    test -z "${target}" && return 1
    mplayer "${target}"
}