[Asm] 纯文本查看 复制代码
import win.ui;
import inet.http;
import string.html;
import process.batch;
/*DSG{{*/
mainForm = win.form(text="ahedu下载";right=757;bottom=408;border="dialog frame";max=false)
mainForm.add(
button={cls="button";text="原件下载";left=236;top=342;right=341;bottom=397;z=2};
button2={cls="button";text="阅读下载";left=415;top=342;right=520;bottom=397;z=4};
button3={cls="button";text="左清空";left=348;top=99;right=408;bottom=143;z=5};
button4={cls="button";text="右清空";left=348;top=218;right=408;bottom=262;z=8};
edit={cls="edit";left=415;top=36;right=734;bottom=329;edge=1;frame=1;multiline=1;z=3};
edit2={cls="edit";left=22;top=36;right=341;bottom=329;edge=1;frame=1;multiline=1;z=1};
static={cls="static";text="链接";left=136;top=4;right=218;bottom=28;align="center";center=1;font=LOGFONT(h=-18);notify=1;transparent=1;z=6};
static3={cls="static";text="结果";left=535;top=4;right=617;bottom=28;align="center";center=1;font=LOGFONT(h=-18);transparent=1;z=7}
)
/*}}*/
import win.ui.tooltip;
var tooltipCtrl = win.ui.tooltip( mainForm );
tooltipCtrl.addTool(mainForm.edit2,"一行一条链接" )
tooltipCtrl.addTool(mainForm.button,"原始文件调用idm批量下载" )
tooltipCtrl.addTool(mainForm.button2,"阅读文件调用idm批量下载(一般为pdf或mp4)" )
tooltipCtrl.addTool(mainForm.static,"只支持链接中带有activityId和productionId参数的链接" )
//获取idm路径
import process.cache
var path = process.cache.find("IDMan.exe")
//获取文件名和后缀
getFileName = function(url){
var http = inet.http();
http.beginRequest(url);
http.send()
var h = http.readHeaderContent();
var filename = h ? h.disposition ? h.disposition.filename;
http.close()
if( !filename ){
var turl = inet.url.split(url);
if(!turl) return;
var tpath = io.splitpath( turl.path )
return tpath.file;
}
return filename
}
//链接批量
FXurl = function(url){
var u=1
var fxurl={}
var o=string.split(url,'\r\n')
for(i=1;#o){
if(string.find(o[i],"http")){
fxurl[u]=o[i]
u=u+1
}
}
return fxurl
}
//原件下载
mainForm.button.oncommand = function(id,event){
mainForm.edit.text=""
var f = FXurl(mainForm.edit2.text)
for(i=1;#f){
var activityId = string.match(f[i],'activityId.(.*?)&')
var productionId = string.match(f[i],'productionId.(.*?)$')
var html = inet.http().post("https://www.ahedu.cn/showme/production/getInfo",'{"activityId":"'++activityId++'","productionId":"'++productionId++'"}',"Content-Type: application/json;charset=UTF-8","",);
var u1n = string.match(string.html.ncr(html),'"productionName"."(.*?)"')
var u2 = string.html.ncr(html)
for(j=1;#string.matches(u2,'"savaPath"."(.*?)"')){
var u2n = string.matches(u2,'"fileName"."(.*?)"')[j][1]
mainForm.edit.print(i++"、"++u2n)
var u3 = string.matches(u2,'"savaPath"."(.*?)"')[j][1]
//批量发送idm
process.batch('"'++path++'" /d "'++u3++'" /p "'++io._exedir++"原件下载\"++u1n++'" /f "'++u2n++'"'++' /a "'++u2n++'"')
}
}
mainForm.edit.print("end")
}
//阅读下载
mainForm.button2.oncommand = function(id,event){
mainForm.edit.text=""
var f = FXurl(mainForm.edit2.text)
for(i=1;#f){
var activityId = string.match(f[i],'activityId.(.*?)&')
var productionId = string.match(f[i],'productionId.(.*?)$')
var html = inet.http().post("https://www.ahedu.cn/showme/production/getInfo",'{"activityId":"'++activityId++'","productionId":"'++productionId++'"}',"Content-Type: application/json;charset=UTF-8","",);
var u1n = string.match(string.html.ncr(html),'"productionName"."(.*?)"')
var u2 = string.html.ncr(html)
for(j=1;#string.matches(u2,'"previewUrl"."(.*?)"')){
var u2n = string.replace(string.left(string.matches(u2,'"fileName"."(.*?)"')[j][1],-5,true)++"."++string.split(getFileName(string.matches(u2,'"previewUrl"."(.*?)"')[j][1]),".")[2],"@..",".")
mainForm.edit.print(i++"、"++u2n)
var u3 = string.matches(u2,'"previewUrl"."(.*?)"')[j][1]
//批量发送idm
process.batch('"'++path++'" /d "'++u3++'" /p "'++io._exedir++"阅读下载\"++u1n++'" /f "'++u2n++'"'++' /a "'++u2n++'"')
}
}
mainForm.edit.print("end")
}
mainForm.button3.oncommand = function(id,event){
mainForm.edit2.text=""
}
mainForm.button4.oncommand = function(id,event){
mainForm.edit.text=""
}
mainForm.show();
win.loopMessage();