diff --git a/src/main/kotlin/com/abmo/services/VideoDownloader.kt b/src/main/kotlin/com/abmo/services/VideoDownloader.kt index 2e8e7d7..e7bd321 100644 --- a/src/main/kotlin/com/abmo/services/VideoDownloader.kt +++ b/src/main/kotlin/com/abmo/services/VideoDownloader.kt @@ -1,9 +1,8 @@ package com.abmo.services import com.abmo.common.Logger -import com.abmo.model.* import com.abmo.crypto.CryptoHelper -import com.abmo.executor.JavaScriptExecutor +import com.abmo.model.* import com.abmo.util.displayProgressBar import com.abmo.util.toJson import com.abmo.util.toReadableTime @@ -125,7 +124,7 @@ class VideoDownloader: KoinComponent { * * @param segmentFolderPath The folder containing the video segments. * @param output The output file where the merged segments will be written. - * @throws IOException If there is an error reading or writing the segment files. + * @throws Exception If there is an error reading or writing the segment files. */ private fun mergeSegmentsIntoMp4(segmentFolderPath: File, output: File) { val segmentFiles = segmentFolderPath.listFiles { file -> file.name.startsWith("segment_") } @@ -269,7 +268,7 @@ class VideoDownloader: KoinComponent { * @throws Exception If the request fails or the response status is not successful. */ private suspend fun requestSegment(url: String, body: String, index: Int? = null): Flow = flow { - println("\n") +// println("\n") Logger.debug("[$index] Starting HTTP POST request to $url with body length: ${body.length}. Body (truncated): \"...$body") val response = Unirest.post(url) .header("Content-Type", "application/json") @@ -279,7 +278,7 @@ class VideoDownloader: KoinComponent { val rawBody = response.rawBody val responseCode = response.status - println("\n") +// println("\n") Logger.debug("[$index] Received response with status $responseCode\n", responseCode !in 200..299) val buffer = ByteArray(65536) diff --git a/src/main/kotlin/com/abmo/util/Extensions.kt b/src/main/kotlin/com/abmo/util/Extensions.kt index a606e3e..e3432fa 100644 --- a/src/main/kotlin/com/abmo/util/Extensions.kt +++ b/src/main/kotlin/com/abmo/util/Extensions.kt @@ -14,7 +14,7 @@ fun Any.toJson(): String = Gson().toJson(this) * * @return The parsed `Document` object representing the HTML content. * @throws IllegalArgumentException if the URL is malformed or cannot be accessed. - * @throws IOException if an I/O error occurs while attempting to retrieve the document. + * @throws Exception if an I/O error occurs while attempting to retrieve the document. */ fun String.fetchDocument(): Document = Jsoup.connect(this).get() @@ -32,7 +32,7 @@ fun String.toJsoupDocument(): Document = Jsoup.parse(this) * @return The corresponding value as a String, or null if not found. */ fun String.findValueByKey(key: String): String? { - val regex = """"$key"\s*:\s*("(?:[^"\\]*(?:\\.[^"\\]*)*)"|[^\s,}]+)""".toRegex() + val regex = """"$key"\s*:\s*("[^"\\]*(?:\\.[^"\\]*)*"|[^\s,}]+)""".toRegex() val matchResult = regex.find(this) return matchResult?.groupValues?.get(1)?.let { if (it.startsWith("\"") && it.endsWith("\"")) {