reformat
This commit is contained in:
parent
1df528c0dc
commit
afa960c808
171 changed files with 3458 additions and 1915 deletions
|
@ -8,12 +8,21 @@ import java.net.URLEncoder
|
|||
object AniSkip {
|
||||
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
suspend fun getResult(malId: Int, episodeNumber: Int, episodeLength: Long, useProxyForTimeStamps: Boolean): List<Stamp>? {
|
||||
suspend fun getResult(
|
||||
malId: Int,
|
||||
episodeNumber: Int,
|
||||
episodeLength: Long,
|
||||
useProxyForTimeStamps: Boolean
|
||||
): List<Stamp>? {
|
||||
val url =
|
||||
"https://api.aniskip.com/v2/skip-times/$malId/$episodeNumber?types[]=ed&types[]=mixed-ed&types[]=mixed-op&types[]=op&types[]=recap&episodeLength=$episodeLength"
|
||||
return tryWithSuspend {
|
||||
val a = if(useProxyForTimeStamps)
|
||||
client.get("https://corsproxy.io/?${URLEncoder.encode(url, "utf-8").replace("+", "%20")}")
|
||||
val a = if (useProxyForTimeStamps)
|
||||
client.get(
|
||||
"https://corsproxy.io/?${
|
||||
URLEncoder.encode(url, "utf-8").replace("+", "%20")
|
||||
}"
|
||||
)
|
||||
else
|
||||
client.get(url)
|
||||
val res = a.parsed<AniSkipResponse>()
|
||||
|
@ -40,8 +49,8 @@ object AniSkip {
|
|||
|
||||
fun String.getType(): String {
|
||||
return when (this) {
|
||||
"op" -> "Opening"
|
||||
"ed" -> "Ending"
|
||||
"op" -> "Opening"
|
||||
"ed" -> "Ending"
|
||||
"recap" -> "Recap"
|
||||
"mixed-ed" -> "Mixed Ending"
|
||||
"mixed-op" -> "Mixed Opening"
|
||||
|
|
|
@ -30,11 +30,11 @@ import java.text.SimpleDateFormat
|
|||
import java.util.*
|
||||
|
||||
object AppUpdater {
|
||||
suspend fun check(activity: FragmentActivity, post:Boolean=false) {
|
||||
if(post) snackString(currContext()?.getString(R.string.checking_for_update))
|
||||
suspend fun check(activity: FragmentActivity, post: Boolean = false) {
|
||||
if (post) snackString(currContext()?.getString(R.string.checking_for_update))
|
||||
val repo = activity.getString(R.string.repo)
|
||||
tryWithSuspend {
|
||||
val (md, version) = if(BuildConfig.DEBUG){
|
||||
val (md, version) = if (BuildConfig.DEBUG) {
|
||||
val res = client.get("https://api.github.com/repos/$repo/releases")
|
||||
.parsed<JsonArray>().map {
|
||||
Mapper.json.decodeFromJsonElement<GithubResponse>(it)
|
||||
|
@ -42,9 +42,9 @@ object AppUpdater {
|
|||
val r = res.filter { it.prerelease }.maxByOrNull {
|
||||
it.timeStamp()
|
||||
} ?: throw Exception("No Pre Release Found")
|
||||
val v = r.tagName.substringAfter("v","")
|
||||
val v = r.tagName.substringAfter("v", "")
|
||||
(r.body ?: "") to v.ifEmpty { throw Exception("Weird Version : ${r.tagName}") }
|
||||
}else{
|
||||
} else {
|
||||
val res =
|
||||
client.get("https://raw.githubusercontent.com/$repo/main/stable.md").text
|
||||
res to res.substringAfter("# ").substringBefore("\n")
|
||||
|
@ -54,15 +54,23 @@ object AppUpdater {
|
|||
val dontShow = loadData("dont_ask_for_update_$version") ?: false
|
||||
if (compareVersion(version) && !dontShow && !activity.isDestroyed) activity.runOnUiThread {
|
||||
CustomBottomDialog.newInstance().apply {
|
||||
setTitleText("${if (BuildConfig.DEBUG) "Beta " else ""}Update " + currContext()!!.getString(R.string.available))
|
||||
setTitleText(
|
||||
"${if (BuildConfig.DEBUG) "Beta " else ""}Update " + currContext()!!.getString(
|
||||
R.string.available
|
||||
)
|
||||
)
|
||||
addView(
|
||||
TextView(activity).apply {
|
||||
val markWon = Markwon.builder(activity).usePlugin(SoftBreakAddsNewLinePlugin.create()).build()
|
||||
val markWon = Markwon.builder(activity)
|
||||
.usePlugin(SoftBreakAddsNewLinePlugin.create()).build()
|
||||
markWon.setMarkdown(this, md)
|
||||
}
|
||||
)
|
||||
|
||||
setCheck(currContext()!!.getString(R.string.dont_show_again, version), false) { isChecked ->
|
||||
setCheck(
|
||||
currContext()!!.getString(R.string.dont_show_again, version),
|
||||
false
|
||||
) { isChecked ->
|
||||
if (isChecked) {
|
||||
saveData("dont_ask_for_update_$version", true)
|
||||
}
|
||||
|
@ -72,11 +80,11 @@ object AppUpdater {
|
|||
try {
|
||||
client.get("https://api.github.com/repos/$repo/releases/tags/v$version")
|
||||
.parsed<GithubResponse>().assets?.find {
|
||||
it.browserDownloadURL.endsWith("apk")
|
||||
}?.browserDownloadURL.apply {
|
||||
if (this != null) activity.downloadUpdate(version, this)
|
||||
else openLinkInBrowser("https://github.com/repos/$repo/releases/tag/v$version")
|
||||
}
|
||||
it.browserDownloadURL.endsWith("apk")
|
||||
}?.browserDownloadURL.apply {
|
||||
if (this != null) activity.downloadUpdate(version, this)
|
||||
else openLinkInBrowser("https://github.com/repos/$repo/releases/tag/v$version")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
|
@ -89,25 +97,24 @@ object AppUpdater {
|
|||
show(activity.supportFragmentManager, "dialog")
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(post) snackString(currContext()?.getString(R.string.no_update_found))
|
||||
else {
|
||||
if (post) snackString(currContext()?.getString(R.string.no_update_found))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun compareVersion(version: String): Boolean {
|
||||
|
||||
if(BuildConfig.DEBUG) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
return BuildConfig.VERSION_NAME != version
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fun toDouble(list: List<String>): Double {
|
||||
return list.mapIndexed { i: Int, s: String ->
|
||||
when (i) {
|
||||
0 -> s.toDouble() * 100
|
||||
1 -> s.toDouble() * 10
|
||||
2 -> s.toDouble()
|
||||
else -> s.toDoubleOrNull()?: 0.0
|
||||
0 -> s.toDouble() * 100
|
||||
1 -> s.toDouble() * 10
|
||||
2 -> s.toDouble()
|
||||
else -> s.toDoubleOrNull() ?: 0.0
|
||||
}
|
||||
}.sum()
|
||||
}
|
||||
|
@ -211,7 +218,7 @@ object AppUpdater {
|
|||
val tagName: String,
|
||||
val prerelease: Boolean,
|
||||
@SerialName("created_at")
|
||||
val createdAt : String,
|
||||
val createdAt: String,
|
||||
val body: String? = null,
|
||||
val assets: List<Asset>? = null
|
||||
) {
|
||||
|
|
|
@ -17,8 +17,9 @@ open class CustomBottomDialog : BottomSheetDialogFragment() {
|
|||
fun addView(view: View) {
|
||||
viewList.add(view)
|
||||
}
|
||||
var title: String?=null
|
||||
fun setTitleText(string: String){
|
||||
|
||||
var title: String? = null
|
||||
fun setTitleText(string: String) {
|
||||
title = string
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,11 @@ open class CustomBottomDialog : BottomSheetDialogFragment() {
|
|||
positiveCallback = callback
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetCustomBinding.inflate(inflater, container, false)
|
||||
val window = dialog?.window
|
||||
window?.statusBarColor = Color.TRANSPARENT
|
||||
|
@ -70,16 +75,16 @@ open class CustomBottomDialog : BottomSheetDialogFragment() {
|
|||
checkCallback?.invoke(checked)
|
||||
}
|
||||
}
|
||||
|
||||
if(negativeText!=null) binding.bottomDialogCustomNegative.apply {
|
||||
|
||||
if (negativeText != null) binding.bottomDialogCustomNegative.apply {
|
||||
visibility = View.VISIBLE
|
||||
text = negativeText
|
||||
setOnClickListener {
|
||||
setOnClickListener {
|
||||
negativeCallback?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
if(positiveText!=null) binding.bottomDialogCustomPositive.apply {
|
||||
if (positiveText != null) binding.bottomDialogCustomPositive.apply {
|
||||
visibility = View.VISIBLE
|
||||
text = positiveText
|
||||
setOnClickListener {
|
||||
|
|
|
@ -12,10 +12,10 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.core.content.ContextCompat
|
||||
import ani.dantotsu.FileUrl
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.media.anime.Episode
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.defaultHeaders
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.media.anime.Episode
|
||||
import ani.dantotsu.parsers.Book
|
||||
import ani.dantotsu.toast
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -50,12 +50,17 @@ object Download {
|
|||
|
||||
fun download(context: Context, episode: Episode, animeTitle: String) {
|
||||
toast(context.getString(R.string.downloading))
|
||||
val extractor = episode.extractors?.find { it.server.name == episode.selectedExtractor } ?: return
|
||||
val extractor =
|
||||
episode.extractors?.find { it.server.name == episode.selectedExtractor } ?: return
|
||||
val video =
|
||||
if (extractor.videos.size > episode.selectedVideo) extractor.videos[episode.selectedVideo] else return
|
||||
val regex = "[\\\\/:*?\"<>|]".toRegex()
|
||||
val aTitle = animeTitle.replace(regex, "")
|
||||
val title = "Episode ${episode.number}${if (episode.title != null) " - ${episode.title}" else ""}".replace(regex, "")
|
||||
val title =
|
||||
"Episode ${episode.number}${if (episode.title != null) " - ${episode.title}" else ""}".replace(
|
||||
regex,
|
||||
""
|
||||
)
|
||||
|
||||
val notif = "$title : $aTitle"
|
||||
val folder = "/Anime/${aTitle}/"
|
||||
|
@ -64,7 +69,7 @@ object Download {
|
|||
download(context, file, fileName, folder, notif)
|
||||
}
|
||||
|
||||
fun download(context: Context, book:Book, pos:Int, novelTitle:String){
|
||||
fun download(context: Context, book: Book, pos: Int, novelTitle: String) {
|
||||
toast(currContext()?.getString(R.string.downloading))
|
||||
val regex = "[\\\\/:*?\"<>|]".toRegex()
|
||||
val nTitle = novelTitle.replace(regex, "")
|
||||
|
@ -77,19 +82,32 @@ object Download {
|
|||
download(context, file, fileName, folder, notif)
|
||||
}
|
||||
|
||||
fun download(context: Context, file: FileUrl, fileName: String, folder: String, notif: String? = null) {
|
||||
if(!file.url.startsWith("http"))
|
||||
fun download(
|
||||
context: Context,
|
||||
file: FileUrl,
|
||||
fileName: String,
|
||||
folder: String,
|
||||
notif: String? = null
|
||||
) {
|
||||
if (!file.url.startsWith("http"))
|
||||
toast(context.getString(R.string.invalid_url))
|
||||
else
|
||||
when (loadData<Int>("settings_download_manager", context, false) ?: 0) {
|
||||
1 -> oneDM(context, file, notif ?: fileName)
|
||||
2 -> adm(context, file, fileName, folder)
|
||||
1 -> oneDM(context, file, notif ?: fileName)
|
||||
2 -> adm(context, file, fileName, folder)
|
||||
else -> defaultDownload(context, file, fileName, folder, notif ?: fileName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun defaultDownload(context: Context, file: FileUrl, fileName: String, folder: String, notif: String) {
|
||||
val manager = context.getSystemService(AppCompatActivity.DOWNLOAD_SERVICE) as DownloadManager
|
||||
private fun defaultDownload(
|
||||
context: Context,
|
||||
file: FileUrl,
|
||||
fileName: String,
|
||||
folder: String,
|
||||
notif: String
|
||||
) {
|
||||
val manager =
|
||||
context.getSystemService(AppCompatActivity.DOWNLOAD_SERVICE) as DownloadManager
|
||||
val request: DownloadManager.Request = DownloadManager.Request(Uri.parse(file.url))
|
||||
file.headers.forEach {
|
||||
request.addRequestHeader(it.key, it.value)
|
||||
|
@ -124,15 +142,24 @@ object Download {
|
|||
}
|
||||
|
||||
private fun oneDM(context: Context, file: FileUrl, notif: String) {
|
||||
val appName = if (isPackageInstalled("idm.internet.download.manager.plus", context.packageManager)) {
|
||||
"idm.internet.download.manager.plus"
|
||||
} else if (isPackageInstalled("idm.internet.download.manager", context.packageManager)) {
|
||||
"idm.internet.download.manager"
|
||||
} else if (isPackageInstalled("idm.internet.download.manager.adm.lite", context.packageManager)) {
|
||||
"idm.internet.download.manager.adm.lite"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
val appName =
|
||||
if (isPackageInstalled("idm.internet.download.manager.plus", context.packageManager)) {
|
||||
"idm.internet.download.manager.plus"
|
||||
} else if (isPackageInstalled(
|
||||
"idm.internet.download.manager",
|
||||
context.packageManager
|
||||
)
|
||||
) {
|
||||
"idm.internet.download.manager"
|
||||
} else if (isPackageInstalled(
|
||||
"idm.internet.download.manager.adm.lite",
|
||||
context.packageManager
|
||||
)
|
||||
) {
|
||||
"idm.internet.download.manager.adm.lite"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
if (appName.isNotEmpty()) {
|
||||
val bundle = Bundle()
|
||||
defaultHeaders.forEach { a -> bundle.putString(a.key, a.value) }
|
||||
|
@ -177,7 +204,9 @@ object Download {
|
|||
} else {
|
||||
ContextCompat.startActivity(
|
||||
context,
|
||||
Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.dv.adm")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||
Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.dv.adm")).addFlags(
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
),
|
||||
null
|
||||
)
|
||||
toast(currContext()?.getString(R.string.install_adm))
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.io.InputStream
|
|||
|
||||
|
||||
@GlideModule
|
||||
class DantotsuGlideApp : AppGlideModule(){
|
||||
class DantotsuGlideApp : AppGlideModule() {
|
||||
@SuppressLint("CheckResult")
|
||||
override fun applyOptions(context: Context, builder: GlideBuilder) {
|
||||
super.applyOptions(context, builder)
|
||||
|
|
|
@ -19,8 +19,6 @@ import ani.dantotsu.saveImageToDownloads
|
|||
import ani.dantotsu.setSafeOnClickListener
|
||||
import ani.dantotsu.shareImage
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.toast
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||
|
@ -50,7 +48,11 @@ class ImageViewDialog : BottomSheetDialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetImageBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
@ -81,13 +83,16 @@ class ImageViewDialog : BottomSheetDialogFragment() {
|
|||
val binding = _binding ?: return@launch
|
||||
|
||||
var bitmap = context.loadBitmap_old(image, trans1 ?: listOf())
|
||||
var bitmap2 = if (image2 != null) context.loadBitmap_old(image2, trans2 ?: listOf()) else null
|
||||
var bitmap2 =
|
||||
if (image2 != null) context.loadBitmap_old(image2, trans2 ?: listOf()) else null
|
||||
if (bitmap == null) {
|
||||
bitmap = context.loadBitmap(image, trans1 ?: listOf())
|
||||
bitmap2 = if (image2 != null) context.loadBitmap(image2, trans2 ?: listOf()) else null
|
||||
bitmap2 =
|
||||
if (image2 != null) context.loadBitmap(image2, trans2 ?: listOf()) else null
|
||||
}
|
||||
|
||||
bitmap = if (bitmap2 != null && bitmap != null) mergeBitmap(bitmap, bitmap2,) else bitmap
|
||||
bitmap =
|
||||
if (bitmap2 != null && bitmap != null) mergeBitmap(bitmap, bitmap2) else bitmap
|
||||
|
||||
if (bitmap != null) {
|
||||
binding.bottomImageShare.isEnabled = true
|
||||
|
@ -100,10 +105,11 @@ class ImageViewDialog : BottomSheetDialogFragment() {
|
|||
}
|
||||
|
||||
binding.bottomImageView.setImage(ImageSource.cachedBitmap(bitmap))
|
||||
ObjectAnimator.ofFloat(binding.bottomImageView, "alpha", 0f, 1f).setDuration(400L).start()
|
||||
ObjectAnimator.ofFloat(binding.bottomImageView, "alpha", 0f, 1f).setDuration(400L)
|
||||
.start()
|
||||
binding.bottomImageProgress.visibility = View.GONE
|
||||
} else {
|
||||
toast(context?.getString(R.string.loading_image_failed))
|
||||
toast(context.getString(R.string.loading_image_failed))
|
||||
binding.bottomImageNo.visibility = View.VISIBLE
|
||||
binding.bottomImageProgress.visibility = View.GONE
|
||||
}
|
||||
|
@ -116,7 +122,12 @@ class ImageViewDialog : BottomSheetDialogFragment() {
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(title: String, image: FileUrl, showReload: Boolean = false, image2: FileUrl?) = ImageViewDialog().apply {
|
||||
fun newInstance(
|
||||
title: String,
|
||||
image: FileUrl,
|
||||
showReload: Boolean = false,
|
||||
image2: FileUrl?
|
||||
) = ImageViewDialog().apply {
|
||||
arguments = Bundle().apply {
|
||||
putString("title", title)
|
||||
putBoolean("reload", showReload)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ani.dantotsu.others
|
||||
|
||||
import ani.dantotsu.media.anime.Episode
|
||||
import ani.dantotsu.client
|
||||
import ani.dantotsu.media.anime.Episode
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -23,9 +23,10 @@ object Jikan {
|
|||
val res = query<EpisodeResponse>("anime/$malId/episodes?page=$page")
|
||||
res?.data?.forEach {
|
||||
val ep = it.malID.toString()
|
||||
eps[ep] = Episode(ep, title = it.title,
|
||||
eps[ep] = Episode(
|
||||
ep, title = it.title,
|
||||
//Personal revenge with 34566 :prayge:
|
||||
filler = if(malId!=34566) it.filler else true,
|
||||
filler = if (malId != 34566) it.filler else true,
|
||||
)
|
||||
}
|
||||
hasNextPage = res?.pagination?.hasNextPage == true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ani.dantotsu.others
|
||||
|
||||
import ani.dantotsu.logger
|
||||
import java.util.regex.*
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.math.pow
|
||||
|
||||
// https://github.com/cylonu87/JsUnpacker
|
||||
|
@ -31,7 +31,10 @@ class JsUnpacker(packedJS: String?) {
|
|||
val js = packedJS ?: return null
|
||||
try {
|
||||
var p =
|
||||
Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL)
|
||||
Pattern.compile(
|
||||
"""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""",
|
||||
Pattern.DOTALL
|
||||
)
|
||||
var m = p.matcher(js)
|
||||
if (m.find() && m.groupCount() == 4) {
|
||||
val payload = m.group(1)?.replace("\\'", "'") ?: return null
|
||||
|
@ -79,7 +82,10 @@ class JsUnpacker(packedJS: String?) {
|
|||
} else {
|
||||
val tmp = StringBuilder(str).reverse().toString()
|
||||
for (i in tmp.indices) {
|
||||
ret += (radix.toDouble().pow(i.toDouble()) * dictionary!![tmp.substring(i, i + 1)]!!).toInt()
|
||||
ret += (radix.toDouble().pow(i.toDouble()) * dictionary!![tmp.substring(
|
||||
i,
|
||||
i + 1
|
||||
)]!!).toInt()
|
||||
}
|
||||
}
|
||||
return ret
|
||||
|
@ -91,12 +97,15 @@ class JsUnpacker(packedJS: String?) {
|
|||
radix < 62 -> {
|
||||
alphabet = a62.substring(0, radix)
|
||||
}
|
||||
|
||||
radix in 63..94 -> {
|
||||
alphabet = a95.substring(0, radix)
|
||||
}
|
||||
|
||||
radix == 62 -> {
|
||||
alphabet = a62
|
||||
}
|
||||
|
||||
radix == 95 -> {
|
||||
alphabet = a95
|
||||
}
|
||||
|
|
|
@ -18,7 +18,13 @@ object Kitsu {
|
|||
"DNT" to "1",
|
||||
"Origin" to "https://kitsu.io"
|
||||
)
|
||||
val json = tryWithSuspend { client.post("https://kitsu.io/api/graphql", headers, data = mapOf("query" to query)) }
|
||||
val json = tryWithSuspend {
|
||||
client.post(
|
||||
"https://kitsu.io/api/graphql",
|
||||
headers,
|
||||
data = mapOf("query" to query)
|
||||
)
|
||||
}
|
||||
return json?.parsed()
|
||||
}
|
||||
|
||||
|
@ -54,8 +60,8 @@ query {
|
|||
val result = getKitsuData(query) ?: return null
|
||||
logger("Kitsu : result=$result", print)
|
||||
media.idKitsu = result.data?.lookupMapping?.id
|
||||
return (result.data?.lookupMapping?.episodes?.nodes?:return null).mapNotNull { ep ->
|
||||
val num = ep?.num?.toString()?:return@mapNotNull null
|
||||
return (result.data?.lookupMapping?.episodes?.nodes ?: return null).mapNotNull { ep ->
|
||||
val num = ep?.num?.toString() ?: return@mapNotNull null
|
||||
num to Episode(
|
||||
number = num,
|
||||
title = ep.titles?.canonical,
|
||||
|
@ -70,39 +76,46 @@ query {
|
|||
@SerialName("data") val data: Data? = null
|
||||
) {
|
||||
@Serializable
|
||||
data class Data (
|
||||
data class Data(
|
||||
@SerialName("lookupMapping") val lookupMapping: LookupMapping? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class LookupMapping (
|
||||
data class LookupMapping(
|
||||
@SerialName("id") val id: String? = null,
|
||||
@SerialName("episodes") val episodes: Episodes? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Episodes (
|
||||
data class Episodes(
|
||||
@SerialName("nodes") val nodes: List<Node?>? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Node (
|
||||
data class Node(
|
||||
@SerialName("number") val num: Long? = null,
|
||||
@SerialName("titles") val titles: Titles? = null,
|
||||
@SerialName("description") val description: Description? = null,
|
||||
@SerialName("thumbnail") val thumbnail: Thumbnail? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Description (
|
||||
data class Description(
|
||||
@SerialName("en") val en: String? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Thumbnail (
|
||||
data class Thumbnail(
|
||||
@SerialName("original") val original: Original? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Original (
|
||||
data class Original(
|
||||
@SerialName("url") val url: String? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Titles (
|
||||
data class Titles(
|
||||
@SerialName("canonical") val canonical: String? = null
|
||||
)
|
||||
|
||||
|
|
|
@ -6,13 +6,12 @@ import android.content.res.Resources
|
|||
import java.util.Locale
|
||||
|
||||
|
||||
|
||||
|
||||
class LangSet {
|
||||
companion object{
|
||||
companion object {
|
||||
fun setLocale(activity: Activity) {
|
||||
val useCursedLang = activity.getSharedPreferences("Dantotsu", Activity.MODE_PRIVATE).getBoolean("use_cursed_lang", false)
|
||||
val locale = if(useCursedLang) Locale("en", "DW") else Locale("en", "US")
|
||||
val useCursedLang = activity.getSharedPreferences("Dantotsu", Activity.MODE_PRIVATE)
|
||||
.getBoolean("use_cursed_lang", false)
|
||||
val locale = if (useCursedLang) Locale("en", "DW") else Locale("en", "US")
|
||||
Locale.setDefault(locale)
|
||||
val resources: Resources = activity.resources
|
||||
val config: Configuration = resources.configuration
|
||||
|
|
|
@ -17,11 +17,14 @@ object MalScraper {
|
|||
try {
|
||||
withTimeout(6000) {
|
||||
if (media.anime != null) {
|
||||
val res = client.get("https://myanimelist.net/anime/${media.idMAL}", headers).document
|
||||
val res =
|
||||
client.get("https://myanimelist.net/anime/${media.idMAL}", headers).document
|
||||
val a = res.select(".title-english").text()
|
||||
media.nameMAL = if (a != "") a else res.select(".title-name").text()
|
||||
media.typeMAL =
|
||||
if (res.select("div.spaceit_pad > a").isNotEmpty()) res.select("div.spaceit_pad > a")[0].text() else null
|
||||
if (res.select("div.spaceit_pad > a")
|
||||
.isNotEmpty()
|
||||
) res.select("div.spaceit_pad > a")[0].text() else null
|
||||
media.anime.op = arrayListOf()
|
||||
res.select(".opnening > table > tbody > tr").forEach {
|
||||
val text = it.text()
|
||||
|
@ -35,12 +38,15 @@ object MalScraper {
|
|||
media.anime.ed.add(it.text())
|
||||
}
|
||||
} else {
|
||||
val res = client.get("https://myanimelist.net/manga/${media.idMAL}", headers).document
|
||||
val res =
|
||||
client.get("https://myanimelist.net/manga/${media.idMAL}", headers).document
|
||||
val b = res.select(".title-english").text()
|
||||
val a = res.select(".h1-title").text().removeSuffix(b)
|
||||
media.nameMAL = a
|
||||
media.typeMAL =
|
||||
if (res.select("div.spaceit_pad > a").isNotEmpty()) res.select("div.spaceit_pad > a")[0].text() else null
|
||||
if (res.select("div.spaceit_pad > a")
|
||||
.isNotEmpty()
|
||||
) res.select("div.spaceit_pad > a")[0].text() else null
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
|
|
@ -31,8 +31,8 @@ object MalSyncBackup {
|
|||
val isDub = page.title.lowercase().replace(" ", "").endsWith("(dub)")
|
||||
val slug = if (dub == isDub) page.identifier else null
|
||||
if (slug != null && page.active == true && page.url != null) {
|
||||
val url = when(name){
|
||||
"Gogoanime" -> slug
|
||||
val url = when (name) {
|
||||
"Gogoanime" -> slug
|
||||
"Tenshi" -> slug
|
||||
else -> page.url
|
||||
}
|
||||
|
|
|
@ -25,7 +25,11 @@ class OutlineTextView : AppCompatTextView {
|
|||
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
) {
|
||||
initResources(context, attrs)
|
||||
|
||||
}
|
||||
|
@ -55,7 +59,8 @@ class OutlineTextView : AppCompatTextView {
|
|||
strokeWidth = width.toPx(context)
|
||||
}
|
||||
|
||||
private fun Float.toPx(context: Context) = (this * context.resources.displayMetrics.scaledDensity + 0.5F)
|
||||
private fun Float.toPx(context: Context) =
|
||||
(this * context.resources.displayMetrics.scaledDensity + 0.5F)
|
||||
|
||||
override fun invalidate() {
|
||||
if (isDrawing) return
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package ani.dantotsu.others
|
||||
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.*
|
||||
import java.util.Timer
|
||||
import java.util.TimerTask
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
class ResettableTimer {
|
||||
var resetLock = AtomicBoolean(false)
|
||||
|
|
|
@ -10,7 +10,7 @@ import android.view.View
|
|||
import android.widget.TextView
|
||||
import io.noties.markwon.AbstractMarkwonPlugin
|
||||
import io.noties.markwon.utils.ColorUtils
|
||||
import java.util.regex.*
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class SpoilerPlugin : AbstractMarkwonPlugin() {
|
||||
override fun beforeSetText(textView: TextView, markdown: Spanned) {
|
||||
|
|
|
@ -29,8 +29,8 @@ class Xpandable @JvmOverloads constructor(
|
|||
}, 300)
|
||||
}
|
||||
|
||||
if(!expanded) children.forEach {
|
||||
if (it != getChildAt(0)){
|
||||
if (!expanded) children.forEach {
|
||||
if (it != getChildAt(0)) {
|
||||
it.visibility = GONE
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class Xpandable @JvmOverloads constructor(
|
|||
|
||||
private fun hideAll() {
|
||||
children.forEach {
|
||||
if (it != getChildAt(0)){
|
||||
if (it != getChildAt(0)) {
|
||||
ObjectAnimator.ofFloat(it, "scaleY", 1f, 0.5f).setDuration(200).start()
|
||||
ObjectAnimator.ofFloat(it, "translationY", 0f, -32f).setDuration(200).start()
|
||||
ObjectAnimator.ofFloat(it, "alpha", 1f, 0f).setDuration(200).start()
|
||||
|
@ -54,7 +54,7 @@ class Xpandable @JvmOverloads constructor(
|
|||
|
||||
private fun showAll() {
|
||||
children.forEach {
|
||||
if (it != getChildAt(0)){
|
||||
if (it != getChildAt(0)) {
|
||||
it.visibility = VISIBLE
|
||||
ObjectAnimator.ofFloat(it, "scaleY", 0.5f, 1f).setDuration(200).start()
|
||||
ObjectAnimator.ofFloat(it, "translationY", -32f, 0f).setDuration(200).start()
|
||||
|
|
|
@ -15,8 +15,8 @@ import ani.dantotsu.R
|
|||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.databinding.ActivityImageSearchBinding
|
||||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.toast
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -36,7 +36,7 @@ class ImageSearchActivity : AppCompatActivity() {
|
|||
}
|
||||
val inputStream = contentResolver.openInputStream(imageUri)
|
||||
|
||||
if(inputStream != null) viewModel.analyzeImage(inputStream)
|
||||
if (inputStream != null) viewModel.analyzeImage(inputStream)
|
||||
else toast(getString(R.string.error_loading_image))
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
|
@ -49,7 +49,7 @@ class ImageSearchActivity : AppCompatActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
LangSet.setLocale(this)
|
||||
ThemeManager(this).applyTheme()
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityImageSearchBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
@ -76,7 +76,7 @@ ThemeManager(this).applyTheme()
|
|||
override fun onItemClick(searchResult: ImageSearchViewModel.ImageResult) {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
val id = searchResult.anilist?.id?.toInt()
|
||||
if (id==null){
|
||||
if (id == null) {
|
||||
toast(getString(R.string.no_anilist_id_found))
|
||||
return@launch
|
||||
}
|
||||
|
|
|
@ -20,10 +20,12 @@ class ImageSearchResultAdapter(private val searchResults: List<ImageSearchViewMo
|
|||
itemClickListener = listener
|
||||
}
|
||||
|
||||
inner class SearchResultViewHolder(val binding : ItemSearchByImageBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
inner class SearchResultViewHolder(val binding: ItemSearchByImageBinding) :
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchResultViewHolder {
|
||||
val binding = ItemSearchByImageBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val binding =
|
||||
ItemSearchByImageBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return SearchResultViewHolder(binding)
|
||||
}
|
||||
|
||||
|
@ -40,7 +42,8 @@ class ImageSearchResultAdapter(private val searchResults: List<ImageSearchViewMo
|
|||
R.string.similarity_text, String.format("%.1f", searchResult.similarity?.times(100))
|
||||
)
|
||||
|
||||
binding.episodeNumber.text = getString(R.string.episode_num, searchResult.episode.toString())
|
||||
binding.episodeNumber.text =
|
||||
getString(R.string.episode_num, searchResult.episode.toString())
|
||||
binding.timeStamp.text = getString(
|
||||
R.string.time_range,
|
||||
toTimestamp(searchResult.from),
|
||||
|
|
|
@ -30,7 +30,7 @@ class ImageSearchViewModel : ViewModel() {
|
|||
searchResultLiveData.postValue(res)
|
||||
}
|
||||
|
||||
fun clearResults(){
|
||||
fun clearResults() {
|
||||
searchResultLiveData.postValue(SearchResult())
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,11 @@ abstract class WebViewBottomDialog : BottomSheetDialogFragment() {
|
|||
|
||||
val cookies: CookieManager = CookieManager.getInstance()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetWebviewBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue