@@ -5,34 +5,42 @@ import me.jbusdriver.plugin.magnet.IMagnetLoader
55import me.jbusdriver.plugin.magnet.IMagnetLoader.Companion.MagnetFormatPrefix
66import me.jbusdriver.plugin.magnet.IMagnetLoader.Companion.safeJsoupGet
77import 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 }
0 commit comments