Skip to content

Commit e1ec780

Browse files
update dependencies
1 parent dc7de73 commit e1ec780

1 file changed

Lines changed: 103 additions & 68 deletions

File tree

NekopoiProvider/src/main/kotlin/com/nekopoi/NekopoiExtractors.kt

Lines changed: 103 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,60 @@ class Playmogo : ExtractorApi() {
2020
subtitleCallback: (SubtitleFile) -> Unit,
2121
callback: (ExtractorLink) -> Unit
2222
) {
23-
val doc = app.get(url).text
24-
25-
val title = Regex("""\[(\d+)[Pp]\]""").find(doc)?.groupValues?.getOrNull(1)
26-
val pageQuality = title?.toIntOrNull() ?: 0
27-
28-
val passMd5 = Regex("/pass_md5/([^/]+)/([^/\\s\"')]+)").find(doc) ?: return
29-
val passPath = passMd5.value
30-
val videoBase = app.get("$mainUrl$passPath", referer = url).text.trim()
31-
if (videoBase.isBlank()) return
32-
33-
val token = passMd5.groupValues[2]
34-
val expiry = (System.currentTimeMillis() + 86400000).toString()
35-
val videoUrl = if (videoBase.endsWith("~")) "$videoBase$token?token=$token&expiry=$expiry" else videoBase
36-
37-
val q = if (pageQuality > 0) pageQuality else when {
38-
Regex("""\b(?:2160|4k)\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P2160.value
39-
Regex("""\b(?:1080|hd)\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P1080.value
40-
Regex("""\b720\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P720.value
41-
Regex("""\b480\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P480.value
42-
Regex("""\b360\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P360.value
43-
else -> Qualities.Unknown.value
44-
}
23+
try {
24+
val doc = app.get(url, referer = referer).text
25+
26+
val title = Regex("""\[(\d+)[Pp]\]""").find(doc)?.groupValues?.getOrNull(1)
27+
val pageQuality = title?.toIntOrNull() ?: 0
28+
29+
val directSource = Regex("""source\s*:\s*['"](https?://[^'"]+\.m3u8.*?)['"]""").find(doc)?.groupValues?.getOrNull(1)
30+
if (directSource != null) {
31+
val q = if (pageQuality > 0) pageQuality else Qualities.Unknown.value
32+
callback.invoke(
33+
newExtractorLink(name, name, directSource, ExtractorLinkType.M3U8) {
34+
this.referer = mainUrl
35+
this.quality = q
36+
this.headers = mapOf("Referer" to mainUrl, "Origin" to mainUrl)
37+
}
38+
)
39+
return
40+
}
41+
42+
val passMd5 = Regex("""/pass_md5/([^/]+)/([^/\s"']+)""").find(doc) ?: return
43+
val passPath = passMd5.value
44+
45+
val req = app.get("$mainUrl$passPath", referer = url)
46+
var videoBase = req.text.trim()
47+
48+
if (videoBase.isBlank()) return
4549

46-
callback.invoke(
47-
newExtractorLink(name, name, videoUrl) {
48-
this.referer = mainUrl
49-
this.quality = q
50-
this.headers = mapOf("Referer" to mainUrl, "Origin" to mainUrl)
50+
if (videoBase.startsWith("{")) {
51+
videoBase = Regex("""['"]url['"]\s*:\s*['"]([^'"]+)['"]""").find(videoBase)?.groupValues?.getOrNull(1) ?: return
5152
}
52-
)
53+
54+
val token = passMd5.groupValues[2]
55+
val expiry = (System.currentTimeMillis() + 86400000).toString()
56+
val videoUrl = if (videoBase.endsWith("~")) "$videoBase$token?token=$token&expiry=$expiry" else videoBase
57+
58+
val q = if (pageQuality > 0) pageQuality else when {
59+
Regex("""\b(?:2160|4k)\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P2160.value
60+
Regex("""\b(?:1080|hd)\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P1080.value
61+
Regex("""\b720\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P720.value
62+
Regex("""\b480\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P480.value
63+
Regex("""\b360\b""", RegexOption.IGNORE_CASE).containsMatchIn(videoUrl) -> Qualities.P360.value
64+
else -> Qualities.Unknown.value
65+
}
66+
67+
callback.invoke(
68+
newExtractorLink(name, name, videoUrl, ExtractorLinkType.M3U8) {
69+
this.referer = mainUrl
70+
this.quality = q
71+
this.headers = mapOf("Referer" to mainUrl, "Origin" to mainUrl)
72+
}
73+
)
74+
} catch (e: Exception) {
75+
e.printStackTrace()
76+
}
5377
}
5478
}
5579

@@ -64,48 +88,59 @@ class Streampoi : ExtractorApi() {
6488
subtitleCallback: (SubtitleFile) -> Unit,
6589
callback: (ExtractorLink) -> Unit
6690
) {
67-
val html = app.get(url).text
68-
69-
val packed = Regex(
70-
"""eval\s*\(\s*function\s*\(\s*p\s*,\s*a\s*,\s*c\s*,\s*k\s*,\s*e\s*,\s*d\s*\)\s*\{[\s\S]*?\}\s*\(\s*'((?:[^'\\]|\\.)*+)'\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*'([^']+)'\s*\.split\s*\(\s*'\|\s*'\s*\)\s*\)""",
71-
RegexOption.IGNORE_CASE
72-
).find(html) ?: return
73-
74-
val encoded = packed.groupValues[1]
75-
val radix = packed.groupValues[2].toIntOrNull() ?: return
76-
val count = packed.groupValues[3].toIntOrNull() ?: return
77-
val dictStr = packed.groupValues[4]
78-
val dictionary = dictStr.split("|")
79-
80-
var result = encoded
81-
for (i in (count - 1) downTo 0) {
82-
val replacement = dictionary.getOrNull(i)
83-
if (!replacement.isNullOrEmpty()) {
84-
val word = i.toString(radix)
85-
result = result.replace(Regex("\\b" + Regex.escape(word) + "\\b"), replacement)
91+
try {
92+
val html = app.get(url, referer = referer).text
93+
94+
var fileUrl = Regex("""['"]file['"]\s*:\s*['"](https?://[^'"]+)['"]""").find(html)?.groupValues?.getOrNull(1)
95+
96+
if (fileUrl == null) {
97+
val packed = Regex(
98+
"""\}\s*\(\s*'((?:[^'\\]|\\.)*+)'\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*'([^']+)'\s*\.split\s*\(\s*'\|\s*'\s*\)""",
99+
RegexOption.IGNORE_CASE
100+
).find(html)
101+
102+
if (packed != null) {
103+
val encoded = packed.groupValues[1]
104+
val radix = packed.groupValues[2].toIntOrNull() ?: return
105+
val count = packed.groupValues[3].toIntOrNull() ?: return
106+
val dictionary = packed.groupValues[4].split("|")
107+
108+
var result = encoded
109+
for (i in (count - 1) downTo 0) {
110+
val replacement = dictionary.getOrNull(i)
111+
if (!replacement.isNullOrEmpty()) {
112+
val word = i.toString(radix)
113+
result = result.replace(Regex("\\b" + Regex.escape(word) + "\\b"), replacement)
114+
}
115+
}
116+
117+
fileUrl = Regex("""['"]file['"]\s*:\s*['"]((?:[^'"]|\\.)*+)['"]""").find(result)?.groupValues?.getOrNull(1)
118+
}
86119
}
87-
}
88120

89-
val fileUrl = Regex("""['"]file['"]\s*:\s*['"]((?:[^'"]|\\.)*+)['"]""").find(result)?.groupValues?.getOrNull(1) ?: return
90-
91-
val links = M3u8Helper.generateM3u8(
92-
source = name,
93-
streamUrl = fileUrl,
94-
referer = url,
95-
headers = mapOf("Referer" to url, "Origin" to mainUrl)
96-
)
97-
if (links.isNotEmpty()) {
98-
links.forEach { callback(it) }
99-
return
100-
}
101-
102-
callback.invoke(
103-
newExtractorLink(name, name, fileUrl) {
104-
this.referer = url
105-
this.quality = Qualities.Unknown.value
106-
this.type = ExtractorLinkType.M3U8
107-
this.headers = mapOf("Referer" to url, "Origin" to mainUrl)
121+
if (fileUrl == null) return
122+
123+
val links = M3u8Helper.generateM3u8(
124+
source = name,
125+
streamUrl = fileUrl,
126+
referer = url,
127+
headers = mapOf("Referer" to url, "Origin" to mainUrl)
128+
)
129+
130+
if (links.isNotEmpty()) {
131+
links.forEach { callback(it) }
132+
} else {
133+
callback.invoke(
134+
newExtractorLink(name, name, fileUrl) {
135+
this.referer = url
136+
this.quality = Qualities.Unknown.value
137+
this.type = ExtractorLinkType.M3U8
138+
this.headers = mapOf("Referer" to url, "Origin" to mainUrl)
139+
}
140+
)
108141
}
109-
)
142+
} catch (e: Exception) {
143+
e.printStackTrace()
144+
}
110145
}
111146
}

0 commit comments

Comments
 (0)