fix: PC steuern zeigt Cover scharf statt 60x60 Pixel (v1.2.1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -67,7 +67,7 @@ object PcRemote {
|
||||
visibleTab = state.optString("visibleTab", activeTab),
|
||||
title = tab.text("title"),
|
||||
subtitle = tab.text("subtitle"),
|
||||
thumbnail = tab.text("thumbnail").takeIf { it.startsWith("https://") }.orEmpty(),
|
||||
thumbnail = largeCover(tab.text("thumbnail").takeIf { it.startsWith("https://") }.orEmpty()),
|
||||
playing = tab?.optBoolean("playing") ?: false,
|
||||
position = tab?.optDouble("currentTime")?.takeIf { it.isFinite() } ?: 0.0,
|
||||
duration = tab?.optDouble("duration")?.takeIf { it.isFinite() } ?: 0.0,
|
||||
@@ -76,6 +76,20 @@ object PcRemote {
|
||||
)
|
||||
}
|
||||
|
||||
private val GOOGLE_IMAGE_SIZE = Regex("=(w\\d+-h\\d+|s\\d+)[^/=]*$")
|
||||
private val YTIMG_SMALL = Regex("/(default|mqdefault)\\.jpg$")
|
||||
|
||||
/**
|
||||
* Das Cover aus der YouTube-Music-Player-Leiste ist nur 60x60 Pixel gross ("=w60-h60-l90-rj") -
|
||||
* fuer die Fernbedienung in 544x544 anfordern; kleine YouTube-Vorschaubilder durch hqdefault ersetzen.
|
||||
*/
|
||||
fun largeCover(url: String): String = when {
|
||||
url.contains("googleusercontent.com") || url.contains("ggpht.com") ->
|
||||
url.replace(GOOGLE_IMAGE_SIZE, "=w544-h544-l90-rj")
|
||||
url.contains("ytimg.com") -> url.replace(YTIMG_SMALL, "/hqdefault.jpg")
|
||||
else -> url
|
||||
}
|
||||
|
||||
/** Textfeld ohne JSON-null ("null" als Text waere sonst sichtbar). */
|
||||
private fun JSONObject?.text(key: String): String =
|
||||
if (this == null || isNull(key)) "" else optString(key)
|
||||
|
||||
Reference in New Issue
Block a user