Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Update Xvideos.kt #21

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,25 @@ class Xvideos : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val sourcesJson = document.select("script:containsData(html5player.setVideoUrl)").toString()
val lowQuality = sourcesJson.substringAfter("VideoUrlLow('").substringBefore("')")
val hlsQuality = sourcesJson.substringAfter("setVideoHLS('").substringBefore("')")
val highQuality = sourcesJson.substringAfter("VideoUrlHigh('").substringBefore("')")
return listOf(
Video(lowQuality, "Low", lowQuality),
Video(hlsQuality, "HLS", hlsQuality),
Video(highQuality, "High", highQuality)
)
val highQuality = sourcesJson.substringAfter("VideoUrlHigh('").substringBefore("'")

// Extract the HLS stream URL and parse it to get the available qualities
val hlsUrl = URL(hlsQuality)
val hlsConnection = hlsUrl.openConnection() as HttpURLConnection
val hlsStream = hlsConnection.inputStream.bufferedReader().use { it.readText() }
val hlsQualities = hlsStream.lines()
.filter { it.startsWith("#EXT-X-STREAM-INF") }
.map { it.substringAfter("NAME=\"").substringBefore("\"") }

// Create a list of videos for each available quality
val videos = mutableListOf<Video>()
videos.add(Video(lowQuality, "Low", lowQuality))
for (quality in hlsQualities) {
videos.add(Video(hlsQuality, quality, hlsQuality))
}
videos.add(Video(highQuality, "High", highQuality))

return videos
}

override fun videoListSelector() = throw Exception("not used")
Expand All @@ -106,6 +119,7 @@ class Xvideos : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
}
return this
}
}

override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
val tagFilter = filters.find{it is Tags} as Tags
Expand Down