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

Commit f3db924

Browse files
authored
New source [Twitch] and changes [Xvideos, Pornhub] (#4)
1 parent 8043e80 commit f3db924

File tree

13 files changed

+384
-53
lines changed

13 files changed

+384
-53
lines changed

src/all/pornhub/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlinx-serialization'
34

45
ext {
56
extName = 'Pornhub'
67
pkgNameSuffix = 'all.pornhub'
78
extClass = '.Pornhub'
8-
extVersionCode = 3
9+
extVersionCode = 4
910
libVersion = '13'
1011
containsNsfw = true
1112
}

src/all/pornhub/src/eu/kanade/tachiyomi/animeextension/all/pornhub/Pornhub.kt

+52-28
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import eu.kanade.tachiyomi.animesource.model.Video
1212
import eu.kanade.tachiyomi.animesource.online.ParsedAnimeHttpSource
1313
import eu.kanade.tachiyomi.network.GET
1414
import eu.kanade.tachiyomi.util.asJsoup
15+
import kotlinx.serialization.ExperimentalSerializationApi
16+
import kotlinx.serialization.SerialName
17+
import kotlinx.serialization.Serializable
18+
import kotlinx.serialization.decodeFromString
19+
import kotlinx.serialization.json.Json
1520
import okhttp3.OkHttpClient
1621
import okhttp3.Request
1722
import okhttp3.Response
@@ -21,6 +26,7 @@ import org.jsoup.nodes.Document
2126
import org.jsoup.nodes.Element
2227
import uy.kohesive.injekt.Injekt
2328
import uy.kohesive.injekt.api.get
29+
import uy.kohesive.injekt.injectLazy
2430
import java.lang.Exception
2531

2632
class Pornhub : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
@@ -35,6 +41,8 @@ class Pornhub : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
3541

3642
override val client: OkHttpClient = network.cloudflareClient
3743

44+
private val json: Json by injectLazy()
45+
3846
private val preferences: SharedPreferences by lazy {
3947
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
4048
}
@@ -59,8 +67,6 @@ class Pornhub : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
5967
override fun episodeListParse(response: Response): List<SEpisode> {
6068
val episodes = mutableListOf<SEpisode>()
6169

62-
val jsoup = response.asJsoup()
63-
6470
val episode = SEpisode.create().apply {
6571
name = "Video"
6672
date_upload = System.currentTimeMillis()
@@ -75,33 +81,24 @@ class Pornhub : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
7581

7682
override fun episodeFromElement(element: Element) = throw Exception("not used")
7783

84+
@OptIn(ExperimentalSerializationApi::class)
7885
override fun videoListParse(response: Response): List<Video> {
7986
val url = response.request.url.toString()
8087
val videoList = mutableListOf<Video>()
8188
// credits to: https://github.com/Joel2B
82-
val document = Jsoup.connect("https://appsdev.cyou/xv-ph-rt/api/?data=$url").ignoreContentType(true).get()
83-
val jsonObject = JSONObject(document.select("body").text())["hls"]
84-
val jsonUrls = JSONObject(jsonObject.toString())
85-
86-
val url1080 = jsonUrls["1080p"].toString().replace("amp;", "")
87-
val url720 = jsonUrls["720p"].toString().replace("amp;", "")
88-
val url480 = jsonUrls["480p"].toString().replace("amp;", "")
89-
val url240 = jsonUrls["240p"].toString().replace("amp;", "")
90-
91-
if (jsonUrls["1080p"] != "") {
92-
videoList.add(Video(url1080, "1080p", url1080))
93-
}
94-
if (jsonUrls["720p"] != "") {
95-
videoList.add(Video(url720, "720p", url720))
96-
}
97-
if (jsonUrls["480p"] != "") {
98-
videoList.add(Video(url480, "480p", url480))
99-
}
100-
if (jsonUrls["240p"] != "") {
101-
videoList.add(Video(url240, "240p", url240))
102-
}
103-
104-
return videoList
89+
val document = client.newCall(GET("https://appsdev.cyou/xv-ph-rt/api/?data=$url")).execute().asJsoup().body().text()
90+
val jsonResponse = json.decodeFromString<PornApiResponse>(document)
91+
92+
return listOf(
93+
Video(jsonResponse.hls!!.all!!,"HLS: ALL",jsonResponse.hls!!.all),
94+
Video(jsonResponse.hls!!.low!!,"HLS: LOW",jsonResponse.hls!!.low),
95+
Video(jsonResponse.hls!!.hd!!,"HLS: HD",jsonResponse.hls!!.hd),
96+
Video(jsonResponse.hls!!.fhd!!,"HLS: FHD",jsonResponse.hls!!.fhd),
97+
Video(jsonResponse.mp4!!.low!!,"MP4: LOW",jsonResponse.mp4!!.low),
98+
Video(jsonResponse.mp4!!.sd!!,"MP4: SD",jsonResponse.mp4!!.sd),
99+
Video(jsonResponse.mp4!!.hd!!,"MP4: HD",jsonResponse.mp4!!.hd),
100+
Video(jsonResponse.mp4!!.fhd!!,"MP4: FHD",jsonResponse.mp4!!.fhd)
101+
).filter { it.url.isNotBlank() }
105102
}
106103

107104
override fun videoListSelector() = throw Exception("not used")
@@ -131,9 +128,7 @@ class Pornhub : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
131128
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
132129
return GET("$baseUrl/video/search?search=$query&page=$page", headers)
133130
}
134-
override fun searchAnimeFromElement(element: Element): SAnime {
135-
return popularAnimeFromElement(element)
136-
}
131+
override fun searchAnimeFromElement(element: Element): SAnime = popularAnimeFromElement(element)
137132

138133
override fun searchAnimeNextPageSelector(): String = popularAnimeNextPageSelector()
139134

@@ -175,4 +170,33 @@ class Pornhub : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
175170
}
176171
screen.addPreference(videoQualityPref)
177172
}
173+
174+
@Serializable
175+
data class PornApiResponse (
176+
var hls : Hls? = Hls(),
177+
var mp4 : Mp4? = Mp4(),
178+
var thumb : String? = null,
179+
var thumbnails : String? = null
180+
181+
)
182+
183+
@Serializable
184+
data class Hls (
185+
var all : String? = "",
186+
@SerialName("1080p" ) var fhd : String? = "",
187+
@SerialName("720p" ) var hd : String? = "",
188+
@SerialName("480p" ) var sd : String? = "",
189+
@SerialName("240p" ) var low : String? = ""
190+
191+
)
192+
193+
@Serializable
194+
data class Mp4 (
195+
@SerialName("1080p" ) var fhd : String? = "",
196+
@SerialName("720p" ) var hd : String? = "",
197+
@SerialName("480p" ) var sd : String? = "",
198+
@SerialName("240p" ) var low : String? = ""
199+
)
200+
201+
178202
}

