mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
fix: playlist download service crashes for video titles with invalid file name characters
This commit is contained in:
parent
2c0b43e02f
commit
4e71792e27
@ -23,6 +23,7 @@ import com.github.libretube.extensions.toID
|
|||||||
import com.github.libretube.extensions.toastFromMainDispatcher
|
import com.github.libretube.extensions.toastFromMainDispatcher
|
||||||
import com.github.libretube.helpers.DownloadHelper
|
import com.github.libretube.helpers.DownloadHelper
|
||||||
import com.github.libretube.parcelable.DownloadData
|
import com.github.libretube.parcelable.DownloadData
|
||||||
|
import com.github.libretube.util.TextUtils
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@ -142,9 +143,16 @@ class PlaylistDownloadEnqueueService : LifecycleService() {
|
|||||||
val videoStream = getStream(videoInfo.videoStreams, maxVideoQuality)
|
val videoStream = getStream(videoInfo.videoStreams, maxVideoQuality)
|
||||||
val audioStream = getStream(videoInfo.audioStreams, maxAudioQuality)
|
val audioStream = getStream(videoInfo.audioStreams, maxAudioQuality)
|
||||||
|
|
||||||
|
// remove all UNIX reserved characters from the title in order to generate
|
||||||
|
// a valid filename
|
||||||
|
var fileName = videoInfo.title
|
||||||
|
TextUtils.RESERVED_CHARS.forEach {
|
||||||
|
fileName = fileName.replace(it, '_')
|
||||||
|
}
|
||||||
|
|
||||||
val downloadData = DownloadData(
|
val downloadData = DownloadData(
|
||||||
videoId = stream.url!!.toID(),
|
videoId = stream.url!!.toID(),
|
||||||
fileName = videoInfo.title,
|
fileName = fileName,
|
||||||
videoFormat = videoStream?.format,
|
videoFormat = videoStream?.format,
|
||||||
videoQuality = videoStream?.quality,
|
videoQuality = videoStream?.quality,
|
||||||
audioFormat = audioStream?.format,
|
audioFormat = audioStream?.format,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user