use youtube direct

This commit is contained in:
Roy Olav Purser 2021-12-27 18:36:48 +01:00
parent dcf3c44ea3
commit d3f965164d
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -11,9 +11,11 @@ public class ShareActivity extends Activity {
private class Upstream { private class Upstream {
private Uri uri = null; private Uri uri = null;
private String provider = null; private String provider = null;
private Upstream(Uri uri, String provider) { private String direct = null;
private Upstream(Uri uri, String provider, boolean direct) {
this.uri = uri; this.uri = uri;
this.provider = provider; this.provider = provider;
this.direct = direct ? "true" : "false";
} }
} }
private Upstream getSharedLink() { private Upstream getSharedLink() {
@ -32,6 +34,7 @@ public class ShareActivity extends Activity {
Uri uri = Uri.parse(txt); Uri uri = Uri.parse(txt);
String host = uri.getHost().toLowerCase(Locale.ROOT); String host = uri.getHost().toLowerCase(Locale.ROOT);
if(domains.containsKey(host)) { if(domains.containsKey(host)) {
boolean direct = host.contains("youtu.be");
if(host.contains("youtube.com")) { if(host.contains("youtube.com")) {
Uri.Builder builder = new Uri.Builder(); Uri.Builder builder = new Uri.Builder();
builder.authority(host); builder.authority(host);
@ -39,10 +42,10 @@ public class ShareActivity extends Activity {
String path = uri.getQueryParameter("v"); String path = uri.getQueryParameter("v");
if(path != null) { if(path != null) {
builder.path(path); builder.path(path);
return new Upstream(builder.build(), domains.get(host)); return new Upstream(builder.build(), domains.get(host), true);
} }
} }
return new Upstream(uri, domains.get(host)); return new Upstream(uri, domains.get(host), direct);
} }
} catch(Exception e) {} } catch(Exception e) {}
} }
@ -58,6 +61,7 @@ public class ShareActivity extends Activity {
builder.scheme("https"); builder.scheme("https");
builder.path(upstream.uri.getPath()); builder.path(upstream.uri.getPath());
builder.appendQueryParameter("provider", upstream.provider); builder.appendQueryParameter("provider", upstream.provider);
builder.appendQueryParameter("direct", upstream.direct);
Intent launch = new Intent(Intent.ACTION_VIEW, builder.build()); Intent launch = new Intent(Intent.ACTION_VIEW, builder.build());
launch.setPackage("com.android.chrome"); launch.setPackage("com.android.chrome");
launch.putExtra("android.support.customtabs.extra.SESSION", "Proxy Stream"); launch.putExtra("android.support.customtabs.extra.SESSION", "Proxy Stream");