Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
341155bc6b | ||
|
|
e0dd61fbb4 | ||
|
|
e3c534c569 |
@@ -19,8 +19,8 @@ android {
|
||||
applicationId = "de.fojadrachi.playtube"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 11
|
||||
versionName = "1.6.1"
|
||||
versionCode = 13
|
||||
versionName = "1.8.0"
|
||||
|
||||
// Update-Quelle: eigener Gitea-Server (kein GitHub/Google Play).
|
||||
buildConfigField("String", "UPDATE_SERVER", "\"https://git.fojadrachi.de\"")
|
||||
|
||||
@@ -20,14 +20,20 @@ object DiagReport {
|
||||
private val EMAIL = Regex("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}")
|
||||
private val URL_QUERY = Regex("(?i)(https?://[^\\s?#\"']+)[?#][^\\s\"']*")
|
||||
private val WORD = Regex("[A-Za-z0-9_-]+")
|
||||
private val JSON_PRIVATE = Regex("(?i)(\"(?:title|artist|author|album|name|query|q|search)\"\\s*:\\s*)\"(?:[^\"\\\\]|\\\\.)*\"")
|
||||
private val CAMEL = Regex("^([A-Z][a-z]+)+$")
|
||||
private val CONTROL = Regex("[\\u0000-\\u0008\\u000b-\\u001f\\u007f\\u202a-\\u202e\\u2066-\\u2069]")
|
||||
|
||||
/** YouTube-Video-ID: 11 Zeichen, Gross- und Kleinbuchstaben gemischt plus Ziffer, `_` oder `-`. */
|
||||
fun looksLikeVideoId(word: String): Boolean =
|
||||
word.length == 11 &&
|
||||
word.all { it.isLetterOrDigit() && it.code < 128 || it == '_' || it == '-' } &&
|
||||
word.any { it in 'A'..'Z' } && word.any { it in 'a'..'z' } &&
|
||||
word.any { it.isDigit() || it == '_' || it == '-' }
|
||||
/**
|
||||
* YouTube-Video-ID: 11 Zeichen aus `[A-Za-z0-9_-]`, entweder Buchstaben plus Ziffer/`_`/`-` oder
|
||||
* mindestens zwei Grossbuchstaben ohne normale Schreibweise (nicht "Verbindunge", "ServerError").
|
||||
*/
|
||||
fun looksLikeVideoId(word: String): Boolean {
|
||||
if (word.length != 11 || !word.all { it in 'A'..'Z' || it in 'a'..'z' || it in '0'..'9' || it == '_' || it == '-' }) return false
|
||||
val letters = word.any { it.isLetter() }
|
||||
if (word.any { it.isDigit() || it == '_' || it == '-' }) return letters
|
||||
return word.count { it in 'A'..'Z' } >= 2 && word.any { it in 'a'..'z' } && !CAMEL.matches(word)
|
||||
}
|
||||
|
||||
private fun looksLikeSecret(word: String): Boolean =
|
||||
word.length >= 20 && word.any { it.isDigit() } && word.any { it.isLetter() }
|
||||
@@ -39,6 +45,7 @@ object DiagReport {
|
||||
text = SECRET.replace(text) { "${it.groupValues[1]}${it.groupValues[2]}[entfernt]" }
|
||||
text = EMAIL.replace(text, "[e-mail]")
|
||||
text = URL_QUERY.replace(text) { "${it.groupValues[1]}?[…]" }
|
||||
text = JSON_PRIVATE.replace(text) { "${it.groupValues[1]}\"[entfernt]\"" }
|
||||
text = WORD.replace(text) {
|
||||
when {
|
||||
looksLikeVideoId(it.value) -> "[video]"
|
||||
|
||||
@@ -83,6 +83,11 @@ class JamActivity : AppCompatActivity() {
|
||||
codeInput.setOnEditorActionListener { _, _, _ -> joinJam(codeInput.text.toString()); true }
|
||||
leave.setOnClickListener { JamHub.leave() }
|
||||
findViewById<View>(R.id.jamPlayPause).setOnClickListener { JamHub.playPause() }
|
||||
findViewById<View>(R.id.jamNowLike).setOnClickListener {
|
||||
if (JamHub.state?.current == null) return@setOnClickListener
|
||||
// Herz zaehlt fuer den laufenden Song, der in der WebView spielt - mit deinem Login.
|
||||
PlaybackHub.send(PlayerCommand.Like)
|
||||
}
|
||||
findViewById<View>(R.id.jamNext).setOnClickListener { JamHub.send("skip") }
|
||||
findViewById<View>(R.id.jamPrevious).setOnClickListener { JamHub.send("previous") }
|
||||
addButton.setOnClickListener { add() }
|
||||
@@ -253,6 +258,9 @@ class JamActivity : AppCompatActivity() {
|
||||
val state = JamHub.state ?: return
|
||||
|
||||
val item = state.current
|
||||
val like = findViewById<ImageButton>(R.id.jamNowLike)
|
||||
like.visibility = if (item != null) View.VISIBLE else View.GONE
|
||||
like.setImageResource(if (PlaybackHub.nowPlaying.likeStatus == "like") R.drawable.ic_like else R.drawable.ic_favorite_border)
|
||||
findViewById<TextView>(R.id.jamNowTitle).text = item?.title ?: getString(R.string.jam_nothing)
|
||||
findViewById<TextView>(R.id.jamNowArtist).text = item?.let { subtitle(it) } ?: ""
|
||||
val cover = findViewById<ImageView>(R.id.jamCover)
|
||||
@@ -309,7 +317,18 @@ class JamActivity : AppCompatActivity() {
|
||||
Unit
|
||||
}
|
||||
} else null
|
||||
members.addView(row(name, info, image = null, initial = m.name.take(1).uppercase(), action1 = null, action2 = kick).apply {
|
||||
// Host-Rolle abgeben (nur an jemanden, der gerade verbunden ist).
|
||||
val makeHost = if (state.isHost && m.id != state.you && m.online) {
|
||||
R.drawable.ic_crown to {
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage(getString(R.string.jam_make_host_confirm, m.name))
|
||||
.setPositiveButton(R.string.jam_make_host) { _, _ -> JamHub.send("transfer", "memberId" to m.id) }
|
||||
.setNegativeButton(R.string.pc_cancel, null)
|
||||
.show()
|
||||
Unit
|
||||
}
|
||||
} else null
|
||||
members.addView(row(name, info, image = null, initial = m.name.take(1).uppercase(), action1 = makeHost, action2 = kick).apply {
|
||||
alpha = if (m.online) 1f else 0.5f
|
||||
})
|
||||
}
|
||||
@@ -344,6 +363,10 @@ class JamActivity : AppCompatActivity() {
|
||||
findViewById<TextView>(R.id.jamTime).text = JamSync.formatTime(pos)
|
||||
findViewById<TextView>(R.id.jamDuration).text = JamSync.formatTime(dur)
|
||||
if (!seeking) seek.progress = if (dur > 0) (pos / dur * 1000).toInt() else 0
|
||||
val like = findViewById<ImageButton>(R.id.jamNowLike)
|
||||
if (like.visibility == View.VISIBLE) {
|
||||
like.setImageResource(if (PlaybackHub.nowPlaying.likeStatus == "like") R.drawable.ic_like else R.drawable.ic_favorite_border)
|
||||
}
|
||||
}
|
||||
|
||||
private fun subtitle(item: JamSync.Item): String {
|
||||
|
||||
@@ -276,6 +276,7 @@ object JamHub {
|
||||
"not_allowed" -> str(R.string.jam_error_not_allowed)
|
||||
"queue_full" -> str(R.string.jam_error_queue_full)
|
||||
"bad_video" -> str(R.string.jam_error_bad_video)
|
||||
"offline" -> str(R.string.jam_error_offline)
|
||||
"playlist_not_found" -> str(R.string.jam_error_playlist)
|
||||
"rate_limited" -> str(R.string.jam_error_rate_limited)
|
||||
else -> str(R.string.jam_error_other, error)
|
||||
@@ -362,6 +363,8 @@ object JamHub {
|
||||
*/
|
||||
fun intercept(command: PlayerCommand): Boolean {
|
||||
val s = state ?: return false
|
||||
// Like gilt fuer den laufenden Song in der WebView (eigener Login) - nicht in den Jam umleiten.
|
||||
if (command == PlayerCommand.Like) return false
|
||||
if (!s.canControl) return true
|
||||
when (command) {
|
||||
PlayerCommand.PlayPause -> playPause()
|
||||
@@ -369,6 +372,7 @@ object JamHub {
|
||||
PlayerCommand.Pause -> send("pause")
|
||||
PlayerCommand.Next -> send("skip")
|
||||
PlayerCommand.Previous -> send("previous")
|
||||
PlayerCommand.Like -> return false
|
||||
is PlayerCommand.SeekTo -> send("seek", "pos" to command.positionMs / 1000.0)
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -62,13 +62,23 @@ object MediaScripts {
|
||||
var sliderOk = isFinite(now) && isFinite(max) && max > 0;
|
||||
var current = sliderOk ? now : (video ? video.currentTime : 0);
|
||||
var duration = sliderOk ? max : ((video && isFinite(video.duration)) ? video.duration : 0);
|
||||
var likeStatus = null;
|
||||
try {
|
||||
var renderer = document.querySelector('ytmusic-player-bar ytmusic-like-button-renderer');
|
||||
likeStatus = renderer ? (renderer.getAttribute('like-status') || '').toLowerCase() : null;
|
||||
if (!likeStatus) {
|
||||
var pressed = document.querySelector('like-button-view-model button[aria-pressed=true], #segmented-like-button button[aria-pressed=true]');
|
||||
if (pressed) likeStatus = 'like';
|
||||
}
|
||||
} catch (e) { likeStatus = null; }
|
||||
return JSON.stringify({
|
||||
title: title || '',
|
||||
artist: artist || '',
|
||||
artwork: artwork,
|
||||
playing: !!video && !video.paused && !video.ended && video.readyState > 2,
|
||||
currentTime: current || 0,
|
||||
duration: duration || 0
|
||||
duration: duration || 0,
|
||||
likeStatus: likeStatus
|
||||
});
|
||||
})();
|
||||
"""
|
||||
@@ -85,6 +95,8 @@ object MediaScripts {
|
||||
action("nexttrack", "['ytmusic-player-bar .next-button','.next-button']")
|
||||
PlayerCommand.Previous ->
|
||||
action("previoustrack", "['ytmusic-player-bar .previous-button','.previous-button']")
|
||||
PlayerCommand.Like ->
|
||||
action("like", "['ytmusic-player-bar ytmusic-like-button-renderer #button-shape-like button','like-button-view-model button','#segmented-like-button button']")
|
||||
is PlayerCommand.SeekTo -> {
|
||||
val seconds = command.positionMs / 1000.0
|
||||
"(function(){var v=document.querySelector('video');if(v){v.currentTime=$seconds;}})();"
|
||||
|
||||
@@ -11,11 +11,12 @@ data class NowPlaying(
|
||||
val playing: Boolean,
|
||||
val positionMs: Long,
|
||||
val durationMs: Long,
|
||||
val likeStatus: String? = null,
|
||||
) {
|
||||
val hasTrack: Boolean get() = title.isNotBlank()
|
||||
|
||||
companion object {
|
||||
val EMPTY = NowPlaying("", "", null, playing = false, positionMs = 0L, durationMs = 0L)
|
||||
val EMPTY = NowPlaying("", "", null, playing = false, positionMs = 0L, durationMs = 0L, likeStatus = null)
|
||||
|
||||
private const val ARTIST_SEPARATOR = " • "
|
||||
|
||||
@@ -34,6 +35,7 @@ data class NowPlaying(
|
||||
playing = json.optBoolean("playing", false),
|
||||
positionMs = seconds(json.optDouble("currentTime", 0.0)),
|
||||
durationMs = seconds(json.optDouble("duration", 0.0)),
|
||||
likeStatus = json.optString("likeStatus").takeIf { it.isNotBlank() && it != "null" },
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ sealed class PlayerCommand {
|
||||
data object Pause : PlayerCommand()
|
||||
data object Next : PlayerCommand()
|
||||
data object Previous : PlayerCommand()
|
||||
data object Like : PlayerCommand()
|
||||
data class SeekTo(val positionMs: Long) : PlayerCommand()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Krone: "Zum Host machen" in der Teilnehmerliste des Jams -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFAAAAAA"
|
||||
android:pathData="M5,16L3,5l5.5,5L12,4l3.5,6L21,5l-2,11H5zM19,19c0,0.6 -0.4,1 -1,1H6c-0.6,0 -1,-0.4 -1,-1v-1h14v1z" />
|
||||
</vector>
|
||||
@@ -207,6 +207,15 @@
|
||||
android:textColor="@color/text_muted"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/jamNowLike"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/jam_like"
|
||||
android:src="@drawable/ic_favorite_border"
|
||||
android:tint="@color/brand_to" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
@@ -383,6 +392,7 @@
|
||||
<TextView
|
||||
android:id="@+id/jamInviteCode"
|
||||
android:layout_width="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:letterSpacing="0.1"
|
||||
@@ -393,6 +403,7 @@
|
||||
<TextView
|
||||
android:id="@+id/jamInviteLink"
|
||||
android:layout_width="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/text_muted"
|
||||
android:textIsSelectable="true"
|
||||
|
||||
@@ -96,6 +96,10 @@
|
||||
<string name="jam_client_web">Browser</string>
|
||||
<string name="jam_kick">Entfernen</string>
|
||||
<string name="jam_kick_confirm">%1$s aus dem Jam entfernen?</string>
|
||||
<string name="jam_make_host">Zum Host machen</string>
|
||||
<string name="jam_like">Zu Lieblingssongs</string>
|
||||
<string name="jam_make_host_confirm">%1$s zum Host machen? Du gibst damit die Host-Rechte ab.</string>
|
||||
<string name="jam_error_offline">Diese Person ist gerade nicht verbunden.</string>
|
||||
<string name="jam_play_now">Jetzt spielen</string>
|
||||
<string name="jam_remove">Entfernen</string>
|
||||
<string name="jam_added">Hinzugefügt: %1$s</string>
|
||||
|
||||
@@ -23,6 +23,16 @@ class DiagReportTest {
|
||||
assertEquals("a b", DiagReport.sanitize("a\u0000b"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removesIdsWithoutDigitsAndJsonTitles() {
|
||||
assertEquals("jam: lade [video]", DiagReport.sanitize("jam: lade JZYXtUJcTws"))
|
||||
assertEquals(
|
||||
"Player: {\"artist\":\"[entfernt]\",\"id\":\"[video]\",\"title\":\"[entfernt]\",\"paused\":true}",
|
||||
DiagReport.sanitize("Player: {\"artist\":\"Band\",\"id\":\"Rlg9P5i1bkQ\",\"title\":\"Mein Song\",\"paused\":true}"),
|
||||
)
|
||||
assertEquals("Verbindunge ServerError PlaytubeApp", DiagReport.sanitize("Verbindunge ServerError PlaytubeApp"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun recognizesVideoIds() {
|
||||
assertTrue(DiagReport.looksLikeVideoId("dQw4w9WgXcQ"))
|
||||
|
||||
@@ -1,27 +1,15 @@
|
||||
## Playtube für Android 1.6.1
|
||||
## Playtube für Android 1.8.0
|
||||
|
||||
- **„Jetzt senden“ schickt immer einen Bericht:** Bisher passierte nach einer frischen Installation nichts
|
||||
(„Keine neuen Einträge“). Jetzt geht auch ohne neue Einträge ein kurzer Bericht mit App-Version, Gerät
|
||||
und dem Vermerk „manuell gesendet“ raus – so lässt sich prüfen, ob der Versand klappt.
|
||||
- **Jam genauer synchron:** Kleine Abweichungen werden unhörbar über ein leicht angepasstes Tempo ausgeglichen
|
||||
(die Tonhöhe bleibt gleich); gesprungen wird erst ab 1 Sekunde Abweichung und mit Vorhalt.
|
||||
- **Jam-Song zu deinen Lieblingssongs:** In der Jam-Ansicht hat der laufende Song jetzt ein Herz. Ein Klick legt
|
||||
ihn in deine eigenen YouTube-Music-Lieblingssongs (oder nimmt ihn wieder heraus) – mit deinem Login.
|
||||
|
||||
Neu in 1.6.0: Diagnosedaten (Abstürze und Verbindungsfehler, ohne Cookies, Anmeldedaten, Suchanfragen oder
|
||||
Songtitel), abschaltbar über das Zahnrad am rechten Rand. Details: playtube-ppp-eula.pages.dev/playtube/privacy/#diag
|
||||
|
||||
Voraussetzung: Android 8.0 oder neuer.
|
||||
Alles Weitere wie in 1.7.0. Voraussetzung: Android 8.0 oder neuer.
|
||||
|
||||
---
|
||||
|
||||
## Playtube for Android 1.6.1
|
||||
## Playtube for Android 1.8.0
|
||||
|
||||
- **"Send now" always sends a report:** after a fresh install nothing happened ("No new entries"). Now a short
|
||||
report with app version, device and the note "sent manually" goes out even without new entries – so you can
|
||||
check that sending works.
|
||||
- **Jam stays more closely in sync:** small offsets are corrected inaudibly by slightly adjusting the playback
|
||||
speed (pitch stays the same); it only seeks once the offset reaches 1 second, with a lead time.
|
||||
- **Jam song to your liked songs:** in the jam view the current song now has a heart. One tap adds it to your own
|
||||
YouTube Music liked songs (or removes it) – with your login.
|
||||
|
||||
New in 1.6.0: diagnostic data (crashes and connection errors, no cookies, sign-in data, searches or song titles),
|
||||
can be turned off via the gear button on the right edge. Details: playtube-ppp-eula.pages.dev/playtube/privacy/#diag
|
||||
|
||||
Requires Android 8.0 or newer.
|
||||
Everything else as in 1.7.0. Requires Android 8.0 or newer.
|
||||
|
||||
Reference in New Issue
Block a user