bashใงๆธใ
UNIXๅฒๅญฆ็ใซๆฌกใฎใใใซๅ้ขใใ
็จใใAPIใฏ GET favorites/list | Twitter Developers. ใใฎAPIใฏไพใซใใฃใฆใๆ่ฟ n ๅใ ใใๅๅพใใฆ (ใใใฉใซใใงn=20ใงๆๅคง200)ใ max_id
ใๆๅฎใใใใจใงใใใใจใใใใๅคใใๆ่ฟ n ๅใๅๅพใใใจใใๅฝขใซใชใฃใฆใ.
ๆใ ใฎ็ฎ็ใจใใฆใฏใๅ จใฆๅๅพใใใ. ๅพใฃใฆใๅ จ้จๅๅพใงใใใพใงAPIใใซใผใใงๅฉใ็ถใใชใใใฐใใใชใ. ๆฌกใฎใใใซๆธใใฐใๅคๅฐใฏๅฅ้บใซๆธใใใจๆใ.
ไธ็ชๆๅใฏ
OPT=""
twurl /1.1/favorites/list.json?count=200${OPT}
ใจใใ. APIใฏใใคใผใใ่กจ็พใใใชใใธใงใฏใใๆๅใจใใ้
ๅใ่ฟใ. ้
ๅใฎๆๅพใฎๆๅใฎ .id
ใใ1ใ ใๅผใ็ฎใใใฎใใmax_id
ใจใใฆๅฉ็จใใใใจใงใ ใใฎ็ถใใๅๅพใใใฎใซไฝฟใใ.
OPT="&max_id=$(( ๆๅพใฎใใค.id - 1 ))"
twurl /1.1/favorites/list.json?count=200${OPT}
ใใใใซใผใใใ. ็ตไบๆกไปถใฏ่ฟใฃใฆใใ้ ๅใ็ฉบใงใใใใจ.
ใใกใไธ่ฆงใจใใใใใฉใไฝใๅๅพใใใฐๆๅฐ้ๅบฆๅๅใชๆ ๅ ฑใ.
ๅใใ็ๅใงใใฃใใใ
max_id
ใซๆๅฎใใidไปฅไธใฎใใฎใๆฅใใฏใใงใใใใๅถใซๅฐใๅคงใใใฎใๆฅใ. ใใจใง้่คใๅใ้คใๅฟ ่ฆใๅจใ.
GET statuses/show/:id | Twitter Developers ใฃใฆใใAPIใ่ฆใใจใ ใใคใผใใฎ id (https://twitter.com/:screen_name/status/:id
ใฎ :id
) ใ ใใใใฐๅๅใใใ.
ใพใใAPIใฏ .id
ใจใใใใใใ ๆๅญๅใซใใใ ใใฎ .id_str
ใไธ็ทใซๆธกใใฎใ้ไพใซใชใฃใฆใใ. .id
ใฏๆดๆฐใงใใใ int32
ใงใฏๅฐๅบๅใพใใใใใjq
ใฏๅฎใฏๆญปใฌ.
echo '{"x":111111111111111111111}' | jq .
{
"x": 111111111111111110000
}
ใพใ bash (zsh) ใฎ $(( ))
ใซใใๆดๆฐๆผ็ฎใๅๆงใฎ็็ฑใใไฟก็จใงใใชใ. ใใฎใใใซใ .id_str
ใใใใใใงใใใใใฝใผในใซใใฆไฟก็จใงใใใใญใปใใตใผใฎใฟใ็จใใ.
ๆๅญๅใๅใใจใใใใใซใฏใชใผใใผใทใงใณใงๆฌใใใจใใใฎใง -r
ใชใใทใงใณใงใใใๆๆญขใใ.
ใจใใใใใงใใใชในใฏใชใใใ tw-fav-list
ใจใใฆใใ.
#!/bin/bash
TMP=$(mktemp)
OPT=""
while :; do
URL="/1.1/favorites/list.json?count=200${OPT}"
twurl "$URL" | jq -r '.[].id_str' > "$TMP"
if [ ! -s "$TMP" ]; then
break
else
NEXTID=$(ruby -e "p $(tail -1 "$TMP") - 1")
OPT="&max_id=${NEXTID}"
cat "$TMP"
fi
done | sort -ur
rm "$TMP"
https://twitter.com/ily_ilyhk2/status/703932013493915648
ใๆใค็ปๅใๅๅพใใฆใฟใ. 1ใใคใผใใ่คๆฐๆๆใคใใจใใใ.
ๅใๅบใในใใฃใฝใๆๅญๅใฏใใใซใใใฎใงใ
twurl /1.1/statuses/show.json?id=703932013493915648 | jq -r '.extended_entities.media[].media_url_https'
ใจใใใฐใใ.
ๆฌกใ tw-media-list
ใจใใใ.
#!/bin/bash
twurl /1.1/statuses/show.json?id=$1 | jq -r '.extended_entities.media[].media_url_https'
ใใใฏใใ APIใๅฉใใ ใ.
ๆฌกใ tw-unfav
ใจใใ.
#!/bin/bash
twurl -X POST /1.1/favorites/destroy.json -d id=$1
tw-fav-list > fav-list.txt
for id in `cat fav-list.txt`; do tw-media-list $id; done | tee media-list.txt
wget -i media-list.txt
for id in `cat fav-list.txt`; do tw-unfav $id; done
ๅ็ป (webpๅฝขๅผใ ใฃใใใช) ใฏใใใใ ใจใตใ ใใคใซ (jpg) ใๅพใใใใฝใ