Skip to content

Commit

Permalink
feat(src/es): Add New source AnimeBum and update extractors (#98)
Browse files Browse the repository at this point in the history
* feat(src/es): Add New source AnimeBum and update extractors

* fix klint
  • Loading branch information
Dark25 authored Sep 29, 2024
1 parent 996e385 commit ea96f95
Show file tree
Hide file tree
Showing 26 changed files with 432 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
package eu.kanade.tachiyomi.lib.streamhidevidextractor

import android.util.Log
import dev.datlag.jsunpacker.JsUnpacker
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.OkHttpClient

class StreamHideVidExtractor(private val client: OkHttpClient) {

private val playlistUtils by lazy { PlaylistUtils(client) }

fun videosFromUrl(url: String, prefix: String = ""): List<Video> {
val page = client.newCall(GET(url)).execute().body.string()
val playlistUrl = (JsUnpacker.unpackAndCombine(page) ?: page)
.substringAfter("sources:")
.substringAfter("file:\"") // StreamHide
.substringAfter("src:\"") // StreamVid
.substringBefore('"')
if (!playlistUrl.startsWith("http")) return emptyList()
return playlistUtils.extractFromHls(playlistUrl,
videoNameGen = { "${prefix}StreamHideVid - $it" }
)
class StreamHideVidExtractor(private val client: OkHttpClient, private val headers: Headers) {


private val playlistUtils by lazy { PlaylistUtils(client, headers) }

fun videosFromUrl(url: String, videoNameGen: (String) -> String = { quality -> "StreamHideVid - $quality" }): List<Video> {

val doc = client.newCall(GET(getEmbedUrl(url), headers)).execute().asJsoup()

val scriptBody = doc.selectFirst("script:containsData(m3u8)")?.data()
?.let { script ->
if (script.contains("eval(function(p,a,c")) {
JsUnpacker.unpackAndCombine(script)
} else {
script
}
}
val masterUrl = scriptBody
?.substringAfter("source", "")
?.substringAfter("file:\"", "")
?.substringBefore("\"", "")
?.takeIf(String::isNotBlank)
?: return emptyList()

Log.d("StreamHideVidExtractor", "Playlist URL: $masterUrl")
return playlistUtils.extractFromHls(masterUrl, url, videoNameGen = videoNameGen)
}

private fun getEmbedUrl(url: String): String {
return when {
url.contains("/d/") -> url.replace("/d/", "/v/")
url.contains("/download/") -> url.replace("/download/", "/v/")
url.contains("/file/") -> url.replace("/file/", "/v/")
else -> url.replace("/f/", "/v/")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class VidGuardExtractor(private val client: OkHttpClient) {
Context.toString(svgObject)
}
} catch (e: Exception) {
Log.i("Error", e.toString())
Log.e("Error", "JavaScript execution error: ${e.message}")
} finally {
Context.exit()
}
}
val t = Thread(ThreadGroup("A"), r, "thread_rhino", 2000000) // StackSize 2Mb: Run in a thread because rhino requires more stack size for large scripts.
val t = Thread(ThreadGroup("A"), r, "thread_rhino", 8 * 1024 * 1024) // Increase stack size to 8MB
t.start()
t.join()
t.interrupt()
Expand Down
17 changes: 17 additions & 0 deletions src/es/animebum/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ext {
extName = 'AnimeBum'
extClass = '.AnimeBum'
extVersionCode = 1
}

apply from: "$rootDir/common.gradle"

dependencies {
implementation(project(':lib:okru-extractor'))
implementation(project(':lib:streamwish-extractor'))
implementation(project(':lib:universal-extractor'))
implementation(project(':lib:streamhidevid-extractor'))
implementation(project(':lib:vidguard-extractor'))
implementation(project(':lib:filemoon-extractor'))
implementation(project(':lib:gdriveplayer-extractor'))
}
Binary file added src/es/animebum/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/es/animebum/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/es/animebum/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ea96f95

Please sign in to comment.