721 名前:名無しさん@お腹いっぱい。[sage] 投稿日:2007/04/04(水) 21:23:04 ID:???0
ついでにスクリプト張っとくからUNIX触れる香具師は必死チェッカー作成よろwww
FirefoxのExtensionがいいな、ログイン状態>さっくっと動画ID入力で必死ランク表示w
Notes:
陰陽師以外で使うなら、wgetのオプションでログイン後のCookieを送り込まないと
FLVINFO取得でしくじる、その辺は課題って事で
下のコードなら--load-cookies オプションで他のブラウザから引っこ抜いたCookieを食わせりゃOKかな
_utma _utmb _utmc _utmz user_session
この5つのCookieが必要と思われ
#!/bin/sh
[ -z "$1" ] && echo "Movie ID required" && exit
# get FLV info
FLVINFO=`mktemp`
wget -O ${FLVINFO} "
http://www.nicovideo.jp/getflv?v=${1}"
[ $? -ne 0 ] && echo "Failed to get FLVINFO" && exit
# extract thread id and message server
THREAD=`cat ${FLVINFO} | sed -e "s/^thread_id=//" -e "s/\&.*//"`
SERVER=`cat ${FLVINFO} | sed -e "s/.*ms=http%3A%2F%2F//" -e "s/%2Fapi%2F\&.*//"`
echo ${THREAD} ${SERVER}
[ -e ${FLVINFO} ] && rm ${FLVINFO}
# get message xml
XML=`mktemp`
MSGCNT=500
[ ! -z ${2} ] && MSGCNT=${2}
AGENT="Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"
REQ="<thread res_from=\"-${MSGCNT}\" version=\"20061206\" thread=\"${THREAD}\" />"
wget -O ${XML} \
--post-data="${REQ}" \
--user-agent="${AGENT}" \
http://${SERVER}/api/ [ $? -ne 0 ] && echo "Failed to get Message XML" && [ -e ${XML} ] && rm ${XML} && exit
# convert
sed 's/<\/chat>/&\
/g' ${XML} > ${THREAD}.xml
[ -e ${XML} ] && rm ${XML}
# extract uniq map
grep "user_id=" ${THREAD}.xml | sed -e "s/.*user_id=\"//" -e "s/\".*//" | sort -n | uniq > ${THREAD}.id
# post count (lol check)
cat ${THREAD}.id | while read id; do
echo -n "${id} "
grep "user_id=\"${id}\"" ${THREAD}.xml | wc -l
done | sort -n -t ' ' -k 2 -r > ${THREAD}.cnt
# EOF