「bilibili」- 视频下载

  CREATED BY JENKINSBOT

提取视频集合标题

v0.0.1

var titleList = ""
$x('//div[@class="link-content"]').forEach((element) => {titleList = titleList + element.innerText.replace("\n", "-") + "\n"})
console.log(titleList)

v0.1.0

在脚本中使用:

var cmds = ""
document.getElementById("multi_page").getElementsByClassName("list-box")[0].getElementsByTagName("a").forEach(function(element){
    // cmds += "touch '" + element.getElementsByClassName("page-num")[0].innerText + " " + element.title + ".flv'" + "\n"
    cmds += element.getElementsByClassName("page-num")[0].innerText + " " + element.title + "\n"
})
console.log(cmds)

v1.0.0(DEPRECATED)

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

async function waitDownloadLink() {
    var shellCommands = ""
    
    // 1、找到所有的视频
    var videoList = document.getElementById("multi_page").getElementsByClassName("list-box")[0].getElementsByTagName("a")
    
    // 2、生成所有视频的链接
	videoList.forEach(function(aTag){
		// 视频信息
		var videoLink = aTag.href
		var videoName = aTag.getElementsByClassName("page-num")[0].innerText + " " + aTag.title + ".flv"
		console.log( videoLink + ", " + videoName)
		
		// 3、加载页面,捕获地址,生成命令
		window.location.href = videoLink
		var downloadLink = waitDownloadLink()
		console.log("wget -O " + downloadLink) 
	})

    while(true){
        await sleep(2000);
  		var link = $x("//*[contains(text(), '下载视频 ')]")
  		if (link.size >0) {
           return link[0].href
       }
    }
}