mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-18 10:13:55 +00:00
fix: network safety
This commit is contained in:
@@ -12,6 +12,8 @@ import ani.dantotsu.addons.AddonManager
|
||||
import ani.dantotsu.addons.LoadResult
|
||||
import ani.dantotsu.addons.AddonInstallReceiver
|
||||
import ani.dantotsu.media.AddonType
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.util.Logger
|
||||
import eu.kanade.tachiyomi.extension.InstallStep
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -70,7 +72,7 @@ class TorrentAddonManager(
|
||||
}
|
||||
|
||||
override fun isAvailable(): Boolean {
|
||||
return extension?.extension != null
|
||||
return extension?.extension != null && PrefManager.getVal(PrefName.TorrentEnabled)
|
||||
}
|
||||
|
||||
override fun getVersion(): String? {
|
||||
|
||||
@@ -40,7 +40,12 @@ class MangaUpdates {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
val res = client.post(apiUrl, json = query).parsed<MangaUpdatesResponse>()
|
||||
val res = try {
|
||||
client.post(apiUrl, json = query).parsed<MangaUpdatesResponse>()
|
||||
} catch (e: Exception) {
|
||||
Logger.log(e.toString())
|
||||
return@tryWithSuspend null
|
||||
}
|
||||
coroutineScope {
|
||||
res.results?.map {
|
||||
async(Dispatchers.IO) {
|
||||
|
||||
@@ -271,33 +271,40 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
||||
if (torrentExtension.isAvailable()) {
|
||||
val activity = currActivity() ?: requireActivity()
|
||||
launchIO {
|
||||
val extension = torrentExtension.extension!!.extension
|
||||
torrentExtension.torrentHash?.let {
|
||||
extension.removeTorrent(it)
|
||||
}
|
||||
val index = if (url.contains("index=")) {
|
||||
url.substringAfter("index=").toIntOrNull() ?: 0
|
||||
} else 0
|
||||
Logger.log("Sending: ${url}, ${video.quality}, $index")
|
||||
val currentTorrent = extension.addTorrent(
|
||||
url, video.quality.toString(), "", "", false
|
||||
)
|
||||
torrentExtension.torrentHash = currentTorrent.hash
|
||||
video.file.url = extension.getLink(currentTorrent, index)
|
||||
Logger.log("Received: ${video.file.url}")
|
||||
if (launch == true) {
|
||||
Intent(activity, ExoplayerView::class.java).apply {
|
||||
ExoplayerView.media = media
|
||||
ExoplayerView.initialized = true
|
||||
startActivity(this)
|
||||
try {
|
||||
val extension = torrentExtension.extension!!.extension
|
||||
torrentExtension.torrentHash?.let {
|
||||
extension.removeTorrent(it)
|
||||
}
|
||||
} else {
|
||||
model.setEpisode(
|
||||
media.anime!!.episodes!![media.anime.selectedEpisode!!]!!,
|
||||
"startExo no launch"
|
||||
val index = if (url.contains("index=")) {
|
||||
url.substringAfter("index=").toIntOrNull() ?: 0
|
||||
} else 0
|
||||
Logger.log("Sending: ${url}, ${video.quality}, $index")
|
||||
val currentTorrent = extension.addTorrent(
|
||||
url, video.quality.toString(), "", "", false
|
||||
)
|
||||
torrentExtension.torrentHash = currentTorrent.hash
|
||||
video.file.url = extension.getLink(currentTorrent, index)
|
||||
Logger.log("Received: ${video.file.url}")
|
||||
if (launch == true) {
|
||||
Intent(activity, ExoplayerView::class.java).apply {
|
||||
ExoplayerView.media = media
|
||||
ExoplayerView.initialized = true
|
||||
startActivity(this)
|
||||
}
|
||||
} else {
|
||||
model.setEpisode(
|
||||
media.anime!!.episodes!![media.anime.selectedEpisode!!]!!,
|
||||
"startExo no launch"
|
||||
)
|
||||
}
|
||||
dismiss()
|
||||
} catch (e: Exception) {
|
||||
Injekt.get<CrashlyticsInterface>().logException(e)
|
||||
Logger.log(e)
|
||||
toast("Error starting video")
|
||||
dismiss()
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ani.dantotsu.others
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
|
||||
@@ -26,7 +26,11 @@ class ImageSearchViewModel : ViewModel() {
|
||||
)
|
||||
.build()
|
||||
|
||||
val res = client.post(url, requestBody = requestBody).parsed<SearchResult>()
|
||||
val res = try {
|
||||
client.post(url, requestBody = requestBody).parsed<SearchResult>()
|
||||
} catch (e: Exception) {
|
||||
SearchResult(error = e.message)
|
||||
}
|
||||
searchResultLiveData.postValue(res)
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
android:inputType="textMultiLine|none"
|
||||
android:textIsSelectable="true"
|
||||
android:focusable="false"
|
||||
android:textSize="12sp"
|
||||
android:focusableInTouchMode="false"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/colorOnBackground" />
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:layout_marginStart="2dp"
|
||||
android:maxLines="5"
|
||||
android:text="@string/empty"
|
||||
app:lineHeight="15sp" />
|
||||
|
||||
Reference in New Issue
Block a user