From d6f89c399b766c8ddf94bb6384b571e991903c8a Mon Sep 17 00:00:00 2001
From: C10udburst <18114966+C10udburst@users.noreply.github.com>
Date: Wed, 17 Aug 2022 11:23:26 +0200
Subject: [PATCH] fix a few providers, closes #3
---
.../kotlin/com/lagradost/BflixProvider.kt | 6 +-
.../com/lagradost/BflixProviderPlugin.kt | 2 +
.../kotlin/com/lagradost/FmoviesToProvider.kt | 0
.../main/kotlin/com/lagradost/NineAnimeApi.kt | 112 ++++++++++++++++++
.../kotlin/com/lagradost/SflixProProvider.kt | 0
FmoviesToProvider/build.gradle.kts | 22 ----
.../src/main/AndroidManifest.xml | 2 -
.../com/lagradost/FmoviesToProviderPlugin.kt | 14 ---
HDTodayProvider/build.gradle.kts | 22 ----
HDTodayProvider/src/main/AndroidManifest.xml | 2 -
.../com/lagradost/HDTodayProviderPlugin.kt | 14 ---
SflixProProvider/build.gradle.kts | 22 ----
SflixProProvider/src/main/AndroidManifest.xml | 2 -
.../com/lagradost/SflixProProviderPlugin.kt | 14 ---
.../kotlin/com/lagradost/HDTodayProvider.kt | 0
.../com/lagradost/SflixProviderPlugin.kt | 1 +
settings.gradle.kts | 7 +-
17 files changed, 119 insertions(+), 123 deletions(-)
rename {FmoviesToProvider => BflixProvider}/src/main/kotlin/com/lagradost/FmoviesToProvider.kt (100%)
create mode 100644 BflixProvider/src/main/kotlin/com/lagradost/NineAnimeApi.kt
rename {SflixProProvider => BflixProvider}/src/main/kotlin/com/lagradost/SflixProProvider.kt (100%)
delete mode 100644 FmoviesToProvider/build.gradle.kts
delete mode 100644 FmoviesToProvider/src/main/AndroidManifest.xml
delete mode 100644 FmoviesToProvider/src/main/kotlin/com/lagradost/FmoviesToProviderPlugin.kt
delete mode 100644 HDTodayProvider/build.gradle.kts
delete mode 100644 HDTodayProvider/src/main/AndroidManifest.xml
delete mode 100644 HDTodayProvider/src/main/kotlin/com/lagradost/HDTodayProviderPlugin.kt
delete mode 100644 SflixProProvider/build.gradle.kts
delete mode 100644 SflixProProvider/src/main/AndroidManifest.xml
delete mode 100644 SflixProProvider/src/main/kotlin/com/lagradost/SflixProProviderPlugin.kt
rename {HDTodayProvider => SflixProvider}/src/main/kotlin/com/lagradost/HDTodayProvider.kt (100%)
diff --git a/BflixProvider/src/main/kotlin/com/lagradost/BflixProvider.kt b/BflixProvider/src/main/kotlin/com/lagradost/BflixProvider.kt
index 1129895..98dc3bb 100644
--- a/BflixProvider/src/main/kotlin/com/lagradost/BflixProvider.kt
+++ b/BflixProvider/src/main/kotlin/com/lagradost/BflixProvider.kt
@@ -2,9 +2,9 @@ package com.lagradost
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.*
-import com.lagradost.cloudstream3.animeproviders.NineAnimeProvider.Companion.decodeVrf
-import com.lagradost.cloudstream3.animeproviders.NineAnimeProvider.Companion.encode
-import com.lagradost.cloudstream3.animeproviders.NineAnimeProvider.Companion.encodeVrf
+import com.lagradost.NineAnimeApi.decodeVrf
+import com.lagradost.NineAnimeApi.encode
+import com.lagradost.NineAnimeApi.encodeVrf
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor
diff --git a/BflixProvider/src/main/kotlin/com/lagradost/BflixProviderPlugin.kt b/BflixProvider/src/main/kotlin/com/lagradost/BflixProviderPlugin.kt
index fd7de36..8379bea 100644
--- a/BflixProvider/src/main/kotlin/com/lagradost/BflixProviderPlugin.kt
+++ b/BflixProvider/src/main/kotlin/com/lagradost/BflixProviderPlugin.kt
@@ -10,5 +10,7 @@ class BflixProviderPlugin: Plugin() {
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(BflixProvider())
+ registerMainAPI(FmoviesToProvider())
+ registerMainAPI(SflixProProvider())
}
}
\ No newline at end of file
diff --git a/FmoviesToProvider/src/main/kotlin/com/lagradost/FmoviesToProvider.kt b/BflixProvider/src/main/kotlin/com/lagradost/FmoviesToProvider.kt
similarity index 100%
rename from FmoviesToProvider/src/main/kotlin/com/lagradost/FmoviesToProvider.kt
rename to BflixProvider/src/main/kotlin/com/lagradost/FmoviesToProvider.kt
diff --git a/BflixProvider/src/main/kotlin/com/lagradost/NineAnimeApi.kt b/BflixProvider/src/main/kotlin/com/lagradost/NineAnimeApi.kt
new file mode 100644
index 0000000..c40dd67
--- /dev/null
+++ b/BflixProvider/src/main/kotlin/com/lagradost/NineAnimeApi.kt
@@ -0,0 +1,112 @@
+package com.lagradost
+
+// taken from https://github.com/saikou-app/saikou/blob/b35364c8c2a00364178a472fccf1ab72f09815b4/app/src/main/java/ani/saikou/parsers/anime/NineAnime.kt
+// GNU General Public License v3.0 https://github.com/saikou-app/saikou/blob/main/LICENSE.md
+object NineAnimeApi {
+ private const val nineAnimeKey =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
+ private const val cipherKey = "kMXzgyNzT3k5dYab"
+
+ fun encodeVrf(text: String, mainKey: String): String {
+ return encode(
+ encrypt(
+ cipher(mainKey, encode(text)),
+ nineAnimeKey
+ )//.replace("""=+$""".toRegex(), "")
+ )
+ }
+
+ fun decodeVrf(text: String, mainKey: String): String {
+ return decode(cipher(mainKey, decrypt(text, nineAnimeKey)))
+ }
+
+ fun encrypt(input: String, key: String): String {
+ if (input.any { it.code > 255 }) throw Exception("illegal characters!")
+ var output = ""
+ for (i in input.indices step 3) {
+ val a = intArrayOf(-1, -1, -1, -1)
+ a[0] = input[i].code shr 2
+ a[1] = (3 and input[i].code) shl 4
+ if (input.length > i + 1) {
+ a[1] = a[1] or (input[i + 1].code shr 4)
+ a[2] = (15 and input[i + 1].code) shl 2
+ }
+ if (input.length > i + 2) {
+ a[2] = a[2] or (input[i + 2].code shr 6)
+ a[3] = 63 and input[i + 2].code
+ }
+ for (n in a) {
+ if (n == -1) output += "="
+ else {
+ if (n in 0..63) output += key[n]
+ }
+ }
+ }
+ return output
+ }
+
+ fun cipher(key: String, text: String): String {
+ val arr = IntArray(256) { it }
+
+ var u = 0
+ var r: Int
+ arr.indices.forEach {
+ u = (u + arr[it] + key[it % key.length].code) % 256
+ r = arr[it]
+ arr[it] = arr[u]
+ arr[u] = r
+ }
+ u = 0
+ var c = 0
+
+ return text.indices.map { j ->
+ c = (c + 1) % 256
+ u = (u + arr[c]) % 256
+ r = arr[c]
+ arr[c] = arr[u]
+ arr[u] = r
+ (text[j].code xor arr[(arr[c] + arr[u]) % 256]).toChar()
+ }.joinToString("")
+ }
+
+ @Suppress("SameParameterValue")
+ private fun decrypt(input: String, key: String): String {
+ val t = if (input.replace("""[\t\n\f\r]""".toRegex(), "").length % 4 == 0) {
+ input.replace("""==?$""".toRegex(), "")
+ } else input
+ if (t.length % 4 == 1 || t.contains("""[^+/0-9A-Za-z]""".toRegex())) throw Exception("bad input")
+ var i: Int
+ var r = ""
+ var e = 0
+ var u = 0
+ for (o in t.indices) {
+ e = e shl 6
+ i = key.indexOf(t[o])
+ e = e or i
+ u += 6
+ if (24 == u) {
+ r += ((16711680 and e) shr 16).toChar()
+ r += ((65280 and e) shr 8).toChar()
+ r += (255 and e).toChar()
+ e = 0
+ u = 0
+ }
+ }
+ return if (12 == u) {
+ e = e shr 4
+ r + e.toChar()
+ } else {
+ if (18 == u) {
+ e = e shr 2
+ r += ((65280 and e) shr 8).toChar()
+ r += (255 and e).toChar()
+ }
+ r
+ }
+ }
+
+ fun encode(input: String): String =
+ java.net.URLEncoder.encode(input, "utf-8").replace("+", "%20")
+
+ private fun decode(input: String): String = java.net.URLDecoder.decode(input, "utf-8")
+}
\ No newline at end of file
diff --git a/SflixProProvider/src/main/kotlin/com/lagradost/SflixProProvider.kt b/BflixProvider/src/main/kotlin/com/lagradost/SflixProProvider.kt
similarity index 100%
rename from SflixProProvider/src/main/kotlin/com/lagradost/SflixProProvider.kt
rename to BflixProvider/src/main/kotlin/com/lagradost/SflixProProvider.kt
diff --git a/FmoviesToProvider/build.gradle.kts b/FmoviesToProvider/build.gradle.kts
deleted file mode 100644
index b650f38..0000000
--- a/FmoviesToProvider/build.gradle.kts
+++ /dev/null
@@ -1,22 +0,0 @@
-// use an integer for version numbers
-version = 1
-
-
-cloudstream {
- // All of these properties are optional, you can safely remove them
-
- // description = "Lorem Ipsum"
- // authors = listOf("Cloudburst")
-
- /**
- * Status int as the following:
- * 0: Down
- * 1: Ok
- * 2: Slow
- * 3: Beta only
- * */
- status = 1 // will be 3 if unspecified
-
-
- iconUrl = "https://www.google.com/s2/favicons?domain=fmovies.to&sz=24"
-}
\ No newline at end of file
diff --git a/FmoviesToProvider/src/main/AndroidManifest.xml b/FmoviesToProvider/src/main/AndroidManifest.xml
deleted file mode 100644
index 29aec9d..0000000
--- a/FmoviesToProvider/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/FmoviesToProvider/src/main/kotlin/com/lagradost/FmoviesToProviderPlugin.kt b/FmoviesToProvider/src/main/kotlin/com/lagradost/FmoviesToProviderPlugin.kt
deleted file mode 100644
index ef02c37..0000000
--- a/FmoviesToProvider/src/main/kotlin/com/lagradost/FmoviesToProviderPlugin.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-
-package com.lagradost
-
-import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
-import com.lagradost.cloudstream3.plugins.Plugin
-import android.content.Context
-
-@CloudstreamPlugin
-class FmoviesToProviderPlugin: Plugin() {
- override fun load(context: Context) {
- // All providers should be added in this manner. Please don't edit the providers list directly.
- registerMainAPI(FmoviesToProvider())
- }
-}
\ No newline at end of file
diff --git a/HDTodayProvider/build.gradle.kts b/HDTodayProvider/build.gradle.kts
deleted file mode 100644
index 86c8ff4..0000000
--- a/HDTodayProvider/build.gradle.kts
+++ /dev/null
@@ -1,22 +0,0 @@
-// use an integer for version numbers
-version = 1
-
-
-cloudstream {
- // All of these properties are optional, you can safely remove them
-
- // description = "Lorem Ipsum"
- // authors = listOf("Cloudburst")
-
- /**
- * Status int as the following:
- * 0: Down
- * 1: Ok
- * 2: Slow
- * 3: Beta only
- * */
- status = 1 // will be 3 if unspecified
-
-
- iconUrl = "https://www.google.com/s2/favicons?domain=hdtoday.cc&sz=24"
-}
\ No newline at end of file
diff --git a/HDTodayProvider/src/main/AndroidManifest.xml b/HDTodayProvider/src/main/AndroidManifest.xml
deleted file mode 100644
index 29aec9d..0000000
--- a/HDTodayProvider/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/HDTodayProvider/src/main/kotlin/com/lagradost/HDTodayProviderPlugin.kt b/HDTodayProvider/src/main/kotlin/com/lagradost/HDTodayProviderPlugin.kt
deleted file mode 100644
index eebaea8..0000000
--- a/HDTodayProvider/src/main/kotlin/com/lagradost/HDTodayProviderPlugin.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-
-package com.lagradost
-
-import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
-import com.lagradost.cloudstream3.plugins.Plugin
-import android.content.Context
-
-@CloudstreamPlugin
-class HDTodayProviderPlugin: Plugin() {
- override fun load(context: Context) {
- // All providers should be added in this manner. Please don't edit the providers list directly.
- registerMainAPI(HDTodayProvider())
- }
-}
\ No newline at end of file
diff --git a/SflixProProvider/build.gradle.kts b/SflixProProvider/build.gradle.kts
deleted file mode 100644
index 440805f..0000000
--- a/SflixProProvider/build.gradle.kts
+++ /dev/null
@@ -1,22 +0,0 @@
-// use an integer for version numbers
-version = 1
-
-
-cloudstream {
- // All of these properties are optional, you can safely remove them
-
- // description = "Lorem Ipsum"
- // authors = listOf("Cloudburst")
-
- /**
- * Status int as the following:
- * 0: Down
- * 1: Ok
- * 2: Slow
- * 3: Beta only
- * */
- status = 1 // will be 3 if unspecified
-
-
- iconUrl = "https://www.google.com/s2/favicons?domain=sflix.pro&sz=24"
-}
\ No newline at end of file
diff --git a/SflixProProvider/src/main/AndroidManifest.xml b/SflixProProvider/src/main/AndroidManifest.xml
deleted file mode 100644
index 29aec9d..0000000
--- a/SflixProProvider/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/SflixProProvider/src/main/kotlin/com/lagradost/SflixProProviderPlugin.kt b/SflixProProvider/src/main/kotlin/com/lagradost/SflixProProviderPlugin.kt
deleted file mode 100644
index bbfff64..0000000
--- a/SflixProProvider/src/main/kotlin/com/lagradost/SflixProProviderPlugin.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-
-package com.lagradost
-
-import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
-import com.lagradost.cloudstream3.plugins.Plugin
-import android.content.Context
-
-@CloudstreamPlugin
-class SflixProProviderPlugin: Plugin() {
- override fun load(context: Context) {
- // All providers should be added in this manner. Please don't edit the providers list directly.
- registerMainAPI(SflixProProvider())
- }
-}
\ No newline at end of file
diff --git a/HDTodayProvider/src/main/kotlin/com/lagradost/HDTodayProvider.kt b/SflixProvider/src/main/kotlin/com/lagradost/HDTodayProvider.kt
similarity index 100%
rename from HDTodayProvider/src/main/kotlin/com/lagradost/HDTodayProvider.kt
rename to SflixProvider/src/main/kotlin/com/lagradost/HDTodayProvider.kt
diff --git a/SflixProvider/src/main/kotlin/com/lagradost/SflixProviderPlugin.kt b/SflixProvider/src/main/kotlin/com/lagradost/SflixProviderPlugin.kt
index 4d5cc38..17c721a 100644
--- a/SflixProvider/src/main/kotlin/com/lagradost/SflixProviderPlugin.kt
+++ b/SflixProvider/src/main/kotlin/com/lagradost/SflixProviderPlugin.kt
@@ -13,5 +13,6 @@ class SflixProviderPlugin : Plugin() {
registerMainAPI(TwoEmbedProvider())
registerMainAPI(DopeboxProvider())
registerMainAPI(ZoroProvider())
+ registerMainAPI(HDTodayProvider())
}
}
\ No newline at end of file
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 6fbc23a..541da99 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -4,12 +4,7 @@ rootProject.name = "CloudstreamPlugins"
// to the includes below.
// Plugins are included like this
-val disabled = listOf(
- "SflixProProvider",
- "HDTodayProvider",
- "BflixProvider",
- "FmoviesToProvider"
-)
+val disabled = listOf()
File(rootDir, ".").eachDir { dir ->
if (!disabled.contains(dir.name) && File(dir, "build.gradle.kts").exists()) {