diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index d984a6c6..abcdb4d7 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -44,7 +44,7 @@ jobs: - name: Bump extensions that uses a modified lib if: steps.modified-libs.outputs.any_changed == 'true' run: | - ./.github/scripts/bump-versions.py ${{ steps.modified-libs.outputs.all_changed_files }} + chmod +x ./.github/scripts/bump-versions.py ${{ steps.modified-libs.outputs.all_changed_files }} - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@a494d935f4b56874c4a5a87d19af7afcf3a163d0 # v2 diff --git a/README.md b/README.md index fb997af6..68811214 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,20 @@ -# Aniyomi-extensions +## Guide -The source code for the extensions +just paste this into your anime repo +``` +https://raw.githubusercontent.com/almightyhak/aniyomi-anime-repo/main/index.min.json +``` +If your interested in installing just the apks they can be found [Here](https://github.com/almightyhak/aniyomi-anime-repo) ## Support Server -[Discord](https://discord.gg/vut4mmXQzU) +Join the [Discord](https://discord.gg/vut4mmXQzU) for updates and announcements + and please check the discord BEFORE making an issue -## Guide +## Contributing -just paste this into your anime repo https://raw.githubusercontent.com/almightyhak/aniyomi-anime-repo/main/index.min.json - -i am maintaining this but keep in mind that i'm NOT a developer so expect issues to take a while to fix - -If your interested in installing just the apks they can be found [Here](https://github.com/almightyhak/aniyomi-anime-repo) +[Template](https://github.com/aniyomiorg/aniyomi-extensions/blob/master/CONTRIBUTING.md) ## Contact diff --git a/lib/voe-extractor/src/main/java/eu/kanade/tachiyomi/lib/voeextractor/DdosGuardInterceptor.kt b/lib/voe-extractor/src/main/java/eu/kanade/tachiyomi/lib/voeextractor/DdosGuardInterceptor.kt new file mode 100644 index 00000000..dddd3982 --- /dev/null +++ b/lib/voe-extractor/src/main/java/eu/kanade/tachiyomi/lib/voeextractor/DdosGuardInterceptor.kt @@ -0,0 +1,73 @@ +package eu.kanade.tachiyomi.lib.voeextractor + +import android.webkit.CookieManager +import eu.kanade.tachiyomi.network.GET +import okhttp3.Cookie +import okhttp3.HttpUrl +import okhttp3.Interceptor +import okhttp3.OkHttpClient +import okhttp3.Response + +class DdosGuardInterceptor(private val client: OkHttpClient) : Interceptor { + + private val cookieManager by lazy { CookieManager.getInstance() } + + override fun intercept(chain: Interceptor.Chain): Response { + val originalRequest = chain.request() + val response = chain.proceed(originalRequest) + + // Check if DDos-GUARD is on + if (response.code !in ERROR_CODES || response.header("Server") !in SERVER_CHECK) { + return response + } + + response.close() + val cookies = cookieManager.getCookie(originalRequest.url.toString()) + val oldCookie = if (cookies != null && cookies.isNotEmpty()) { + cookies.split(";").mapNotNull { Cookie.parse(originalRequest.url, it) } + } else { + emptyList() + } + + val ddg2Cookie = oldCookie.firstOrNull { it.name == "__ddg2_" } + if (!ddg2Cookie?.value.isNullOrEmpty()) { + return chain.proceed(originalRequest) + } + + val newCookie = getNewCookie(originalRequest.url) ?: return chain.proceed(originalRequest) + val newCookieHeader = buildString { + (oldCookie + newCookie).forEachIndexed { index, cookie -> + if (index > 0) append("; ") + append(cookie.name).append('=').append(cookie.value) + } + } + + return chain.proceed(originalRequest.newBuilder().addHeader("cookie", newCookieHeader).build()) + } + + fun getNewCookie(url: HttpUrl): Cookie? { + val cookies = cookieManager.getCookie(url.toString()) + val oldCookie = if (cookies != null && cookies.isNotEmpty()) { + cookies.split(";").mapNotNull { Cookie.parse(url, it) } + } else { + emptyList() + } + val ddg2Cookie = oldCookie.firstOrNull { it.name == "__ddg2_" } + if (!ddg2Cookie?.value.isNullOrEmpty()) { + return ddg2Cookie + } + val wellKnown = client.newCall(GET("https://check.ddos-guard.net/check.js")) + .execute().body.string() + .substringAfter("'", "") + .substringBefore("'", "") + val checkUrl = "${url.scheme}://${url.host + wellKnown}" + return client.newCall(GET(checkUrl)).execute().header("set-cookie")?.let { + Cookie.parse(url, it) + } + } + + companion object { + private val ERROR_CODES = listOf(403) + private val SERVER_CHECK = listOf("ddos-guard") + } +} diff --git a/lib/voe-extractor/src/main/java/eu/kanade/tachiyomi/lib/voeextractor/VoeExtractor.kt b/lib/voe-extractor/src/main/java/eu/kanade/tachiyomi/lib/voeextractor/VoeExtractor.kt index 398dc0cf..40878ebc 100644 --- a/lib/voe-extractor/src/main/java/eu/kanade/tachiyomi/lib/voeextractor/VoeExtractor.kt +++ b/lib/voe-extractor/src/main/java/eu/kanade/tachiyomi/lib/voeextractor/VoeExtractor.kt @@ -14,7 +14,9 @@ class VoeExtractor(private val client: OkHttpClient) { private val json: Json by injectLazy() - private val playlistUtils by lazy { PlaylistUtils(client) } + private val clientDdos by lazy { client.newBuilder().addInterceptor(DdosGuardInterceptor(client)).build() } + + private val playlistUtils by lazy { PlaylistUtils(clientDdos) } private val linkRegex = "(http|https)://([\\w_-]+(?:\\.[\\w_-]+)+)([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])".toRegex() @@ -24,7 +26,16 @@ class VoeExtractor(private val client: OkHttpClient) { data class VideoLinkDTO(val file: String) fun videosFromUrl(url: String, prefix: String = ""): List