Skip to content

Commit 140f484

Browse files
fix(YouTube - Spoof video streams): Make livestreams start at the current time when using iOS client (ReVanced#4137)
1 parent 1150bab commit 140f484

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java

+17
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
@SuppressWarnings("unused")
1717
public class SpoofVideoStreamsPatch {
1818
private static final boolean SPOOF_STREAMING_DATA = BaseSettings.SPOOF_VIDEO_STREAMS.get();
19+
20+
private static final boolean FIX_HLS_CURRENT_TIME = SPOOF_STREAMING_DATA
21+
&& BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ClientType.IOS;
22+
1923
/**
2024
* Any unreachable ip address. Used to intentionally fail requests.
2125
*/
@@ -165,6 +169,19 @@ public static byte[] removeVideoPlaybackPostBody(Uri uri, int method, byte[] pos
165169
return postData;
166170
}
167171

172+
/**
173+
* Injection point.
174+
*
175+
* Fixes iOS livestreams starting from the beginning.
176+
*/
177+
public static boolean fixHLSCurrentTime(boolean original) {
178+
if (FIX_HLS_CURRENT_TIME) {
179+
return false;
180+
}
181+
182+
return original;
183+
}
184+
168185
public static final class SpoofiOSAvailability implements Setting.Availability {
169186
@Override
170187
public boolean isAvailable() {

patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/Fingerprints.kt

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package app.revanced.patches.shared.misc.spoof
22

33
import app.revanced.patcher.fingerprint
4+
import app.revanced.util.literal
45
import com.android.tools.smali.dexlib2.AccessFlags
56
import com.android.tools.smali.dexlib2.Opcode
67

@@ -110,3 +111,13 @@ internal val buildMediaDataSourceFingerprint = fingerprint {
110111
"Ljava/lang/Object;",
111112
)
112113
}
114+
115+
internal const val HLS_CURRENT_TIME_FEATURE_FLAG = 45355374L
116+
117+
internal val hlsCurrentTimeFingerprint = fingerprint {
118+
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
119+
parameters("Z", "L")
120+
literal {
121+
HLS_CURRENT_TIME_FEATURE_FLAG
122+
}
123+
}

patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/SpoofVideoStreamsPatch.kt

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMu
1212
import app.revanced.patches.all.misc.resources.addResourcesPatch
1313
import app.revanced.util.getReference
1414
import app.revanced.util.indexOfFirstInstructionOrThrow
15+
import app.revanced.util.insertFeatureFlagBooleanOverride
1516
import com.android.tools.smali.dexlib2.AccessFlags
1617
import com.android.tools.smali.dexlib2.Opcode
1718
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
@@ -201,6 +202,15 @@ fun spoofVideoStreamsPatch(
201202
}
202203
// endregion
203204

205+
// region Fix iOS livestream current time.
206+
207+
hlsCurrentTimeFingerprint.method.insertFeatureFlagBooleanOverride(
208+
HLS_CURRENT_TIME_FEATURE_FLAG,
209+
"$EXTENSION_CLASS_DESCRIPTOR->fixHLSCurrentTime(Z)Z"
210+
)
211+
212+
// endregion
213+
204214
executeBlock()
205215
}
206216
}

patches/src/main/resources/addresources/values/strings.xml

-1
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,6 @@ Video playback may not work"</string>
12901290
AVC has a maximum resolution of 1080p, Opus audio codec is not available, and video playback will use more internet data than VP9 or AV1."</string>
12911291
<string name="revanced_spoof_video_streams_about_ios_title">iOS spoofing side effects</string>
12921292
<string name="revanced_spoof_video_streams_about_ios_summary">"• Private kids videos may not play
1293-
• Livestreams start from the beginning
12941293
• Videos end 1 second early"</string>
12951294
<string name="revanced_spoof_video_streams_about_android_vr_title">Android VR spoofing side effects</string>
12961295
<string name="revanced_spoof_video_streams_about_android_vr_summary">"• Kids videos may not play

0 commit comments

Comments
 (0)