forked from grakshith/fterm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.sh
executable file
·173 lines (145 loc) · 3.5 KB
/
home.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#! /bin/bash
source config.cfg
figlet -f script "Your Feed"
curl -s -X GET \
"https://graph.facebook.com/v2.2/me/feed?fields=link,message,place,picture,story,source,created_time,description&limit=1000&access_token=$access_token" > json.data &
pid=$!
./wait.sh $pid
unset pid
usage() {
cat<<EOF
List of commands available
show thumbnail Display the thumbnail present in the post
show video Display the Video in this post
like Like the current photo
comment Comment on this photo
previous Go to the previous photo
Navigation:
back To go back to the previous level
EOF
}
#jq -r ".data[]" json.data
length=$(jq -r ".data | length" json.data)
if [ -d "fbthumbs" ]; then
echo
else
mkdir fbthumbs
fi
for((i=0;i<$length;i++))
do
#jq -r ".data[$i]" json.data
id="$(jq -r ".data[$i].id" json.data)"
from="$(jq -r ".home.data[$i].from.name" json.data)"
message="$(jq -r ".data[$i].message" json.data)"
story="$(jq -r ".data[$i].story" json.data)"
souce="$(jq -r ".data[$i].source" json.data)"
link="$(jq -r ".data[$i].link" json.data)"
picture="$(jq -r ".data[$i].picture" json.data)"
places="$(jq -r ".data[$i].place" json.data)"
description="$(jq -r ".data[$i].description" json.data)"
tim="$(jq -r ".data[$i].created_time" json.data)"
if [ "$from" != "null" ]; then
echo "From : $from"
fi
if [ "$message" != "null" ]
then
echo -n "Message : "
jq -r ".data[$i].message" json.data
fi
if [ "$story" != "null" ]
then
jq -r ".data[$i].story" json.data
fi
if [ "$description" != "null" ]
then
echo -n "Description : "
jq -r ".data[$i].description" json.data
fi
if [ "$link" != "null" ]
then
jq -r ".data[$i].link" json.data
fi
if [ "$places" != "null" ]
then
jq -r ".data[$i].place[]" json.data
fi
if [ "$souce" != "null" ];
then
echo "Video from this post available"
fi
if [ "$picture" != "null" ];
then
echo "This post contains a thumbnail"
fi
if [ "$tim"!="null" ]; then
echo -n "Created time : "
jq -r ".data[$i].created_time" json.data
echo ""
fi
echo -n "facebook/timeline $ "
read input
if [ "$input" = "previous" ]; then
i=$((i-2))
echo ""
continue
fi
if [ "$input" = "back" ]; then
exit
fi
if [ "$input" = "like" ]
then
curl -s -X POST \
-d "access_token=$access_token" \
"https://graph.facebook.com/v2.2/$id/likes" | jq -r ".success" &
pid=$!
./wait.sh $pid
unset pid
echo ""
fi
if [ "$input" = "show video" ]; then
vlc $souce > /dev/null 2>&1
fi
if [ "$input" = "show thumbnail" ]; then
wget -q -O fbthumbs/"$i.png" "$(jq -r ".data[$i].picture" json.data)"
echo "$(jq -r ".data[$i].picture" json.data)" >> fbthumbs/log
xdg-open "$(jq -r ".data[$i].picture" json.data)"
fi
if [ "$input" = "comment" ]
then
read comment
curl -s -X POST \
-d "access_token=$access_token&message=$comment" \
"https://graph.facebook.com/v2.2/$id/comments" | jq -r ".id"
pid=$!
./wait.sh $pid
unset pid
echo "Successfully posted comment"
echo ""
fi
if [ "$input" = "show comments" ]
then
curl -s -X GET \
"https://graph.facebook.com/v2.2/$id/comments?limit=10&access_token=$access_token" > comments.data &
pid=$!
./wait.sh $pid
for((i=0;i<10;i++))
do
name="$(jq -r ".data[$i].from.name" comments.data)"
message="$(jq -r ".data[$i].message" comments.data)"
like_count="$(jq -r ".data[$i].like_count" comments.data)"
created_time="$(jq -r ".data[$i].created_time" comments.data)"
echo "On $created_time, $name commented "
echo $message
echo ""
done
echo "End of comments for this post"
echo ""
fi
if [ "$input" = "help" ]; then
i=$((i-1))
usage
read ip
continue
fi
done
#rm json.data