Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: playlist download service crashes for video titles with invalid filename characters #7180

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.github.libretube.extensions.toID
import com.github.libretube.extensions.toastFromMainDispatcher
import com.github.libretube.helpers.DownloadHelper
import com.github.libretube.parcelable.DownloadData
import com.github.libretube.util.TextUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -142,9 +143,16 @@ class PlaylistDownloadEnqueueService : LifecycleService() {
val videoStream = getStream(videoInfo.videoStreams, maxVideoQuality)
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(
videoId = stream.url!!.toID(),
fileName = videoInfo.title,
fileName = fileName,
videoFormat = videoStream?.format,
videoQuality = videoStream?.quality,
audioFormat = audioStream?.format,
Expand Down
Loading