feat: support for multiple audio/subtitle downloads

This commit is contained in:
rebelonion 2024-05-16 14:51:35 -05:00
parent fd8dd26435
commit f1d16ba16a
10 changed files with 137 additions and 117 deletions

View file

@ -10,7 +10,7 @@ sealed class DownloadAddon : Addon() {
override val pkgName: String,
override val versionName: String,
override val versionCode: Long,
val extension: DownloadAddonApi,
val extension: DownloadAddonApiV2,
val icon: Drawable?,
val hasUpdate: Boolean = false,
) : Addon.Installed(name, pkgName, versionName, versionCode)

View file

@ -1,21 +0,0 @@
package ani.dantotsu.addons.download
import android.content.Context
import android.net.Uri
interface DownloadAddonApi {
fun cancelDownload(sessionId: Long)
fun setDownloadPath(context: Context, uri: Uri): String
suspend fun executeFFProbe(request: String, logCallback: (String) -> Unit)
suspend fun executeFFMpeg(request: String, statCallback: (Double) -> Unit): Long
fun getState(sessionId: Long): String
fun getStackTrace(sessionId: Long): String?
fun hadError(sessionId: Long): Boolean
}

View file

@ -0,0 +1,32 @@
package ani.dantotsu.addons.download
import android.content.Context
import android.net.Uri
interface DownloadAddonApiV2 {
fun cancelDownload(sessionId: Long)
fun setDownloadPath(context: Context, uri: Uri): String
suspend fun executeFFProbe(
videoUrl: String,
headers: Map<String, String> = emptyMap(),
logCallback: (String) -> Unit
)
suspend fun executeFFMpeg(
videoUrl: String,
downloadPath: String,
headers: Map<String, String> = emptyMap(),
subtitleUrls: List<Pair<String, String>> = emptyList(),
audioUrls: List<Pair<String, String>> = emptyList(),
statCallback: (Double) -> Unit
): Long
fun getState(sessionId: Long): String
fun getStackTrace(sessionId: Long): String?
fun hadError(sessionId: Long): Boolean
}