-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitchFollows.sh
executable file
·80 lines (61 loc) · 2.06 KB
/
twitchFollows.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
#!/bin/bash
FOLLOWCOUNT="$(curl -s -H 'Client-ID: #####' -X GET 'https://api.twitch.tv/helix/users/follows?from_id=37047880' | jq .total)"
((n = $FOLLOWCOUNT / 100))
((h = $n /2))
COUNTER=0
LIMIT=0
echo GENERATING LIST
curl -s -H 'Client-ID: #####' -X GET 'https://api.twitch.tv/helix/users/follows?from_id=37047880&first=100' | jq -r '.data[].to_id' | tee twitchid.txt > /dev/null
page="$(curl -s -H 'Client-ID: #####' -X GET 'https://api.twitch.tv/helix/users/follows?from_id=37047880&first=100' | jq -r '.pagination.cursor')"
while [ $COUNTER -lt $n ]; do
curl -s -H 'Client-ID: #####' -X GET 'https://api.twitch.tv/helix/users/follows?from_id=37047880&first=100&after='$page'' | jq -r '.data[].to_id' | tee -a twitchid.txt > /dev/null
page="$(curl -s -H 'Client-ID: #####' -X GET 'https://api.twitch.tv/helix/users/follows?from_id=37047880&first=100&after='$page'' | jq -r '.pagination.cursor')"
sleep 4
#echo $page
#echo $COUNTER
#if [ $LIMIT -eq 10 ]
#then
# echo Waiting 30 seconds for API reset
# LIMIT=0
# sleep 30
# fi
let COUNTER=COUNTER+1
let LIMIT=LIMIT+1
done
echo
echo GENERATING REPORTS
sleep 4
declare -a myarray
let i=0
while IFS=$'\n' read -r line_data; do
myarray[i]="${line_data}"
((++i))
done < twitchid.txt
let i=0
let LIMIT=0
let COUNTER=0
rm -rfv twitchInactive.txt
rm -rfv twitchActive.txt
while [ $COUNTER -lt $FOLLOWCOUNT ]; do
published="$(curl -s -H 'Client-ID: #####' -X GET 'https://api.twitch.tv/helix/videos?user_id='${myarray[i]}'&first=1&type=archive' | jq -r '.data[].published_at')"
if [ -z "$published" ]
then
curl -s -H 'Client-ID: #####' -X GET 'https://api.twitch.tv/helix/users?id='${myarray[i]}'' | jq -r '.data[].display_name' | tee -a twitchInactive.txt
echo i
sleep 4
else
curl -s -H 'Client-ID: #####' -X GET 'https://api.twitch.tv/helix/users?id='${myarray[i]}'' | jq -r '.data[].display_name' | tee -a twitchActive.txt
echo a
sleep 4
fi
# if [ $LIMIT -eq 10 ]
# then
# echo Waiting 30 seconds for API reset
# LIMIT=0
# sleep 60
# fi
echo
let LIMIT=LIMIT+1
let i=i+1
let COUNTER=COUNTER+1
done