diff --git a/Tvtwofourseven/build.gradle.kts b/Tvtwofourseven/build.gradle.kts
new file mode 100644
index 0000000..fa8d9cb
--- /dev/null
+++ b/Tvtwofourseven/build.gradle.kts
@@ -0,0 +1,22 @@
+// use an integer for version numbers
+version = 1
+
+
+cloudstream {
+ language = "en"
+ // All of these properties are optional, you can safely remove them
+
+ // description = "Lorem Ipsum"
+ authors = listOf("Hexated")
+
+ /**
+ * Status int as the following:
+ * 0: Down
+ * 1: Ok
+ * 2: Slow
+ * 3: Beta only
+ * */
+ status = 1 // will be 3 if unspecified
+ tvTypes = listOf("Live")
+ iconUrl = "https://www.google.com/s2/favicons?domain=tv247.us&sz=%size%"
+}
\ No newline at end of file
diff --git a/Tvtwofourseven/src/main/AndroidManifest.xml b/Tvtwofourseven/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..29aec9d
--- /dev/null
+++ b/Tvtwofourseven/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/Tvtwofourseven/src/main/kotlin/com/lagradost/Tvtwofourseven.kt b/Tvtwofourseven/src/main/kotlin/com/lagradost/Tvtwofourseven.kt
new file mode 100644
index 0000000..d709298
--- /dev/null
+++ b/Tvtwofourseven/src/main/kotlin/com/lagradost/Tvtwofourseven.kt
@@ -0,0 +1,115 @@
+package com.lagradost
+
+import com.lagradost.cloudstream3.*
+import com.lagradost.cloudstream3.utils.ExtractorLink
+import com.lagradost.cloudstream3.utils.M3u8Helper
+import com.lagradost.cloudstream3.utils.Qualities
+import org.jsoup.nodes.Element
+import java.net.URI
+
+class Tvtwofourseven : MainAPI() {
+ override var mainUrl = "http://tv247.us"
+ override var name = "Tv247"
+ override val hasDownloadSupport = false
+ override val hasMainPage = true
+ override val supportedTypes = setOf(
+ TvType.Live
+ )
+
+ override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
+ val homePageList = ArrayList()
+ listOf(
+ Pair("$mainUrl/top-channels", "Top Channels"),
+ Pair("$mainUrl/all-channels", "All Channels")
+ ).apmap {
+ val home =
+ app.get(it.first).document.select("div.grid-items div.item").mapNotNull { item ->
+ item.toSearchResult()
+ }
+ if (home.isNotEmpty()) homePageList.add(HomePageList(it.second, home, true))
+ }
+ return HomePageResponse(homePageList)
+ }
+
+ private fun Element.toSearchResult(): LiveSearchResponse? {
+ return LiveSearchResponse(
+ this.selectFirst("div.layer-content a")?.text() ?: return null,
+ fixUrl(this.selectFirst("a")!!.attr("href")),
+ this@Tvtwofourseven.name,
+ TvType.Live,
+ fixUrlNull(this.select("img").attr("src")),
+ )
+
+ }
+
+ override suspend fun search(query: String): List? {
+ return app.post(
+ "$mainUrl/wp-admin/admin-ajax.php", data = mapOf(
+ "action" to "ajaxsearchlite_search",
+ "aslp" to query,
+ "asid" to "1",
+ "options" to "qtranslate_lang=0&set_intitle=None&set_incontent=None&set_inposts=None"
+ ),
+ headers = mapOf("X-Requested-With" to "XMLHttpRequest")
+ ).document.select("div.item").mapNotNull {
+ LiveSearchResponse(
+ it.selectFirst("a")?.text() ?: return null,
+ fixUrl(it.selectFirst("a")!!.attr("href")),
+ this@Tvtwofourseven.name,
+ TvType.Live,
+ fixUrlNull(
+ it.select("div.asl_image").attr("style").substringAfter("url(\"")
+ .substringBefore("\");")
+ )
+ )
+ }
+ }
+
+ override suspend fun load(url: String): LoadResponse? {
+ val document = app.get(url).document
+ val data =
+ document.select("script").find { it.data().contains("var channelName =") }?.data()
+ val baseUrl = data?.substringAfter("baseUrl = \"")?.substringBefore("\";")
+ val channel = data?.substringAfter("var channelName = \"")?.substringBefore("\";")
+ return LiveStreamLoadResponse(
+ document.selectFirst("title")?.text()?.split("-")?.first()?.trim() ?: return null,
+ url,
+ this.name,
+ "$baseUrl$channel.m3u8",
+ fixUrlNull(document.selectFirst("img.aligncenter.jetpack-lazy-image")?.attr("src")),
+ plot = document.select("address").text()
+ )
+ }
+
+ override suspend fun loadLinks(
+ data: String,
+ isCasting: Boolean,
+ subtitleCallback: (SubtitleFile) -> Unit,
+ callback: (ExtractorLink) -> Unit
+ ): Boolean {
+
+ if (URI(data).host == "cdn.espnfree.xyz") {
+ M3u8Helper.generateM3u8(
+ this.name,
+ data,
+ "$mainUrl/",
+ headers = mapOf("Origin" to mainUrl, "X-Cache" to "HIT"),
+ ).forEach(callback)
+ } else {
+ callback.invoke(
+ ExtractorLink(
+ source = name,
+ name = name,
+ url = data,
+ referer = "$mainUrl/",
+ quality = Qualities.Unknown.value,
+ isM3u8 = true,
+ headers = mapOf("Origin" to mainUrl)
+ )
+ )
+ }
+
+ return true
+
+ }
+}
\ No newline at end of file
diff --git a/Tvtwofourseven/src/main/kotlin/com/lagradost/TvtwofoursevenPlugin.kt b/Tvtwofourseven/src/main/kotlin/com/lagradost/TvtwofoursevenPlugin.kt
new file mode 100644
index 0000000..c9f7ef9
--- /dev/null
+++ b/Tvtwofourseven/src/main/kotlin/com/lagradost/TvtwofoursevenPlugin.kt
@@ -0,0 +1,14 @@
+
+package com.lagradost
+
+import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
+import com.lagradost.cloudstream3.plugins.Plugin
+import android.content.Context
+
+@CloudstreamPlugin
+class TvtwofoursevenPlugin: Plugin() {
+ override fun load(context: Context) {
+ // All providers should be added in this manner. Please don't edit the providers list directly.
+ registerMainAPI(Tvtwofourseven())
+ }
+}
\ No newline at end of file