Last active
August 7, 2023 08:09
-
-
Save Sg4Dylan/139b0e22b255389f3cd7c185638da28e to your computer and use it in GitHub Desktop.
导出 biliplus 下载链接,并简单合并下载的视频分片
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 显示下载链接的侧边栏加载完成后,在 Console 复制这段 JS 并执行 | |
// 执行完成后,鼠标选中一组链接,ctrl+c 复制到 aria2 即可批量下载视频 | |
// 格式化版 | |
var total_area = document.getElementById('geturl_content'); | |
var split_area = total_area.getElementsByTagName('div'); | |
var itemDocs = []; | |
for (let i=0;i<split_area.length;i++) { | |
if(split_area[i].style[0]=="width") { | |
itemDocs.push(split_area[i]); | |
} | |
} | |
for (let i=0;i<itemDocs.length;i++) { | |
let result = decodeURIComponent(itemDocs[0].getElementsByTagName('input')[0].value.replace(/\|/g,'\r\n')); | |
console.log("自上而下,第",i+1,"个"); | |
console.log(result); | |
} | |
// 压缩版 | |
var ta=document.getElementById('geturl_content');var sa=ta.getElementsByTagName('div');var ids=[];for(let i=0;i<sa.length;i++){if(sa[i].style[0]=="width"){ids.push(sa[i])}}for(let i=0;i<ids.length;i++){let rs=decodeURIComponent(ids[0].getElementsByTagName('input')[0].value.replace(/\|/g,'\r\n'));console.log("自上而下,第",i+1,"个");console.log(rs)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 仅适用于B站的视频自动合并脚本 | |
# 需要文件名模式为 $CID-$Index-$N.flv 或 $CID-$Index.flv | |
# 例如 12345-1-12.flv 或 12345-1.flv | |
# 使用方式: | |
# 复制本文件及 mkvmerge 到待合并视频目录,双击执行脚本即可 | |
import os | |
# 检查是否有 mkvmerge | |
if not os.path.exists('mkvmerge.exe'): | |
print("脚本缺少必要的 mkvmerge") | |
os.system("pause") | |
exit(1) | |
# 取得当前目录下的文件列表 | |
orig_list = os.listdir() | |
# 从列表移除并非视频分片的部分 | |
for item in os.listdir(): | |
if item.endswith('.flv'): | |
continue | |
orig_list.remove(item) | |
# 检查合并条件 | |
if len(orig_list) <= 1: | |
print("检测到只有%d个文件,大概没有合并的必要" % len(orig_list)) | |
os.system("pause") | |
exit(1) | |
# 装配合并命令中输入文件的部分 | |
name_split = orig_list[0].split('-',2) | |
filelist = [] | |
for i in range(1, len(orig_list)+1): | |
if len(name_split) == 3: | |
filelist.append("-".join([name_split[0],str(i),name_split[2]])) | |
elif len(name_split) == 2: | |
filelist.append("-".join(name_split)) | |
# 合并命令模板 | |
command_pattern = "mkvmerge -o %s %s" | |
output_name = name_split[0]+'.mkv' | |
file_combine = " + ".join(filelist) | |
# 避免覆盖文件 | |
if os.path.exists(output_name): | |
print("检测到输出文件已存在,操作中断") | |
os.system("pause") | |
exit(1) | |
# 执行合并命令 | |
os.system(command_pattern % (name_split[0]+'.mkv',file_combine)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment