Skip to content

Commit fa18084

Browse files
committed
update plugin
1 parent 9c4ac2b commit fa18084

File tree

7 files changed

+136
-20
lines changed

7 files changed

+136
-20
lines changed

api/announce.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@
2828
},
2929
"notice": {
3030
"id": 16,
31-
"content": "提示:\r\n1. 磁力插件btso.pw更新"
31+
"content": "提示:\r\n1. 磁力插件更新,添加超人"
3232
},
3333
"plugins": {
3434
"internal": [
3535
{
3636
"name": "me.jbusdriver.plugin.magnet",
37-
"versionCode": 8,
38-
"versionName": "1.0.7",
39-
"url": "https://raw.githubusercontent.com/Ccixyj/jbusfile/master/plugins/me.jbusdriver.plugin.magnet_1.0.7.apk",
37+
"versionCode": 9,
38+
"versionName": "1.0.8",
39+
"url": "https://gitee.com/jbusdriver/static/raw/master/plugins/me.jbusdriver.plugin.magnet_1.0.8.apk",
4040
"desc": "[内部插件]磁力链接解析插件",
41-
"eTag": "F3D1BF6EA4174259BDD71AEF5FBD18F5"
41+
"eTag": "FB60460C68DD9E5D0EA3C833026020DA"
4242
}
4343
]
4444
}

