|
用起来还是很方便的,- #!/bin/bash
- #Usage: getlrc 歌名 [歌手 [专辑]]
- # or: getlrc mp3文件名 [歌手 [专辑]]
- #可以设置mp3文件关联, 就可以直接用它"打开"mp3文件, 下载歌词
- #要求gnome-terminal, wget
- #lrcdir可能要适当修改.
- #by lastart@linuxisr
- export LC_CTYPE=zh_CN.GBK
- if [ "$TERM" == dumb ]
- then
- gnome-terminal -x "$0" "$@"
- exit
- fi
- logfile=/dev/null
- result=/tmp/a.htm
- cookies=/tmp/lrc_cookies
- list="/tmp/lrclist"
- lrcdir="$HOME/music/lyrics"
- lrcfile="${1%.mp3}"
- if [ "$lrcfile" == "$1" ]
- then
- lrcfile="$lrcdir/$lrcfile"
- fi
- gm="`basename "$lrcfile"`"
- gm="${gm// /+}"
- gm="${gm//_/+}"
- zj="${3// /+}"
- gs="${2// /+}"
- if [ ! -f $cookies ]
- then
- wget -o $logfile -O $logfile --keep-session-cookies --save-cookies=$cookies http://www2.5ilrc.com/souge1.asp
- fi
- searchanddown()
- {
- wget -o $logfile -O $result --load-cookies=$cookies --post-data='gm='"$gm"'&zj='"$zj"'&search=1&gs='"$gs" --referer="http://www2.5ilrc.com/souge1.asp" http://www2.5ilrc.com/souge1.asp
- echo -e "No.\t歌名\r\t\t\t专辑\r\t\t\t歌手\r\t\t\t\t\t上传者\r\t\t\t\t\t\t\t下载\t更新时间"
- riphtm "$result"
- echo -n "下载序号(r重搜):"
- read -t 10 xh
- if [ -z "$xh" ]
- then
- xh=1
- elif [ "$xh" == "r" ]
- then
- echo "输入歌名:"
- read gm
- echo "输入歌手:"
- read gs
- echo "输入专辑:"
- read zj
- searchanddown
- exit
- fi
- did=`awk 'FNR=='"$xh"' {print}' /tmp/lrclist`
- id=`echo $did|sed 's/.*ID=//;s/&.*$//'`
- if [ -z "$id" ]
- then
- exit
- fi
- #wget -O c.htm --load-cookies=/tmp/lrc_cookies --referer="http://www2.5ilrc.com/souge1.asp" http://www2.5ilrc.com/gqShow.asp?ID=239786
- if wget -o $logfile -O "$lrcfile".lrc --load-cookies=$cookies --referer="http://www2.5ilrc.com/$did" --post-data="id_gc=$id" http://www2.5ilrc.com/downlrc.asp
- then
- echo download lyric successful
- sleep 2
- exit
- fi
- }
- searchanddown
复制代码 下面是riphtm- #!/usr/bin/awk -f
- BEGIN{RS="<[Tt][Rr]>";FS="</[tT][Dd]>";i=1;printf("")>"/tmp/lrclist"}
- /点击,查看lrc格式歌词/ {lj=$1;
- gsub(".*href="","",lj);
- gsub("" target.*$","",lj);
- gm=$1;
- gsub("[ \n\r\t]*<[^>]*>[\n\r \t]*","",gm)
- zj=$2;
- gsub("[ \n\r\t]*<[^>]*>[\n\r \t]*","",zj)
- gs=$3;
- gsub("[ \n\r\t]*<[^>]*>[\n\r \t]*","",gs)
- sj=$4;
- gsub("[ \n\r\t]*<[^>]*>[\n\r \t]*","",sj)
- xz=$5;
- gsub("[ \n\r\t]*<[^>]*>[\n\r \t]*","",xz)
- scz=$6
- gsub("[ \n\r\t]*<[^>]*>[\n\r \t]*","",scz)
- print i".\t" gm"\r\t\t\t"zj"\r\t\t\t"gs"\r\t\t\t\t\t"scz"\r\t\t\t\t\t\t\t"xz"\t"sj;
- print lj >"/tmp/lrclist";
- i++;
- }
复制代码 |
|