Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ccixyj committed Mar 21, 2019
2 parents e502665 + 9d4eefb commit 1b2facb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 27 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
android:supportsRtl="true"
android:resizeableActivity="true"
tools:replace="android:allowBackup"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme.NoActionBar" >

<meta-data
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/me/jbusdriver/http/JAVBusService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface JAVBusService {
}

private fun createService(url: String) =
NetClient.getRetrofit(if (!url.endsWith("/")) "$url/" else url).create(JAVBusService::class.java)
NetClient.getRetrofit("${url.trimEnd('/')}/").create(JAVBusService::class.java)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface DownloadService {
.build()

fun createService() =
Retrofit.Builder().client(client).baseUrl("https://raw.githubusercontent.com").addCallAdapterFactory(
Retrofit.Builder().client(client).baseUrl("https://raw.githubusercontent.com/").addCallAdapterFactory(
RxJavaCallAdapterFactory
).build().create(DownloadService::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ open class MagnetService {

@RemoteMethod(name = "pluginToast")
open fun pluginToast(context: Context): String {
val info = "$context hello from plugin! test2" //update to version 2!!!!
val info =
"$context hello from plugin! ver : ${BuildConfig.VERSION_NAME} ,code: ${BuildConfig.VERSION_CODE}" //update to version 2!!!!
Toast.makeText(context, info, Toast.LENGTH_LONG).show()
return info
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,47 @@ class BtdiggsMagnetLoaderImpl : IMagnetLoader {
private val search = "https://www.btdigg.xyz/search/%s/%s/1/0.html"

override var hasNexPage: Boolean = true
val TAG = "Btdiggs"
val TAG = "MagnetLoader:Btdiggs"

override fun loadMagnets(key: String, page: Int): List<JSONObject> {
val url = search.format(encodeBase64(key), page)
Log.w(TAG, "load url :$url")
val doc = Jsoup.connect(url).initHeaders().get()
Log.w(TAG, "load doc :${doc.title()}")
hasNexPage = doc.select(".page-split :last-child[title]").size > 0
return doc.select(".list dl").map {
val href = it.select("dt a")
val title = href.text()
val url = href.attr("href")

val realUrl = when {
url.startsWith("www.") -> "https://$url"
url.startsWith("/magnet") -> {
IMagnetLoader.MagnetFormatPrefix + url.removePrefix("/magnet/").removeSuffix(".html")
return try {
val doc = Jsoup.connect(url).initHeaders().get()
Log.i(TAG, "load doc :${doc.title()}")
hasNexPage = doc.select(".page-split :last-child[title]").size > 0
doc.select(".list dl").map {
val href = it.select("dt a")
val title = href.text()
val url = href.attr("href")

val realUrl = when {
url.startsWith("www.") -> "https://$url"
url.startsWith("/magnet") -> {
IMagnetLoader.MagnetFormatPrefix + url.removePrefix("/magnet/").removeSuffix(".html")
}
else -> "https://www.btdigg.xyz$url"
}
else -> "https://www.btdigg.xyz$url"
}

val labels = it.select(".attr span")
JSONObject().apply {
put("name", title)
put("size", labels.component2().text())
put("date", labels.component1().text())
put("link", realUrl)
}
val labels = it.select(".attr span")
JSONObject().apply {
put("name", title)
put("size", labels.component2().text())
put("date", labels.component1().text())
put("link", realUrl)
}


}
}
} catch (e: Exception) {
e.printStackTrace()
Log.e(TAG, "throw error $e", e)
emptyList()

}
}


override fun fetchMagnetLink(url: String): String {
return (IMagnetLoader.MagnetFormatPrefix + Jsoup.connect(url).get().select(".content .infohash").text().trim())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.jbusdriver.plugin.magnet.loaders


import android.util.Log
import me.jbusdriver.plugin.magnet.IMagnetLoader
import me.jbusdriver.plugin.magnet.loaders.Helper.gzDeflateBase64
import org.json.JSONObject
Expand All @@ -12,6 +13,7 @@ class CNBtkittyMangetLoaderImpl : IMagnetLoader {

override var hasNexPage: Boolean = true

private val Tag = "MagnetLoader:CNBtkitty"

init {
val manager = java.net.CookieManager()
Expand All @@ -22,7 +24,9 @@ class CNBtkittyMangetLoaderImpl : IMagnetLoader {

override fun loadMagnets(key: String, page: Int): List<JSONObject> {
return try {
val doc = Jsoup.connect(search.format(gzDeflateBase64(key) , page)).get()
val url = search.format(gzDeflateBase64(key), page)
Log.i(Tag, "laod url $url")
val doc = Jsoup.connect(url).get()
val nextPages = doc.select(".pagination strong~a")
hasNexPage = nextPages.size > 0

Expand All @@ -43,7 +47,9 @@ class CNBtkittyMangetLoaderImpl : IMagnetLoader {
}
} catch (e: Exception) {
e.printStackTrace()
Log.e(Tag, "throw error $e", e)
emptyList()

}


Expand Down

0 comments on commit 1b2facb

Please sign in to comment.