@@ -2,6 +2,7 @@ package io.github.gnuf0rce.mirai.netdisk
22
33import io.github.gnuf0rce.mirai.netdisk.data.*
44import io.ktor.client.*
5+ import io.ktor.client.call.*
56import io.ktor.client.engine.okhttp.*
67import io.ktor.client.plugins.*
78import io.ktor.client.plugins.compression.*
@@ -51,12 +52,11 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
5152 public val SHORT_URL_REGEX : Regex = """ (?:surl=|s/1)([A-z0-9=_-]+)\s*([A-z0-9]{4})?""" .toRegex()
5253
5354 @JvmStatic
54- public val STAND_CODE_REGEX : Regex = """ [A-z0-9]{32}#[A-z0-9]{32}#\d+#\S+""" .toRegex()
55+ public val STAND_CODE_REGEX : Regex = """ [A-z0-9]{32}#( [A-z0-9]{32}#)? \d+#\S+""" .toRegex()
5556
5657 @JvmStatic
5758 public val BD_LINK_REGEX : Regex = """ bdlink=(\S+)""" .toRegex()
5859
59-
6060 @PublishedApi
6161 internal val logger: MiraiLogger by lazy {
6262 try {
@@ -74,7 +74,7 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
7474 HttpResponseValidator {
7575 validateResponse { response ->
7676 if (response.headers[HttpHeaders .ContentType ] == " text/octet" ) {
77- val bytes = response.readBytes ()
77+ val bytes = response.body< ByteArray > ()
7878 throw ClientRequestException (response, bytes.joinToString(" " ) { " \\ x%02x" .format(it) })
7979 }
8080 }
@@ -149,9 +149,10 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
149149 }
150150 if (paths.isNotEmpty() && NetdiskUploadConfig .reply) {
151151 val info = netdisk.user()
152+ val name = info.netdiskName.ifEmpty { info.baiduName }
152153 subject.sendMessage(buildMessageChain {
153154 append(message.quote())
154- appendLine(" 分享转存到 ${info.netdiskName} 成功" )
155+ appendLine(" 分享转存到 $name 成功" )
155156 paths.forEach { path ->
156157 appendLine(path)
157158 }
@@ -172,9 +173,10 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
172173 }
173174 if (paths.isNotEmpty() && NetdiskUploadConfig .reply) {
174175 val info = netdisk.user()
176+ val name = info.netdiskName.ifEmpty { info.baiduName }
175177 subject.sendMessage(buildMessageChain {
176178 append(message.quote())
177- appendLine(" 秒传码保存到 ${info.netdiskName} 成功" )
179+ appendLine(" 秒传码保存到 $name 成功" )
178180 paths.forEach { path ->
179181 appendLine(path)
180182 }
@@ -198,9 +200,10 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
198200 }
199201 if (paths.isNotEmpty() && NetdiskUploadConfig .reply) {
200202 val info = netdisk.user()
203+ val name = info.netdiskName.ifEmpty { info.baiduName }
201204 subject.sendMessage(buildMessageChain {
202205 append(message.quote())
203- appendLine(" 秒传链接到 ${info.netdiskName} 保存成功 " )
206+ appendLine(" 秒传链接保存到 $name 成功 " )
204207 paths.forEach { path ->
205208 appendLine(path)
206209 }
@@ -312,7 +315,6 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
312315 }
313316
314317 val root = rest.view(surl = surl, key = key)
315-
316318 val dir = rest.mkdir(path = " ${LocalDate .now()} /${root.uk} _${root.shareId} " , ondup = OnDupType .NEW_COPY )
317319
318320 val info = TransferFileInfo (
@@ -329,7 +331,7 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
329331
330332 rest.transfer(info = part, path = dir.path, ondup = OnDupType .NEW_COPY )
331333
332- delay(30_000 )
334+ delay(list.size.toLong() )
333335 }
334336
335337 return dir.path
@@ -339,10 +341,10 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
339341 internal suspend fun BaiduNetDiskClient.saveRapidUpload (upload : RapidUploadInfo ): String {
340342 val path = " ${LocalDate .now()} /${upload.path} "
341343
342- mkdir(path = path.substringBeforeLast(' /' ))
344+ val dir = mkdir(path = path.substringBeforeLast(' /' ))
343345 rapid(upload = upload.copy(path = path), ondup = OnDupType .NEW_COPY )
344346
345- return path
347+ return dir. path.ifEmpty { path }
346348 }
347349
348350 private suspend fun download (urlString : String , range : LongRange ? = null): HttpStatement {
0 commit comments