mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40: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>()
|
val items = mutableListOf<DownloadItem>()
|
||||||
|
|
||||||
if (!videoQuality.isNullOrEmpty() && !videoFormat.isNullOrEmpty()) {
|
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(
|
items.add(
|
||||||
DownloadItem(
|
DownloadItem(
|
||||||
type = FileType.VIDEO,
|
type = FileType.VIDEO,
|
||||||
videoId = videoId,
|
videoId = videoId,
|
||||||
fileName = fileName + "." + stream?.mimeType?.split("/")?.last(),
|
fileName = stream.qualityString(fileName),
|
||||||
path = "",
|
path = "",
|
||||||
url = stream?.url,
|
url = stream?.url,
|
||||||
format = videoFormat,
|
format = videoFormat,
|
||||||
@ -31,12 +31,12 @@ fun Streams.toDownloadItems(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!audioQuality.isNullOrEmpty() && !audioFormat.isNullOrEmpty()) {
|
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(
|
items.add(
|
||||||
DownloadItem(
|
DownloadItem(
|
||||||
type = FileType.AUDIO,
|
type = FileType.AUDIO,
|
||||||
videoId = videoId,
|
videoId = videoId,
|
||||||
fileName = fileName + "." + stream?.mimeType?.split("/")?.last(),
|
fileName = stream.qualityString(fileName),
|
||||||
path = "",
|
path = "",
|
||||||
url = stream?.url,
|
url = stream?.url,
|
||||||
format = audioFormat,
|
format = audioFormat,
|
||||||
@ -50,9 +50,9 @@ fun Streams.toDownloadItems(
|
|||||||
DownloadItem(
|
DownloadItem(
|
||||||
type = FileType.SUBTITLE,
|
type = FileType.SUBTITLE,
|
||||||
videoId = videoId,
|
videoId = videoId,
|
||||||
fileName = "$fileName.srt",
|
fileName = "${fileName}_$subtitleCode.srt",
|
||||||
path = "",
|
path = "",
|
||||||
url = subtitles?.find { it.code == subtitleCode }?.url
|
url = subtitles.find { it.code == subtitleCode }?.url
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user