fix(YouTube - Change live ring click action): Check more information for the guarantee of the more accurate operation of the patch

This commit is contained in:
inotia00 2025-02-07 14:37:02 +09:00
parent 3e280c9311
commit f678991e61
87 changed files with 408 additions and 16 deletions

View File

@ -49,7 +49,9 @@ object PlayerRoutes {
Route.Method.POST,
"player" +
"?prettyPrint=false" +
"&fields=videoDetails.channelId"
"&fields=videoDetails.channelId," +
"videoDetails.isLiveContent," +
"videoDetails.isUpcoming"
).compile()
private const val YT_API_URL = "https://youtubei.googleapis.com/youtubei/v1/"

View File

@ -1,5 +1,7 @@
package app.revanced.extension.youtube.patches.general;
import static app.revanced.extension.shared.utils.StringRef.str;
import android.widget.ImageView;
import androidx.annotation.NonNull;
@ -18,6 +20,12 @@ public final class OpenChannelOfLiveAvatarPatch {
private static final boolean CHANGE_LIVE_RING_CLICK_ACTION =
Settings.CHANGE_LIVE_RING_CLICK_ACTION.get();
/**
* If you change the language in the app settings, a string from another language may be used.
* In this case, restarting the app will solve it.
*/
private static final String liveRingDescription = str("revanced_live_ring_description");
private static volatile String videoId = "";
/**
@ -56,6 +64,16 @@ public final class OpenChannelOfLiveAvatarPatch {
if (!(playbackStartDescriptorMap.get(ELEMENTS_SENDER_VIEW) instanceof ComponentHost componentHost)) {
return;
}
// Check content description (accessibility labels) of the live ring.
final String contentDescription = componentHost.getContentDescription().toString();
final boolean match = liveRingDescription.equals(contentDescription);
Logger.printDebug(() -> "resource description: '" + liveRingDescription + "', litho description: '" + contentDescription + "', match: " + match);
if (!match) {
// Sometimes it may not match:
// 1. In some languages, accessibility label is not provided.
// 2. Language has changed in the app settings, and the app has not restarted.
// In this case, fallback with the legacy method.
// Child count of other litho Views such as Thumbnail and Watch history: 2
// Child count of live ring: 1
if (componentHost.getChildCount() != 1) {
@ -69,6 +87,7 @@ public final class OpenChannelOfLiveAvatarPatch {
if (!(liveRingViewGroup.getChildAt(0) instanceof ImageView)) {
return;
}
}
// Fetch channel id
videoId = newlyLoadedVideoId;
VideoDetailsRequest.fetchRequestIfNeeded(newlyLoadedVideoId);

View File

@ -119,9 +119,22 @@ class VideoDetailsRequest private constructor(
private fun parseResponse(videoDetailsJson: JSONObject): String? {
try {
return videoDetailsJson
.getJSONObject("videoDetails")
.getString("channelId")
val videoDetailsJson = videoDetailsJson.getJSONObject("videoDetails")
// Live streams always open when live ring is clicked.
// Make sure this video is live streams.
val isLiveContent = videoDetailsJson.has("isLiveContent") &&
videoDetailsJson.getBoolean("isLiveContent")
// Even if 'isLiveContent' is true, it may be 'UPCOMING' video.
// Check if the value of 'isUpcoming' is true.
val isUpcoming = videoDetailsJson.has("isUpcoming") &&
videoDetailsJson.getBoolean("isUpcoming")
// Return the channel id only if the video is live streams and not 'UPCOMING' video.
if (isLiveContent && !isUpcoming) {
return videoDetailsJson.getString("channelId")
}
} catch (e: JSONException) {
Logger.printException(
{ "Fetch failed while processing response data for response: $videoDetailsJson" },

View File

@ -4,6 +4,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.resourcePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.extension.Constants.GENERAL_PATH
@ -17,6 +18,7 @@ import app.revanced.patches.youtube.video.playbackstart.playbackStartDescriptorP
import app.revanced.patches.youtube.video.playbackstart.playbackStartVideoIdReference
import app.revanced.patches.youtube.video.playbackstart.shortsPlaybackStartIntentFingerprint
import app.revanced.patches.youtube.video.playbackstart.shortsPlaybackStartIntentLegacyFingerprint
import app.revanced.util.copyXmlNode
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
@ -29,6 +31,29 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
private val openChannelOfLiveAvatarResourcePatch = resourcePatch(
description = "openChannelOfLiveAvatarResourcePatch"
) {
execute {
arrayOf(
"", "af", "am", "ar", "as", "az", "b+sr+Latn", "be", "bg", "bn", "bs", "ca",
"cs", "da", "de", "el", "en-rGB", "en-rIN", "es", "es-rUS", "et", "eu", "fa",
"fi", "fr", "fr-rCA", "gl", "gu", "hi", "hr", "hu", "hy", "in", "is", "it",
"iw", "ja", "ka", "kk", "km", "kn", "ko", "ky", "lo", "lt", "lv", "mk", "ml",
"mn", "mr", "ms", "my", "nb", "ne", "nl", "or", "pa", "pl", "pt", "pt-rBR",
"pt-rPT", "ro", "ru", "si", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te",
"th", "tl", "tr", "uk", "ur", "uz", "vi", "zh-rCN", "zh-rHK", "zh-rTW", "zu"
).forEach { locale ->
val directory = if (locale.isEmpty())
"values"
else
"values-$locale"
copyXmlNode("youtube/livering/host", "$directory/strings.xml", "resources")
}
}
}
private const val EXTENSION_CLASS_DESCRIPTOR =
"$GENERAL_PATH/OpenChannelOfLiveAvatarPatch;"
@ -41,6 +66,7 @@ val openChannelOfLiveAvatarPatch = bytecodePatch(
dependsOn(
settingsPatch,
openChannelOfLiveAvatarResourcePatch,
playbackStartDescriptorPatch,
versionCheckPatch,
)

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Tap to watch live</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">በቀጥታ ስርጭት ለመመልከት መታ ያድርጉ</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">انقر لمشاهدة البث المباشر.</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">লাইভ চাবলৈ টিপক</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Canlı baxmaq üçün toxunun</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Dodirnite da biste gledali uživo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Націсніце, каб глядзець жывую трансляцыю</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Докоснете, за да гледате на живо</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">লাইভ দেখতে ট্যাপ করুন</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Dodirnite da gledate uživo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">"Toca per veure l'emissió en directe"</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Klepnutím spustíte živý přenos</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Tryk for at se live</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Zum live Ansehen tippen</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Πατήστε για να παρακολουθήσετε ζωντανά</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Tap to watch live</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Tap to watch live</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Presiona para ver la transmisión en vivo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Toca para ver en directo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Puudutage, et otse vaadata</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Sakatu hau bideoa zuzenean ikusteko</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">برای تماشای زنده تک‌ضرب بزنید</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Napauta katsoaksesi livenä</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Touchez pour regarder en direct</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Appuyer pour regarder en direct</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Toca para velo en directo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">લાઇવ જોવા માટે ટૅપ કરો</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">लाइव वीडियो देखने के लिए टैप करें</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Dodirnite za gledanje uživo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Koppints és nézd élőben</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">"Հպեք՝ ուղիղ եթերը դիտելու համար"</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Ketuk untuk menonton live</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Ýttu til að horfa í beinni</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Tocca per guardare dal vivo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">אפשר ללחוץ כדי לצפות בשידור החי</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">タップしてライブを視聴</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">შეეხეთ პირდაპირ ეთერში საყურებლად</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Тікелей эфирді көру үшін түртіңіз</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">ចុចដើម្បីមើលការផ្សាយផ្ទាល់</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">ಲೈವ್ ನೋಡಲು ಟ್ಯಾಪ್ ಮಾಡಿ</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">탭하여 실시간으로 시청하기</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Түз ободо көрүү үчүн таптап коюңуз</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">ແຕະເພື່ອເບິ່ງການຖ່າຍທອດສົດ</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Palieskite ir žiūrėkite tiesiogiai</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Pieskarieties, lai skatītos tiešraidi</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Допрете за да гледате во живо</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">തത്സമയം കാണാൻ ടാപ്പ് ചെയ്യുക</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Шууд үзэхийн тулд товшино уу</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">लाइव्ह पाहण्यासाठी टॅप करा</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Ketik untuk menonton secara langsung</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">တိုက်ရိုက်ကြည့်ရန် တို့ပါ</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Trykk for å se direktesendingen</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">लाइभ हेर्न ट्याप गर्नुहोस्</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Tik om live te kijken</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">ଲାଇଭ ଦେଖିବାକୁ ଟାପ କରନ୍ତୁ</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">ਲਾਈਵ ਦੇਖਣ ਲਈ ਟੈਪ ਕਰੋ</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Dotknij, aby obejrzeć na żywo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Toque para assistir a transmissão ao vivo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Toque para ver em direto</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Toque para assistir a transmissão ao vivo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Atinge pentru a viziona live</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Нажмите, чтобы посмотреть трансляцию</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">සජීවීව නැරඹීමට තට්ටු කරන්න</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Klepnutím spustíte prehrávanie priameho prenosu</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Dotaknite se za ogled v živo</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Trokit për të parë drejtpërdrejt</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Додирните да бисте гледали уживо</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Tryck för att titta live</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Gusa ili utazame moja kwa moja</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">நேரலையில் பார்க்க, தட்டவும்</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">లైవ్‌ను చూడటానికి ట్యాప్ చేయండి</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">แตะเพื่อดูถ่ายทอดสด</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">I-tap para live na mapanood</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Canlı izlemek için dokunun</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Натисніть, щоб дивитися прямий ефір</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">لائیو دیکھنے کیلئے تھپتھپائیں</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Jonli tomosha uchun bosing</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Nhấn để xem sự kiện trực tiếp</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">点按即可观看直播</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">輕按即可收看直播</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">輕觸即可觀看直播影片</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Thepha ukuze ubuke bukhoma</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="revanced_live_ring_description">Tap to watch live</string>
</resources>