From 5f0ca05eebd78d0e17e27105fb044be9a1bc7d69 Mon Sep 17 00:00:00 2001 From: Francesco Bonazzi Date: Sun, 22 Mar 2020 17:57:49 +0100 Subject: [PATCH] Added support for Prime Videos shared from the official Amazon app --- .../ui/sections/remote/RemoteActivity.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteActivity.java b/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteActivity.java index dfe4333..b4d02b1 100644 --- a/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteActivity.java +++ b/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteActivity.java @@ -390,6 +390,21 @@ public class RemoteActivity extends BaseActivity videoUri = intent.getData(); } + if (videoUri == null) { + // Some apps hide the link in the clip, try to detect any link by casting the intent + // to string a looking with a regular expression: + + Matcher matcher = Pattern.compile("https?://[^\\s]+").matcher(intent.toString()); + String matchedString = null; + if (matcher.find()) { + matchedString = matcher.group(0); + if (matchedString.endsWith("}")) { + matchedString = matchedString.substring(0, matchedString.length() - 1); + } + videoUri = Uri.parse(matchedString); + } + } + String url; if (videoUri == null) { url = getShareLocalUri(intent); @@ -598,6 +613,12 @@ public class RemoteActivity extends BaseActivity } else if (host.endsWith("soundcloud.com")) { return "plugin://plugin.audio.soundcloud/play/?url=" + URLEncoder.encode(playuri.toString()); + } else if (host.startsWith("app.primevideo.com")) { + Matcher amazonMatcher = Pattern.compile("gti=([^&]+)").matcher(playuri.toString()); + if (amazonMatcher.find()) { + String gti = amazonMatcher.group(1); + return "plugin://plugin.video.amazon-test/?asin=" + gti + "&mode=PlayVideo&adult=0&name=&trailer=0&selbitrate=0"; + } } return null; }