mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Better download file naming scheme
This commit is contained in:
parent
1972c0a45d
commit
9ec166dcef
@ -0,0 +1,8 @@
|
||||
package com.github.libretube.extensions
|
||||
|
||||
import com.github.libretube.api.obj.PipedStream
|
||||
|
||||
fun PipedStream?.qualityString(fileName: String): String {
|
||||
this ?: return ""
|
||||
return fileName + "_" + quality?.replace(" ", "_") + "_" + format + "." + mimeType?.split("/")?.last()
|
||||
}
|
@ -16,12 +16,12 @@ fun Streams.toDownloadItems(
|
||||
val items = mutableListOf<DownloadItem>()
|
||||
|
||||
if (!videoQuality.isNullOrEmpty() && !videoFormat.isNullOrEmpty()) {
|
||||
val stream = videoStreams?.find { it.quality == videoQuality && it.format == videoFormat }
|
||||
val stream = videoStreams.find { it.quality == videoQuality && it.format == videoFormat }
|
||||
items.add(
|
||||
DownloadItem(
|
||||
type = FileType.VIDEO,
|
||||
videoId = videoId,
|
||||
fileName = fileName + "." + stream?.mimeType?.split("/")?.last(),
|
||||
fileName = stream.qualityString(fileName),
|
||||
path = "",
|
||||
url = stream?.url,
|
||||
format = videoFormat,
|
||||
@ -31,12 +31,12 @@ fun Streams.toDownloadItems(
|
||||
}
|
||||
|
||||
if (!audioQuality.isNullOrEmpty() && !audioFormat.isNullOrEmpty()) {
|
||||
val stream = audioStreams?.find { it.quality == audioQuality && it.format == audioFormat }
|
||||
val stream = audioStreams.find { it.quality == audioQuality && it.format == audioFormat }
|
||||
items.add(
|
||||
DownloadItem(
|
||||
type = FileType.AUDIO,
|
||||
videoId = videoId,
|
||||
fileName = fileName + "." + stream?.mimeType?.split("/")?.last(),
|
||||
fileName = stream.qualityString(fileName),
|
||||
path = "",
|
||||
url = stream?.url,
|
||||
format = audioFormat,
|
||||
@ -50,9 +50,9 @@ fun Streams.toDownloadItems(
|
||||
DownloadItem(
|
||||
type = FileType.SUBTITLE,
|
||||
videoId = videoId,
|
||||
fileName = "$fileName.srt",
|
||||
fileName = "${fileName}_$subtitleCode.srt",
|
||||
path = "",
|
||||
url = subtitles?.find { it.code == subtitleCode }?.url
|
||||
url = subtitles.find { it.code == subtitleCode }?.url
|
||||
)
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user