fix the parsing of the videoID when importing playlists in some cases

This commit is contained in:
Bnyro 2022-12-06 11:39:33 +01:00
parent 50f5ca5610
commit 3c3d313bec
2 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.github.libretube.api package com.github.libretube.api
import android.content.Context import android.content.Context
import android.net.Uri
import android.util.Log import android.util.Log
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.obj.Playlist import com.github.libretube.api.obj.Playlist
@ -195,7 +196,7 @@ object PlaylistsHelper {
addToPlaylist( addToPlaylist(
playlistId, playlistId,
*playlist.videos.map { *playlist.videos.map {
it.substringAfter("=") Uri.parse(it).getQueryParameter("v")!!
}.toTypedArray() }.toTypedArray()
) )
} }
@ -231,7 +232,7 @@ object PlaylistsHelper {
return if (loggedIn()) PlaylistType.PRIVATE else PlaylistType.LOCAL return if (loggedIn()) PlaylistType.PRIVATE else PlaylistType.LOCAL
} }
fun getPrivatePlaylistType(playlistId: String): PlaylistType { private fun getPrivatePlaylistType(playlistId: String): PlaylistType {
if (playlistId.all { it.isDigit() }) return PlaylistType.LOCAL if (playlistId.all { it.isDigit() }) return PlaylistType.LOCAL
if (playlistId.matches(pipedPlaylistRegex)) return PlaylistType.PRIVATE if (playlistId.matches(pipedPlaylistRegex)) return PlaylistType.PRIVATE
return PlaylistType.PUBLIC return PlaylistType.PUBLIC

View File

@ -463,7 +463,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
binding.playerDescriptionArrow.animate().rotation(0F).setDuration(250).start() binding.playerDescriptionArrow.animate().rotation(0F).setDuration(250).start()
binding.descLinLayout.visibility = View.GONE binding.descLinLayout.visibility = View.GONE
// show formated short view count // show formatted short view count
viewInfo = getString(R.string.views, streams.views.formatShort()) + viewInfo viewInfo = getString(R.string.views, streams.views.formatShort()) + viewInfo
} else { } else {
// show the description and chapters // show the description and chapters