@@ -23,6 +23,7 @@ import com.github.libretube.extensions.toID
2323import com.github.libretube.extensions.toastFromMainDispatcher
2424import com.github.libretube.helpers.DownloadHelper
2525import com.github.libretube.parcelable.DownloadData
26+ import com.github.libretube.util.TextUtils
2627import kotlinx.coroutines.Dispatchers
2728import kotlinx.coroutines.launch
2829
@@ -142,9 +143,16 @@ class PlaylistDownloadEnqueueService : LifecycleService() {
142143 val videoStream = getStream(videoInfo.videoStreams, maxVideoQuality)
143144 val audioStream = getStream(videoInfo.audioStreams, maxAudioQuality)
144145
146+ // remove all UNIX reserved characters from the title in order to generate
147+ // a valid filename
148+ var fileName = videoInfo.title
149+ TextUtils .RESERVED_CHARS .forEach {
150+ fileName = fileName.replace(it, ' _' )
151+ }
152+
145153 val downloadData = DownloadData (
146154 videoId = stream.url!! .toID(),
147- fileName = videoInfo.title ,
155+ fileName = fileName ,
148156 videoFormat = videoStream?.format,
149157 videoQuality = videoStream?.quality,
150158 audioFormat = audioStream?.format,
0 commit comments