forked from aniyomiorg/aniyomi-extensions
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from Dark25/Hackstore
Feat(es/Hackstore): Add GoodStreamExtractor
- Loading branch information
Showing
4 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
plugins { | ||
id("lib-android") | ||
} |
33 changes: 33 additions & 0 deletions
33
...extractor/src/main/java/eu/kanade/tachiyomi/lib/goodstramextractor/GoodStreamExtractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package eu.kanade.tachiyomi.lib.goodstramextractor | ||
|
||
import eu.kanade.tachiyomi.animesource.model.Video | ||
import eu.kanade.tachiyomi.network.GET | ||
import eu.kanade.tachiyomi.util.asJsoup | ||
import okhttp3.Headers | ||
import okhttp3.OkHttpClient | ||
|
||
class GoodStreamExtractor(private val client: OkHttpClient, private val headers: Headers) { | ||
|
||
fun videosFromUrl(url: String, name: String): List<Video> { | ||
val doc = client.newCall(GET(url, headers)).execute().asJsoup() | ||
val videos = mutableListOf<Video>() | ||
|
||
doc.select("script").forEach { script -> | ||
if (script.data().contains(Regex("file|player"))) { | ||
val urlRegex = Regex("file: \"(https:\\/\\/[a-z0-9.\\/-_?=&]+)\",") | ||
urlRegex.find(script.data())?.groupValues?.get(1)?.let { link -> | ||
videos.add( | ||
Video( | ||
url = link, | ||
quality = name, | ||
videoUrl = link, | ||
headers = headers | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
||
return videos | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters