From b51bfc46f2f005f4daf0e31608a441ce83c74d83 Mon Sep 17 00:00:00 2001 From: abe Date: Sun, 17 Nov 2024 23:42:49 +0100 Subject: [PATCH] refactoring --- .../com/abmo/providers/TvhaywProvider.kt | 1 - .../com/abmo/services/ProviderDispatcher.kt | 20 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/abmo/providers/TvhaywProvider.kt b/src/main/kotlin/com/abmo/providers/TvhaywProvider.kt index edcc80c..e8ebad9 100644 --- a/src/main/kotlin/com/abmo/providers/TvhaywProvider.kt +++ b/src/main/kotlin/com/abmo/providers/TvhaywProvider.kt @@ -5,7 +5,6 @@ import com.abmo.util.fetchDocument class TvhaywProvider: Provider { - // TODO: Refactor duplicated code similar to PhimbetProvider. // The logic for extracting video URLs is repeated across multiple providers. // Consider moving the common code into a shared base class or utility function to reduce duplication. override fun getVideoID(url: String): String? { diff --git a/src/main/kotlin/com/abmo/services/ProviderDispatcher.kt b/src/main/kotlin/com/abmo/services/ProviderDispatcher.kt index e05cd49..f480ecd 100644 --- a/src/main/kotlin/com/abmo/services/ProviderDispatcher.kt +++ b/src/main/kotlin/com/abmo/services/ProviderDispatcher.kt @@ -23,16 +23,18 @@ class ProviderDispatcher: KoinComponent { * @return An instance of the Provider that matches the URL's host. */ fun getProviderForUrl(url: String): Provider { - return when(url.getHost()) { - "tvphim.my", "tvphim.cx", "tvphim.id" -> TvphimProvider(javaScriptExecutor) - "sieutamphim.com" -> SieutamphimProvider() - "phimbet.biz" -> PhimbetProvider() - "fimmoi.top" -> FimmoiProvider() - "motchill.taxi", "motchill.to", "subnhanh.win" -> MotchillProvider() - "animet3.biz" -> Animet3Provider() - "tvhayw.org" -> TvhaywProvider() + url.getHost().apply { + return when { + contains("tvphim") -> TvphimProvider(javaScriptExecutor) + equals("sieutamphim.com") -> SieutamphimProvider() + equals("phimbet.biz") -> PhimbetProvider() + equals("fimmoi.top") -> FimmoiProvider() + contains("motchill") || equals("subnhanh.win") -> MotchillProvider() + equals("animet3.biz") -> Animet3Provider() + equals("tvhayw.org") -> TvhaywProvider() - else -> AbyssToProvider() + else -> AbyssToProvider() + } } }