summaryrefslogtreecommitdiffstats
path: root/moviemanager
blob: 64f2459396dd1e6af75d59bf03748482359144eb (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/zsh

# Dependencies
# 1. fetch_poster.py 
# 2. imdbpy.py -- both from  mythtv scripts(no need to install mythtv.. just
# search for those files on intertubes)
# 3. imdb package from  http://imdbpy.sourceforge.net/

# To add 
# 1. My votes and other votes
# 2. Symlink to download dir
# 3. Symlink to torrent file (legal of course)
# 4. Search and retrieval
# 5. Linking between movies
# 6. Handling parallel connections -- without getting banned :)
# 7. Watched or not
# 8. Better genre sorting/searching

#set -x
if [[ -z $2 ]];then echo "Not enough arguments"; exit 1;fi


action=${1:-view}


dir="$HOME/.imdatabase"
ids="$dir/.movieids"
rm $dir/.done &>/dev/null


if [[ $action == add ]];then
    url="$2"
    stage=$3
    temp=$RANDOM
    movie_id="${${url:t}#[a-zA-Z][a-zA-Z]}"

    if ps auxww | grep -q $movie_id | grep -v grep;then
        exit
    fi
    
    if grep -q $movie_id $ids;then
        exit
    else
        echo $movie_id >> "$dir/.movieids"
    fi

    title="$(get_movie.py $movie_id 2>/dev/null | tee /tmp/$temp  | grep Title | cut -d : -f 2 | sed -e 's/^\s*//g')"
    [[ -d "$dir/$title" || -d "$dir/$title-stage" ]] && exit


    if [[ -n $stage ]];then
        title="$title-stage"
    fi
    mkdir -p "$dir/$title"
    mv /tmp/$temp "$dir/$title/desc"

    poster=$(~/bin/fetch_poster.py -P $movie_id -a 2>/dev/null | tail -1)
    mv $poster "$dir/$title/poster.jpg"
    notify-send "IMDB:" "^i(/home/raghavendra/.notify-icons/movies.xpm)$title added"
elif [[ $action == view ]];then
    notify-send "IMDB:" "^i(/home/raghavendra/.notify-icons/movies.xpm)Nothing for now"
fi

# Completion token
touch $dir/.done &>/dev/null
#set +x

#for x in *;do  x="$(echo $x | tr -dc '[0-9A-Za-z ]')"; echo -n "$x::"; locate "$x[(w)1]"  | /bin/grep -i -E '*.(avi|mkv|mp4)$' | grep "$x[(w)2]" | grep "$x[(w)3]" | head -1 ; echo "===================="; done | tee /tmp/llog
#for line in $(cat /tmp/llog2);do first="$(echo $line | cut -d ':' -f 1)"; second="$(echo $line | cut -d : -f 3)"; pushd "*$first*" 2>/dev/null; echo "ln -s $second:h ." ;popd;done |& less