VideoDownloadManager

Types

Link copied to clipboard
data class CreateNotificationMetadata(    val type: VideoDownloadManager.DownloadType,     val bytesDownloaded: Long,     val bytesTotal: Long,     val hlsProgress: Long? = null,     val hlsTotal: Long? = null,     val bytesPerSecond: Long)
Link copied to clipboard
data class DownloadedFileInfo(    val totalBytes: Long,     val relativePath: String,     val displayName: String,     val extraInfo: String? = null,     val basePath: String? = null)
Link copied to clipboard
data class DownloadedFileInfoResult(val fileLength: Long, val totalBytes: Long, val path: Uri)
Link copied to clipboard
data class DownloadEpisodeMetadata(    val id: Int,     val mainName: String,     val sourceApiName: String?,     val poster: String?,     val name: String?,     val season: Int?,     val episode: Int?,     val type: TvType?)
Link copied to clipboard
data class DownloadInfo(    val source: String?,     val folder: String?,     val ep: VideoDownloadManager.DownloadEpisodeMetadata,     val links: List<ExtractorLink>)
Link copied to clipboard
data class DownloadItem(    val source: String?,     val folder: String?,     val ep: VideoDownloadManager.DownloadEpisodeMetadata,     val links: List<ExtractorLink>)
Link copied to clipboard
data class DownloadMetaData(    id: Int?,     var bytesDownloaded: Long = 0,     var bytesWritten: Long = 0,     var totalBytes: Long? = null,     lastUpdatedMs: Long = 0,     lastDownloadedBytes: Long = 0,     createNotificationCallback: (VideoDownloadManager.CreateNotificationMetadata) -> Unit,     internalType: VideoDownloadManager.DownloadType = DownloadType.IsPending,     var hlsProgress: Int = 0,     var hlsTotal: Int? = null,     var hlsWrittenProgress: Int = 0,     downloadFileInfoTemplate: VideoDownloadManager.DownloadedFileInfo? = null) : Closeable

This class handles the notifications, as well as the relevant key

Link copied to clipboard
data class DownloadResumePackage(val item: VideoDownloadManager.DownloadItem, val linkIndex: Int?)
Link copied to clipboard
data class DownloadStatus(val retrySame: Boolean, val tryNext: Boolean, val success: Boolean)
Link copied to clipboard
data class LazyStreamDownloadData(    url: String,     headers: Map<String, String>,     referer: String,     chuckStartByte: LongArray,     val totalLength: Long?,     val downloadLength: Long?,     val chuckSize: Long,     val bufferSize: Int,     val isResumed: Boolean)
Link copied to clipboard
data class LazyStreamDownloadResponse(val bytes: ByteArray, val startByte: Long, val endByte: Long)

bytes have the size end-start where the byte range is [start,end) note that ByteArray is a pointer and therefore cant be stored without cloning it

Link copied to clipboard
data class StreamData(fileLength: Long, val file: SafeFile)

Properties

Link copied to clipboard
Link copied to clipboard
val imgDone: <Error class: unknown class>
Link copied to clipboard
val imgDownloading: <Error class: unknown class>
Link copied to clipboard
val imgError: <Error class: unknown class>
Link copied to clipboard
val imgPaused: <Error class: unknown class>
Link copied to clipboard
val imgStopped: <Error class: unknown class>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val pressToPauseIcon: <Error class: unknown class>
Link copied to clipboard
val pressToResumeIcon: <Error class: unknown class>
Link copied to clipboard
val pressToStopIcon: <Error class: unknown class>
Link copied to clipboard
const val TAG: String
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun deleteFilesAndUpdateSettings(context: Context, ids: Set<Int>, scope: CoroutineScope, onComplete: (Set<Int>) -> Unit = {})
Link copied to clipboard
suspend fun downloadCheck(context: Context, notificationCallback: (Int, Notification) -> Unit)
Link copied to clipboard
Link copied to clipboard
suspend fun downloadEpisode(    context: Context?,     source: String?,     folder: String?,     ep: VideoDownloadManager.DownloadEpisodeMetadata,     links: List<ExtractorLink>,     notificationCallback: (Int, Notification) -> Unit)
Link copied to clipboard
fun downloadEpisodeUsingWorker(    context: Context,     source: String?,     folder: String?,     ep: VideoDownloadManager.DownloadEpisodeMetadata,     links: List<ExtractorLink>)
Link copied to clipboard
suspend fun downloadFromResume(    context: Context,     pkg: VideoDownloadManager.DownloadResumePackage,     notificationCallback: (Int, Notification) -> Unit,     setKey: Boolean = true)
Link copied to clipboard
suspend fun downloadThing(    context: Context,     link: IDownloadableMinimum,     name: String,     folder: String,     extension: String,     tryResume: Boolean,     parentId: Int?,     createNotificationCallback: (VideoDownloadManager.CreateNotificationMetadata) -> Unit,     parallelConnections: Int = 3,     minimumSize: Long = 100): VideoDownloadManager.DownloadStatus

download a file that consist of a single stream of data

Link copied to clipboard
fun Context.getBasePath(): Pair<SafeFile?, String?>

Base path where downloaded things should be stored, changes depending on settings. Returns the file and a string to be stored for future file retrieval. UniFile.filePath is not sufficient for storage.

Link copied to clipboard
fun getDefaultDir(context: Context): SafeFile?

Gets the default download path as an UniFile. Vital for legacy downloads, be careful about changing anything here.

Link copied to clipboard
Link copied to clipboard
fun getFolder(context: Context, relativePath: String, basePath: String?): List<Pair<String, Uri>>?

Used for getting video player subs.

Link copied to clipboard
fun Context.getImageBitmapFromUrl(url: String, headers: Map<String, String>? = null): Bitmap?
Link copied to clipboard
fun sanitizeFilename(name: String, removeSpaces: Boolean = false): String
Link copied to clipboard
fun setupStream(context: Context, name: String, folder: String?, extension: String, tryResume: Boolean): VideoDownloadManager.StreamData

fun setupStream(baseFile: SafeFile, name: String, folder: String?, extension: String, tryResume: Boolean): VideoDownloadManager.StreamData

Sets up the appropriate file and creates a data stream from the file. Used for initializing downloads.

Link copied to clipboard
suspend fun streamLazy(    url: String,     headers: Map<String, String>,     referer: String,     startByte: Long,     chuckSize: Long = (1 shl 20) * 10,     bufferSize: Int = DEFAULT_BUFFER_SIZE,     maximumSmallSize: Long = chuckSize * 2): VideoDownloadManager.LazyStreamDownloadData