OwnTweetSearch.sh
1 |
#!/bin/bash |
---|---|
2 |
|
3 |
IFS=' |
4 |
' |
5 |
|
6 |
MY_NAME="own-twitter-id" #自身のTwitterのidを設定 |
7 |
HIT_LIST=$(cat tweet.js |sed -e 's/window.YTD.tweet.part0 = //'|jq -r -c '.[]'|grep "$1") |
8 |
HIT_COUNT=$(echo "${HIT_LIST}"|wc -l) |
9 |
COUNT="1" |
10 |
|
11 |
for RECORD in $HIT_LIST |
12 |
do |
13 |
echo $RECORD |
14 |
ID=$(echo $RECORD|grep -o "\"id\":\".*\""|tr ',' '\n'|grep "\"id\":\".*\""|tail -1|awk -F'"' '{print $4}') |
15 |
SCREEN_NAME=$(echo $RECORD|grep -o "screen_name\":\".*\","|awk -F'"' '{print $3}') |
16 |
if [ -z "$SCREEN_NAME" ] |
17 |
then |
18 |
SCREEN_NAME=$MY_NAME |
19 |
fi |
20 |
echo "https://twitter.com/${SCREEN_NAME}/status/${ID}" |
21 |
if [ "$HIT_COUNT" -gt 1 ] |
22 |
then |
23 |
echo "-------------------- [$HIT_COUNT] --------------------" |
24 |
: $((HIT_COUNT--)) |
25 |
fi |
26 |
done |