- //歌词合并精简.js//拖入歌词文件
- lrcfile = WScript.Arguments(0);
-
- Rstream = new ActiveXObject("ADODB.Stream");
- Rstream.Type=2; //类型1是二进制,2是文本
- Rstream.Charset = "GBK";
- Rstream.Open;
-
- Rstream.LoadFromFile(lrcfile); //读歌词文件
- var i=n=tflag=sflag=lflag=0;
- var btime=[],lyric=[],tmpTime=rchr='';
- while(!Rstream.EOS){
- Rchar=Rstream.ReadText(1);
- rchr+=Rchar;
-
- if(tflag && Rchar==']'){ //时间末,词始
- tmpTime+=rchr;rchr='';tflag=0,sflag=1;
- }else if(sflag && Rchar=='\n'){ //词末
- tmpLrc=rchr;sflag=lflag=0;
- for(i=1;i<=n;i++){ //检查重复词
- if(lyric[i]==tmpLrc){lflag=1;break;}
- }
- if(lflag){btime[i]+=tmpTime;} //合并时间
- else{n++;lyric[n]=tmpLrc;btime[n]=tmpTime;}
- rchr=tmpTime='';
- }else if(Rchar=='[')tflag=1; //时间始
- }
- Rstream.Close;
-
- joinLrc='歌词文件:'+lrcfile+'\n\n';
- for(i=1;i<=n;i++){
- joinLrc+=btime[i]+lyric[i];
- }
- WSH.Echo(joinLrc); //显示精简后歌词
复制代码
|