diff --git a/backend/src/main/kotlin/de/randomerror/ytsync/Queue.kt b/backend/src/main/kotlin/de/randomerror/ytsync/Queue.kt index 73513bf..45c9951 100644 --- a/backend/src/main/kotlin/de/randomerror/ytsync/Queue.kt +++ b/backend/src/main/kotlin/de/randomerror/ytsync/Queue.kt @@ -10,8 +10,12 @@ import kotlin.text.RegexOption.IGNORE_CASE private val youtubeUrlRegex: Regex = Regex("""https://(?:www\.)?youtu(?:\.be|be\.com)/(?:watch\?v=|embed/|shorts/)?([^?&]+)(?:.*)?""", IGNORE_CASE) + +private const val FETCHER_CORE_POOL = 4 +private const val FETCHER_MAX_POOL = 16 +private const val FETCHER_KEEPALIVE_SECONDS = 60L private val videoInfoFetcher: ExecutorService = - ThreadPoolExecutor(4, 16, 60L, SECONDS, LinkedBlockingQueue()) + ThreadPoolExecutor(FETCHER_CORE_POOL, FETCHER_MAX_POOL, FETCHER_KEEPALIVE_SECONDS, SECONDS, LinkedBlockingQueue()) fun enqueue(session: Session, query: String): String { val room = getRoom(session) diff --git a/backend/src/main/kotlin/de/randomerror/ytsync/VideoInfo.kt b/backend/src/main/kotlin/de/randomerror/ytsync/VideoInfo.kt index ff36d6f..a981143 100644 --- a/backend/src/main/kotlin/de/randomerror/ytsync/VideoInfo.kt +++ b/backend/src/main/kotlin/de/randomerror/ytsync/VideoInfo.kt @@ -35,7 +35,7 @@ fun fetchVideoInfo(query: String, youtubeId: String?): QueueItem? { private fun fetchVideoInfoYouTubeOEmbed(query: String, youtubeId: String): QueueItem? { val videoData = try { URL("https://www.youtube.com/oembed?url=$query").readText() - } catch (e: FileNotFoundException) { + } catch (ignored: FileNotFoundException) { return null } return try {