src/all/twitch/AndroidManifest.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="eu.kanade.tachiyomi.animeextension">
4+
5+
<application android:icon="@mipmap/ic_launcher">
6+
<activity
7+
android:name=".all.twitch.TwitchIntent"
8+
android:excludeFromRecents="true"
9+
android:exported="true"
10+
android:theme="@android:style/Theme.NoDisplay">
11+
<intent-filter>
12+
<action android:name="android.intent.action.VIEW" />
13+
14+
<category android:name="android.intent.category.DEFAULT" />
15+
<category android:name="android.intent.category.BROWSABLE" />
16+
17+
<data
18+
android:host="m.twitch.tv"
19+
android:pathPattern="/..*"
20+
android:scheme="https" />
21+
</intent-filter>
22+
</activity>
23+
</application>
24+
</manifest>

src/all/twitch/build.gradle

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlinx-serialization'
4+
5+
ext {
6+
extName = 'Twitch'
7+
pkgNameSuffix = 'all.twitch'
8+
extClass = '.Twitch'
9+
extVersionCode = 1
10+
libVersion = '13'
11+
}
12+
13+
apply from: "$rootDir/common.gradle"
1.62 KB
Loading
1.62 KB
Loading
1.62 KB
Loading
1.62 KB
Loading
Loading

0 commit comments

Comments
 (0)