prowong / lrcdis

Automatically exported from code.google.com/p/lrcdis
1 stars 0 forks source link

千千歌词,以及跨平台问题 #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
首先是千千歌词,就是千千静听那个。千千需要referer... 
所以后面的代码也要稍微
改一下……
另外,千千可以查歌名/歌手/歌词内容,查歌词内容这个有时
候没有歌名好,如果做
个选项就更好了……
QIANQIAN_URI(){
    local htm
    # arg1: gb-hex “artist - title” arg2: gb-hex “title”

    # qfield: 1 - title 2 - artist 3 - lyric content
    # pageflag: num of page
    htm="`wget
"http://www.qianqian.com/lrcresult.php?qfield=1&pageflag=1&qword="$2"" -q
-T 10 -O- 2>/dev/null`"
    a="http://www.qianqian.com/""`echo "$htm" | grep -Fim1 lrcresult_frame |
awk -F\\\" '{print $6}'`"
    [ "$Debug" = 1 ] && echo "A $a" >&2
    b="`wget "$a" --referer=www.qianqian.com -O- -q | grep -Fim1 downfromlrc |
awk -F\\\" '{print $6}'`"
    [ "$Debug" = 1 ] && echo "B $b" >&2
    echo -n 'http://www.qianqian.com/'"$b"
}

QIANQIAN_REFERER(){
    echo www.qianqian.com
}

...

在 DOWNLRC() 里:

    title="`echo -n "$nm" | awk -F\\\- '{print $2}'`"
    gbtitle="$(echo -n "$title" | iconv -c -t gbk | hexdump -v -e '1/1 "
%02x"' | tr " " "%")"

...

    link="`QIANQIAN_URI "$gb" "$gbtitle"`"
    referer="`QIANQIAN_REFERER`"

...
(千千的歌词好像是UTF-8的?……)
    wget "$link" --referer=$referer -T 5 -t 2 -q -O -| tr -d "\r" > "$file"

另外,我用的FreeBSD,od在这里不能按照期望的工作,所以用��
�是 hexdump -v -e
'1/1 " %02x"'
还有,head -n -1 和 tail -n +3 这样的用法这边也不行……

Original issue reported on code.google.com by Henry.Hu...@gmail.com on 1 May 2009 at 6:57

GoogleCodeExporter commented 9 years ago
改了一下,在找不到的时候换别的方法:
QIANQIAN_URI(){
    local htm
    [ "$Debug" = 1 ] && echo "gb: $1" >&2
    [ "$Debug" = 1 ] && echo "Title: $2" >&2
    # qfield: 1 - title 2 - artist 3 - lyric content
    # pageflag: num of page
    htm="`wget "http://www.qianqian.com/lrcresult.php?qfield=1&pageflag=1&qword="$2"" -q
-T 10 -O- 2>/dev/null`"
    a="http://www.qianqian.com/""`echo "$htm" | grep -Fim1 lrcresult_frame | awk -F\\\"
'{print $6}'`"
    [ "$Debug" = 1 ] && echo "A $a" >&2
    b="`wget "$a" --referer=www.qianqian.com -O- -q | grep -Fim1 downfromlrc | awk
-F\\\" '{print $6}'`"
    [ "$Debug" = 1 ] && echo "B $b" >&2
    if [ "$b" != "" ]; then
        echo -n 'http://www.qianqian.com/'"$b";
    else
        htm="`wget "http://www.qianqian.com/lrcresult.php?qfield=3&pageflag=1&qword="$1""
-q -T 10 -O- 2>/dev/null`"
        a="http://www.qianqian.com/""`echo "$htm" | grep -Fim1 lrcresult_frame | awk -F\\\"
'{print $6}'`"
        [ "$Debug" = 1 ] && echo "A $a" >&2
        b="`wget "$a" --referer=www.qianqian.com -O- -q | grep -Fim1 downfromlrc | awk
-F\\\" '{print $6}'`"
        [ "$Debug" = 1 ] && echo "B $b" >&2
        if [ "$b" != "" ]; then
            echo -n 'http://www.qianqian.com/'"$b";
        else
            htm="`wget "http://www.qianqian.com/lrcresult.php?qfield=3&pageflag=1&qword="$2""
-q -T 10 -O- 2>/dev/null`"
            a="http://www.qianqian.com/""`echo "$htm" | grep -Fim1 lrcresult_frame | awk
-F\\\" '{print $6}'`"
            [ "$Debug" = 1 ] && echo "A $a" >&2
            b="`wget "$a" --referer=www.qianqian.com -O- -q | grep -Fim1 downfromlrc | awk
-F\\\" '{print $6}'`"
            [ "$Debug" = 1 ] && echo "B $b" >&2
            if [ "$b" != "" ]; then
                echo -n 'http://www.qianqian.com/'"$b";
            fi
        fi
    fi
#   referer="www.qianqian.com"
}

Original comment by Henry.Hu...@gmail.com on 1 May 2009 at 7:29

GoogleCodeExporter commented 9 years ago
受不了这个千千歌词,emotional 
flutter直接搜歌曲名没有,搜歌词内容有…… 
而且歌曲名是对的……

Original comment by Henry.Hu...@gmail.com on 1 May 2009 at 7:31

GoogleCodeExporter commented 9 years ago
呵呵,谢谢,稍后我把你的代码合并一下.

Original comment by bones7...@gmail.com on 4 May 2009 at 6:50