fix(it/animeunity): Fix video streams URLs (#621)
* Fix AnimeUnity video streams URLs The video streams URLs have been moved from JS to a single m3u8 file, this commit adapts to the change. The subtitles seem to have disappeared entirely, so I've left them commented. * Update Years filter * Bump AnimeUnity extVersionCode
This commit is contained in:
parent
16b2eae7b4
commit
ba2ba44dc4
3 changed files with 25 additions and 26 deletions
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'AnimeUnity'
|
extName = 'AnimeUnity'
|
||||||
extClass = '.AnimeUnity'
|
extClass = '.AnimeUnity'
|
||||||
extVersionCode = 8
|
extVersionCode = 9
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
||||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||||
import eu.kanade.tachiyomi.animesource.model.Track
|
|
||||||
import eu.kanade.tachiyomi.animesource.model.Video
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource
|
import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
@ -38,7 +37,7 @@ class AnimeUnity :
|
||||||
|
|
||||||
// TODO: Check frequency of url changes to potentially
|
// TODO: Check frequency of url changes to potentially
|
||||||
// add back overridable baseurl preference
|
// add back overridable baseurl preference
|
||||||
override val baseUrl = "https://www.animeunity.to"
|
override val baseUrl = "https://www.animeunity.so"
|
||||||
|
|
||||||
override val lang = "it"
|
override val lang = "it"
|
||||||
|
|
||||||
|
@ -366,42 +365,42 @@ class AnimeUnity :
|
||||||
.asJsoup()
|
.asJsoup()
|
||||||
val scripts = iframe.select("script")
|
val scripts = iframe.select("script")
|
||||||
val script = scripts.find { it.data().contains("masterPlaylist") }!!.data().replace("\n", "\t")
|
val script = scripts.find { it.data().contains("masterPlaylist") }!!.data().replace("\n", "\t")
|
||||||
var playlistUrl = Regex("""url: ?'(.*?)'""").find(script)!!.groupValues[1]
|
val playlistUrl = Regex("""url: ?'(.*?)'""").find(script)!!.groupValues[1]
|
||||||
val filename = playlistUrl.slice(playlistUrl.lastIndexOf("/") + 1 until playlistUrl.length)
|
|
||||||
if (!filename.endsWith(".m3u8")) {
|
|
||||||
playlistUrl = playlistUrl.replace(filename, filename + ".m3u8")
|
|
||||||
}
|
|
||||||
|
|
||||||
val expires = Regex("""'expires': ?'(\d+)'""").find(script)!!.groupValues[1]
|
val expires = Regex("""'expires': ?'(\d+)'""").find(script)!!.groupValues[1]
|
||||||
val token = Regex("""'token': ?'([\w-]+)'""").find(script)!!.groupValues[1]
|
val token = Regex("""'token': ?'([\w-]+)'""").find(script)!!.groupValues[1]
|
||||||
// Get subtitles
|
|
||||||
val masterPlUrl = "$playlistUrl?token=$token&expires=$expires&n=1"
|
val masterPlUrl = buildString {
|
||||||
|
append(playlistUrl)
|
||||||
|
append(if (playlistUrl.contains('?')) '&' else '?')
|
||||||
|
append("h=1&token=")
|
||||||
|
append(token)
|
||||||
|
append("&expires=")
|
||||||
|
append(expires)
|
||||||
|
}
|
||||||
val masterPl =
|
val masterPl =
|
||||||
client
|
client
|
||||||
.newCall(GET(masterPlUrl))
|
.newCall(GET(masterPlUrl))
|
||||||
.execute()
|
.execute()
|
||||||
.body
|
.body
|
||||||
.string()
|
.string()
|
||||||
val subList =
|
|
||||||
|
// Subtitles are nowhere to be seen... I'm leaving this regex for future reference
|
||||||
|
/*val subList =
|
||||||
Regex("""#EXT-X-MEDIA:TYPE=SUBTITLES.*?NAME="(.*?)".*?URI="(.*?)"""")
|
Regex("""#EXT-X-MEDIA:TYPE=SUBTITLES.*?NAME="(.*?)".*?URI="(.*?)"""")
|
||||||
.findAll(masterPl)
|
.findAll(masterPl)
|
||||||
.map {
|
.map {
|
||||||
Track(it.groupValues[2], it.groupValues[1])
|
Track(it.groupValues[2], it.groupValues[1])
|
||||||
}.toList()
|
}.toList()*/
|
||||||
Regex("""'token(\d+p?)': ?'([\w-]+)'""").findAll(script).forEach { match ->
|
|
||||||
val quality = match.groupValues[1]
|
|
||||||
|
|
||||||
val videoUrl =
|
Regex("""https?://vixcloud\.co/playlist/(.+)\?.*type=video&.*rendition=(\d+p?).*""").findAll(masterPl).forEach { match ->
|
||||||
buildString {
|
var videoUrl = match.groupValues[0]
|
||||||
append(playlistUrl)
|
val filename = match.groupValues[1]
|
||||||
append("?type=video&rendition=")
|
if (!filename.endsWith(".m3u8")) {
|
||||||
append(quality)
|
videoUrl = videoUrl.replace(filename, "$filename.m3u8")
|
||||||
append("&token=")
|
|
||||||
append(match.groupValues[2])
|
|
||||||
append("&expires=$expires")
|
|
||||||
append("&n=1")
|
|
||||||
}
|
}
|
||||||
videoList.add(Video(videoUrl, quality, videoUrl, subtitleTracks = subList))
|
val quality = match.groupValues[2]
|
||||||
|
videoList.add(Video(videoUrl, quality, videoUrl))
|
||||||
}
|
}
|
||||||
|
|
||||||
require(videoList.isNotEmpty()) { "Failed to fetch videos" }
|
require(videoList.isNotEmpty()) { "Failed to fetch videos" }
|
||||||
|
|
|
@ -197,7 +197,7 @@ object AnimeUnityFilters {
|
||||||
Pair("Sì", "true"),
|
Pair("Sì", "true"),
|
||||||
)
|
)
|
||||||
|
|
||||||
val YEAR = arrayOf(ANY) + (1969..2024).map {
|
val YEAR = arrayOf(ANY) + (1969..2025).map {
|
||||||
Pair(it.toString(), it.toString())
|
Pair(it.toString(), it.toString())
|
||||||
}.reversed().toTypedArray()
|
}.reversed().toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue