1+ /*
2+ * SPDX-FileCopyrightText: 2025 NewPipe contributors <https://newpipe.net>
3+ * SPDX-License-Identifier: GPL-3.0-or-later
4+ */
5+
16package org.schabi.newpipe.local.playlist
27
38import android.content.Context
@@ -21,11 +26,7 @@ fun export(
2126 }
2227}
2328
24- fun exportWithTitles (
25- playlist : List <PlaylistStreamEntry >,
26- context : Context
27- ): String {
28-
29+ private fun exportWithTitles (playlist : List <PlaylistStreamEntry >, context : Context ): String {
2930 return playlist.asSequence()
3031 .map { it.streamEntity }
3132 .map { entity ->
@@ -38,18 +39,14 @@ fun exportWithTitles(
3839 .joinToString(separator = " \n " )
3940}
4041
41- fun exportJustUrls (playlist : List <PlaylistStreamEntry >): String {
42-
43- return playlist.asSequence()
44- .map { it.streamEntity.url }
45- .joinToString(separator = " \n " )
42+ private fun exportJustUrls (playlist : List <PlaylistStreamEntry >): String {
43+ return playlist.joinToString(separator = " \n " ) { it.streamEntity.url }
4644}
4745
48- fun exportAsYoutubeTempPlaylist (playlist : List <PlaylistStreamEntry >): String {
46+ private fun exportAsYoutubeTempPlaylist (playlist : List <PlaylistStreamEntry >): String {
4947
5048 val videoIDs = playlist.asReversed().asSequence()
51- .map { it.streamEntity.url }
52- .mapNotNull(::getYouTubeId)
49+ .mapNotNull { getYouTubeId(it.streamEntity.url) }
5350 .take(50 ) // YouTube limitation: temp playlists can't have more than 50 items
5451 .toList()
5552 .asReversed()
@@ -58,15 +55,15 @@ fun exportAsYoutubeTempPlaylist(playlist: List<PlaylistStreamEntry>): String {
5855 return " https://www.youtube.com/watch_videos?video_ids=$videoIDs "
5956}
6057
61- val linkHandler: YoutubeStreamLinkHandlerFactory = YoutubeStreamLinkHandlerFactory .getInstance()
58+ private val linkHandler: YoutubeStreamLinkHandlerFactory = YoutubeStreamLinkHandlerFactory .getInstance()
6259
6360/* *
6461 * Gets the video id from a YouTube URL.
6562 *
6663 * @param url YouTube URL
6764 * @return the video id
6865 */
69- fun getYouTubeId (url : String ): String? {
66+ private fun getYouTubeId (url : String ): String? {
7067
7168 return try { linkHandler.getId(url) } catch (e: ParsingException ) { null }
7269}
0 commit comments