fix some issues

This commit is contained in:
Bnyro 2022-11-21 14:35:09 +01:00
parent 592f1b5648
commit bbd021fc6d
3 changed files with 9 additions and 7 deletions

View File

@ -38,7 +38,7 @@ object PlaylistsHelper {
Playlists(
id = it.playlist.id.toString(),
name = it.playlist.name,
thumbnail = it.playlist.thumbnailUrl,
thumbnail = ProxyHelper.rewriteUrl(it.playlist.thumbnailUrl),
videos = it.videos.size.toLong()
)
)

View File

@ -1,6 +1,5 @@
package com.github.libretube.extensions
import android.util.Log
import com.github.libretube.api.obj.StreamItem
import com.github.libretube.api.obj.Streams
import com.github.libretube.db.obj.LocalPlaylistItem
@ -24,7 +23,6 @@ fun Streams.toStreamItem(videoId: String): StreamItem {
}
fun LocalPlaylistItem.toStreamItem(): StreamItem {
Log.e("thumb", ProxyHelper.rewriteUrl(thumbnailUrl).toString())
return StreamItem(
url = videoId,
title = title,

View File

@ -6,6 +6,9 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.net.URI
import java.net.URLDecoder
import java.nio.charset.StandardCharsets
import java.util.*
object ProxyHelper {
private fun getImageProxyUrl(): String? {
@ -35,13 +38,14 @@ object ProxyHelper {
runCatching {
val originalUri = URI(url)
return URI(
originalUri.scheme.lowercase(),
proxyUrl,
val newUri = URI(
originalUri.scheme.lowercase(Locale.US),
URI(proxyUrl).authority,
originalUri.path,
originalUri.query,
originalUri.fragment
).toString()
)
return URLDecoder.decode(newUri.toString(), StandardCharsets.UTF_8.toString())
}
return url
}