?

Log in

No account? Create an account

December 16th, 2007

fedora 蓝色小药丸

veryab (天威在线-威雅宽频影院) in fedora + firefox

前一个是 GreaseMonkey,后一个是 rtsp handler,都借助了 firebugs,谢谢华华帮我。不想做更多了,凑乎用就行。

Read more...Collapse )



update 20071227
因为 firefox 3 暂时不支持 GreaseMonkey,而且对页面好像有更高的要求,因此 javascript 没法执行了…… 用 zenity 搭配 shell 做了一个脚本,输入电影编号或者地址就可以播放了。

#!/bin/sh
READFROMFILE=
DEBUG=$READFROMFILE

function read_input
{
    while :; do
## read a number first
	INPUT=$(zenity --entry --text="输入电影编号" --entry-text="输入电影编号或网页地址")
	echo $INPUT > /dev/stderr
	if test "x$INPUT" == "x"; then
	    exit
	fi

## For a URL, get the number.
## For a number, check for range. 
	if [[ "$INPUT" =~ "^http.*=([0-9]+)$" ]]; then
	    INPUT=${BASH_REMATCH[1]}
	    echo $INPUT > /dev/stderr
	fi

	if test "x$INPUT" != "x"; then
	    break
	fi
    done
}

function read_input_stock
{
    INPUT=27672
}

function get_detail 
{
    DETAILURL=http://www.veryab.com/Movie/public/movie_detail.jsp
    CONTENT=`wget -c $DETAILURL?id=$INPUT -O - | dos2unix | iconv -f gbk -t utf8 | tee $INPUT.txt`
    echo $CONTENT > /dev/stderr
}

function get_detail_from_file
{
    CONTENT=`cat $INPUT.txt`
    echo $CONTENT > /dev/stderr
}

function parse_detail
{
    echo parse detail > /dev/stderr
    if [[ "$CONTENT" =~ ".*<span class=\"table_tx07\"><font color=\"050505\">(.*)</font></span>.*<SELECT[^>]*>(.*)</SELECT>.*<span id =\"detail\" *>(.*)(</span>)?" ]]; then
	TITLE=${BASH_REMATCH[1]}
	echo $TITLE > /dev/stderr
	OPTIONS=${BASH_REMATCH[2]}
	echo $OPTIONS > /dev/stderr
	DETAIL=${BASH_REMATCH[3]}
	echo $DETAIL > /dev/stderr
    else
	echo "error page???" > /dev/stderr
	exit
    fi
}

function show_detail
{
    QUIT=$(zenity --info --text="`echo "$DETAIL" | sed -e 's/&nbsp;//g' | sed -e 's/<BR>//g'`")
}

function get_list
{
#if [[ $OPTIONS =~ "(<OPTION[^<]*</OPTION>)" ]]; then
#	OPTIONS=("${BASH_REMATCH[@]}")
#fi

#for i in `seq ${#OPTIONS[@]}`; do
#	OPTION="${OPTIONS[$i]}"
#	if [[ $OPTION =~ "<OPTION VALUE='([0-9]+)'[^>]*>(.*)</OPTION>" ]]; then
#		LIST=("${LIST[@]}" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")
#	fi
#done

    LIST=($(echo $OPTIONS |sed -e  "s,<OPTION VALUE='\([^']*\)'[^>]*>\([^<]*\)</OPTION>,\1 \2,g"))
    echo "${LIST[@]}" > /dev/stderr
}

function get_selection
{
## prompt for information, as well as list of videos
    SELECTION=$(zenity --list --text="$TITLE" --column="id2" --column="选择" --hide-column=1 --multiple "${LIST[@]}")
    echo $SELECTION > /dev/stderr
    if test "x$SELECTION" == "x"; then
	exit
    fi
}

function do_play_selection
{
## call read_rtsp
    CONTENT=`wget -c $PLAYURL -O - | dos2unix | iconv -f gbk -t utf8 `
    echo $CONTENT > /dev/stderr
    if [[ $CONTENT =~ "(rtsp[^']*)'" ]]; then
	echo ${BASH_REMATCH[1]} > /dev/stderr
	exec ~/.local/bin/read_rtsp ${BASH_REMATCH[1]}
    fi
}

function play_selection
{
    PLAYACTIONURL=http://www.veryab.com/Movie/player/playAction.do
    for ID2 in $SELECTION; do
	PLAYURL="$PLAYACTIONURL?id=$INPUT&id2=$ID2"
	do_play_selection 
    done
## if we were wrong, still can play at least one
    if [ "x$SELECTION" == "x" ]; then
	PLAYURL=$PLAYACTIONURL?id=$INPUT
	do_play_selection
    fi
}

if [ "x$DEBUG" != "x" ] || [ "x$READFROMFILE" != "x" ]; then
    read_input_stock
    get_detail_from_file
else
    read_input
    get_detail
fi
parse_detail
#show_detail
get_list
if [ "x$DEBUG" != "x" ]; then
    exit
fi

## only prompt for selection when there are more than 1 videos
if [ ${#LIST[@]} == 2 ]; then
	    SELECTION=${LIST[0]}
	    play_selection 
elif [ ${#LIST[@]} == 0 ]; then
	    echo "no videos found??" > /dev/stderr
	    SELECTION=()
	    play_selection
else
    while :; do
	get_selection
	play_selection
    done
fi

Tags: