未解决 想找一个b站视频下载转发到qq群的助手
-
在隔壁群看到的,但是无论怎么搜关键字都找不到类似的,有没有用过的大佬知道
-
-
有大佬知道吗
-
我有一个用
you-get
的方法,不过不是很优雅,抛砖引玉吧object YougetCommand: SimpleCommand( owner = PluginMain, "youget", "you-get", description = "you-get" ) { private var cnt = 0 private var lock = Any() private fun getNo(): Int { synchronized(lock) { cnt += 1 return cnt } } private fun get(process: Process): String { return String(process.inputStream.readNBytes(process.inputStream.available())) } @Handler suspend fun CommandSenderOnMessage<GroupMessageEvent>.run(arg: String, refresh: Long? = null) { val cookie = if (arg.contains("bilibili")) { "/home/michael/cookies/bilibili/youget.txt" } else { null } val no = getNo() var cmdline = "you-get $arg -O /tmp/mirai-$no" if (cookie != null) { cmdline += " -c $cookie" } val f = File("/tmp/").listFiles { _, name -> name.contains("mirai-$no") }.firstOrNull() if (f != null) { f.delete() } val process = ProcessBuilder(cmdline.split(' ')).start() var title = "untitled" var s = "" while (!process.waitFor(1, TimeUnit.SECONDS)) { s += get(process) if (s.contains("Downloading ")) { fromEvent.subject.sendMessage(s.substring(0, s.lastIndexOf("\n"))) val titleLine = s.split("\n")[1] title = titleLine.substring(titleLine.lastIndexOf(' ') + 1) "\\/:*?\"<>|".forEach { title = title.replace(it, '_') } s = s.substring(s.lastIndexOf("\n") + 1) } } if (refresh != null) { do { s += get(process) val pos = s.lastIndexOf('\r') if (pos != -1) { val sub = s.substring(0, pos) val pos2 = sub.lastIndexOf('\r') s = s.substring(pos2) fromEvent.subject.sendMessage(sub.substring( pos2 + 1)) } } while(!process.waitFor(refresh, TimeUnit.SECONDS)) } else { while(!process.waitFor(1, TimeUnit.SECONDS)); } val video = File("/tmp/").listFiles { _, name -> name.contains("mirai-$no") }.firstOrNull() if (video != null) { val ext = video.extension // fromEvent.subject.sendMessage("Uploading ...") println(video.length()) fromEvent.group.files.uploadNewFile( "/$title.$ext", video.toExternalResource(ext).toAutoCloseable(), object : ProgressionCallback<AbsoluteFile, Long> { var last = 0 val tot = video.length() } ) // video.delete() } else { fromEvent.subject.sendMessage("file not found!") } } }
-
@kerwenard yunzai的R插件
-
我写过一个,不过是node的。主要的思路是先跳转获取真实地址,然后通过bvid,avid获取cid。然后通过avid和cid去请求接口