Created new cache/downloader
This commit is contained in:
@@ -19,7 +19,14 @@
|
||||
package xyz.quaver.pupil.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import okhttp3.OkHttpClient
|
||||
import xyz.quaver.pupil.util.downloader.Cache
|
||||
import xyz.quaver.pupil.util.downloader.Metadata
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@@ -67,4 +74,20 @@ fun OkHttpClient.Builder.proxyInfo(proxyInfo: ProxyInfo) = this.apply {
|
||||
proxyInfo.authenticator()?.let {
|
||||
proxyAuthenticator(it)
|
||||
}
|
||||
}
|
||||
|
||||
val formatMap = mapOf<String, (Cache) -> (String)>(
|
||||
"\$ID" to { runBlocking { it.getGalleryBlock()?.id.toString() } },
|
||||
"\$TITLE" to { runBlocking { it.getGalleryBlock()?.title.toString() } },
|
||||
// TODO
|
||||
)
|
||||
/**
|
||||
* Formats download folder name with given Metadata
|
||||
*/
|
||||
fun Cache.formatDownloadFolder(): String {
|
||||
return Preferences["download_folder_format", "\$ID"].apply {
|
||||
formatMap.entries.forEach { (key, lambda) ->
|
||||
this.replace(key, lambda.invoke(this@formatDownloadFolder))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user