mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-19 17:13:59 +00:00
fix(YouTube Music - Spoof video streams): Fix playback issues when using a cellular network
Code adapted from 5f35e51a27
This commit is contained in:
@@ -22,10 +22,19 @@ public class SpoofVideoStreamsPatch {
|
|||||||
&& BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ClientType.IOS_UNPLUGGED;
|
&& BaseSettings.SPOOF_VIDEO_STREAMS_CLIENT_TYPE.get() == ClientType.IOS_UNPLUGGED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any unreachable ip address. Used to intentionally fail requests.
|
* Domain used for internet connectivity verification.
|
||||||
|
* It has an empty response body and is only used to check for a 204 response code.
|
||||||
|
* <p>
|
||||||
|
* If an unreachable IP address (127.0.0.1) is used, no response code is provided.
|
||||||
|
* <p>
|
||||||
|
* YouTube handles unreachable IP addresses without issue.
|
||||||
|
* YouTube Music has an issue with waiting for the Cronet connect timeout of 30s on mobile networks.
|
||||||
|
* <p>
|
||||||
|
* Using a VPN or DNS can temporarily resolve this issue,
|
||||||
|
* But the ideal workaround is to avoid using an unreachable IP address.
|
||||||
*/
|
*/
|
||||||
private static final String UNREACHABLE_HOST_URI_STRING = "https://127.0.0.0";
|
private static final String INTERNET_CONNECTION_CHECK_URI_STRING = "https://www.google.com/gen_204";
|
||||||
private static final Uri UNREACHABLE_HOST_URI = Uri.parse(UNREACHABLE_HOST_URI_STRING);
|
private static final Uri INTERNET_CONNECTION_CHECK_URI = Uri.parse(INTERNET_CONNECTION_CHECK_URI_STRING);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If this patch was included during patching.
|
* @return If this patch was included during patching.
|
||||||
@@ -53,9 +62,9 @@ public class SpoofVideoStreamsPatch {
|
|||||||
String path = playerRequestUri.getPath();
|
String path = playerRequestUri.getPath();
|
||||||
|
|
||||||
if (path != null && path.contains("get_watch")) {
|
if (path != null && path.contains("get_watch")) {
|
||||||
Logger.printDebug(() -> "Blocking 'get_watch' by returning unreachable uri");
|
Logger.printDebug(() -> "Blocking 'get_watch' by returning internet connection check uri");
|
||||||
|
|
||||||
return UNREACHABLE_HOST_URI;
|
return INTERNET_CONNECTION_CHECK_URI;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.printException(() -> "blockGetWatchRequest failure", ex);
|
Logger.printException(() -> "blockGetWatchRequest failure", ex);
|
||||||
@@ -77,9 +86,9 @@ public class SpoofVideoStreamsPatch {
|
|||||||
String path = originalUri.getPath();
|
String path = originalUri.getPath();
|
||||||
|
|
||||||
if (path != null && path.contains("initplayback")) {
|
if (path != null && path.contains("initplayback")) {
|
||||||
Logger.printDebug(() -> "Blocking 'initplayback' by clearing query");
|
Logger.printDebug(() -> "Blocking 'initplayback' by returning internet connection check uri");
|
||||||
|
|
||||||
return originalUri.buildUpon().clearQuery().build().toString();
|
return INTERNET_CONNECTION_CHECK_URI_STRING;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.printException(() -> "blockInitPlaybackRequest failure", ex);
|
Logger.printException(() -> "blockInitPlaybackRequest failure", ex);
|
||||||
|
|||||||
Reference in New Issue
Block a user