component_plugin_manager/src/main/java/me/jbusdriver/component/plugin/manager/PluginManagerComponent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PluginManagerComponent : IComponent {
2828

2929
override fun onCall(cc: CC): Boolean {
3030
try {
31-
when (val action = cc.actionName) {
31+
when (cc.actionName) {
3232
"plugins.init" -> {
3333
// async call
3434
val plugins = GSON.fromJson(cc.getParamItem<JsonObject>("plugins"), Plugins::class.java)

plugins/plugin_magnet/src/main/java/me/jbusdriver/plugin/magnet/MagnetLoaders.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ object MagnetLoaders {
77
*/
88
val Loaders: Map<String, IMagnetLoader> by lazy {
99
mapOf(
10+
"超人" to ChaoRenLoaderImpl(),
11+
"Btanv" to BtAntMagnetLoaderImpl(),
1012
"Kitty" to CNBtkittyMangetLoaderImpl(),
1113
"btdigg" to BtdiggsMagnetLoaderImpl(),
1214
"zzjd" to ZZJDMagnetLoaderImpl(),
1315
"BTbaocai" to BTBCMagnetLoaderImpl(),
14-
"Btanv" to BtanvMagnetLoaderImpl(),
1516
"BTSO.PW" to BtsoPWMagnetLoaderImpl(),
1617
"BTSOW" to BTSOWMagnetLoaderImpl(),
1718
/* "BTDB" to BTDBMagnetLoaderImpl(),*/
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,42 @@ import me.jbusdriver.plugin.magnet.IMagnetLoader
55
import me.jbusdriver.plugin.magnet.IMagnetLoader.Companion.MagnetFormatPrefix
66
import me.jbusdriver.plugin.magnet.IMagnetLoader.Companion.safeJsoupGet
77
import org.json.JSONObject
8+
import java.util.regex.Pattern
89

9-
class BtanvMagnetLoaderImpl : IMagnetLoader {
10-
private val Tag = "MagnetLoader:Btanv"
11-
private val search = "http://www.btdft.com/search/%s-first-asc-%s"
10+
class BtAntMagnetLoaderImpl : IMagnetLoader {
11+
private val Tag = "Btanv"
12+
private val search = "http://www.eclzz.life/s/%s_rel_%s.html"
1213
override var hasNexPage: Boolean = false
1314

15+
private val hashRegex = Pattern.compile("detail/(.+)\\.html")
16+
1417
override fun loadMagnets(key: String, page: Int): List<JSONObject> {
15-
val url = search.format(EncodeHelper.utf8Encode(key.trim()), page)
18+
val url = search.format(key.replace(" ",""), page)
1619
Log.i(Tag, "load url : $url")
1720
val doc = safeJsoupGet(url) ?: return emptyList()
1821

19-
hasNexPage =
20-
!doc.select(".bottom-pager").firstOrNull()?.children()?.lastOrNull()?.attr("href").isNullOrBlank()
22+
hasNexPage = doc.select(".pagination").last()?.hasClass("active")?.not() ?: false
2123
Log.i(Tag, "hasNexPage : $hasNexPage")
2224
return doc.select("#content .search-item").map { ele ->
23-
//it.log()
25+
Log.i(Tag, "find item : $ele")
2426
val bars =
2527
ele.select(".item-bar").firstOrNull()?.children()?.map {
2628
if (it.tagName() == "a") it.attr(
2729
"href"
2830
) else it.text()
29-
}
30-
?: emptyList<String>()
31+
} ?: emptyList<String>()
32+
33+
val hashSource = ele.select(".item-title a").attr("href")
34+
val hash = hashRegex.matcher(hashSource).let {
35+
it.find()
36+
it.group(1).orEmpty()
37+
}
38+
val link = IMagnetLoader.MagnetFormatPrefix + hash
3139
JSONObject().apply {
3240
put("name", ele.select(".item-title").text())
3341
put("size", bars.find { it.contains("大小") } ?: "未知")
3442
put("date", bars.find { it.contains("时间") } ?: "未知")
35-
put("link", bars.find { it.contains(MagnetFormatPrefix) })
43+
put("link", link)
3644
}
3745
}
3846
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package me.jbusdriver.plugin.magnet.loaders
2+
3+
import android.text.Html
4+
import android.util.Log
5+
import me.jbusdriver.plugin.magnet.IMagnetLoader
6+
import org.json.JSONObject
7+
import java.util.regex.Pattern
8+
9+
class ChaoRenLoaderImpl : IMagnetLoader {
10+
11+
private val searchUrl = "https://www.chaoren99.xyz/search/page-%s.html?name=%s"
12+
13+
private val Tag = "ChaoRen"
14+
override var hasNexPage: Boolean = false
15+
16+
private val hashRegex = Pattern.compile("hash/(.+)\\.html")
17+
18+
override fun loadMagnets(key: String, page: Int): List<JSONObject> {
19+
return try {
20+
val url = searchUrl.format(page, EncodeHelper.utf8Encode(key)).trim()
21+
val doc = IMagnetLoader.safeJsoupGet(url) ?: return emptyList()
22+
23+
Log.d(Tag, "search :$url")
24+
hasNexPage = !doc.select(".pagination li").last().hasClass("active")
25+
return doc.select(".container .item").map { item ->
26+
Log.d(Tag, "find :$item")
27+
val title = Html.fromHtml(item.select("h4").html())
28+
val hashSource = item.select("a").first()?.attr("href").orEmpty()
29+
val hash = hashRegex.matcher(hashSource).let {
30+
it.find()
31+
it.group(1).orEmpty()
32+
}
33+
val link = IMagnetLoader.MagnetFormatPrefix + hash
34+
Log.d(Tag, "find link :$link")
35+
val infos = item.select("p").text().split(" ")
36+
val split = infos.size / 2
37+
JSONObject().apply {
38+
put("name", title)
39+
put("size", infos.take(2).joinToString(" "))
40+
put("date", infos.takeLast(infos.size - split).joinToString(" "))
41+
put("link", link)
42+
}
43+
}
44+
45+
} catch (e: Exception) {
46+
e.printStackTrace()
47+
emptyList()
48+
}
49+
50+
51+
}
52+
53+
override fun fetchMagnetLink(url: String): String {
54+
return ""
55+
}
56+
57+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package me.jbusdriver.plugin.magnet.loaders
2+
3+
import android.util.Log
4+
import me.jbusdriver.plugin.magnet.IMagnetLoader
5+
import org.json.JSONObject
6+
7+
class CiLiDaoLoaderImpl : IMagnetLoader {
8+
9+
private val searchUrl = "https://cilidao.org/query?word=%s&page=%s&sort=rele"
10+
11+
private val Tag = "cilidao"
12+
override var hasNexPage: Boolean = false
13+
14+
15+
16+
override fun loadMagnets(key: String, page: Int): List<JSONObject> {
17+
return try {
18+
val url = searchUrl.format( EncodeHelper.utf8Encode(key),page).trim()
19+
val doc = IMagnetLoader.safeJsoupGet(url) ?: return emptyList()
20+
Log.d(Tag, "search :$url")
21+
hasNexPage = true
22+
return doc.select(".Search_results li").map { item ->
23+
Log.i(Tag, "find item : $item")
24+
val txtBloc = item.select(".SearchListTitle_list_title")
25+
val title = txtBloc.text()
26+
val url = "https://cilidao.org" + txtBloc.select("a").last().attr("href")
27+
val infos = item.select(".Search_result_type").text().split(" ")
28+
val split = infos.size / 2
29+
JSONObject().apply {
30+
put("name", title)
31+
put("size", infos.take(2).joinToString(" "))
32+
put("date", infos.takeLast(infos.size - split).joinToString(" "))
33+
put("link", url)
34+
}
35+
}
36+
37+
} catch (e: Exception) {
38+
e.printStackTrace()
39+
emptyList()
40+
}
41+
42+
43+
}
44+
45+
override fun fetchMagnetLink(url: String): String {
46+
Log.d(Tag, "fetchMagnetLink :$url")
47+
return IMagnetLoader.safeJsoupGet(url)?.select(".infohash-box span")?.text().orEmpty()
48+
}
49+
50+
}

version.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ext {
55
'buildTools' : '28.0.3',
66

77
'gradle' : '3.1.4',
8-
'kotlin' : '1.3.50',
8+
'kotlin' : '1.3.70',
99
'supportLibrary' : '28.0.0',
1010

1111
'okhttp' : '3.12.12',
@@ -42,8 +42,8 @@ ext {
4242
],
4343
'plugins' : [
4444
magnet: [
45-
version_code: 8,
46-
version_name: '1.0.7'
45+
version_code: 9,
46+
version_name: '1.0.8'
4747
]
4848
]
4949

0 commit comments

Comments
 (0)