Add support for sharing SVTplay urls to "Play on Kodi". (#343)

* Add support for sharing SVTplay urls to "Play on Kodi".
SVTplay is a free streaming service provided by the Swedish national television SVT.
This feature requires the svtplay video plugin on Kodi.
* Fix SVTplay share always playing first episode of series.
This commit is contained in:
Joel Hedlund 2017-01-30 20:06:14 +01:00 committed by Synced Synapse
parent d5f8ee4d49
commit 7a2ed7704a
1 changed files with 13 additions and 5 deletions

View File

@ -65,6 +65,7 @@ import org.xbmc.kore.utils.UIUtils;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -369,9 +370,13 @@ public class RemoteActivity extends BaseActivity
final String videoId = getVideoId(videoUri);
String videoUrl;
if (videoId != null) {
videoUrl = "plugin://plugin.video." +
(videoUri.getHost().endsWith("vimeo.com") ? "vimeo" : "youtube") +
"/play/?video_id=" + videoId;
if (videoUri.getHost().endsWith("svtplay.se")) {
videoUrl = "plugin://plugin.video.svtplay/?url=%2Fvideo%2F" + URLEncoder.encode(videoId) + "&mode=video";
} else if (videoUri.getHost().endsWith("vimeo.com")) {
videoUrl = "plugin://plugin.video.vimeo?video_id=" + videoId;
} else {
videoUrl = "plugin://plugin.video.youtube/play/?video_id=" + videoId;
}
} else {
videoUrl = videoUri.toString();
@ -517,10 +522,13 @@ public class RemoteActivity extends BaseActivity
* @return Youtube/Vimeo Video ID
*/
private String getVideoId(Uri playuri) {
if (playuri.getHost().endsWith("youtube.com") || playuri.getHost().endsWith("youtu.be") || playuri.getHost().endsWith("vimeo.com")) {
if (playuri.getHost().endsWith("svtplay.se") || playuri.getHost().endsWith("youtube.com") || playuri.getHost().endsWith("youtu.be") || playuri.getHost().endsWith("vimeo.com")) {
// We'll need to get the v= parameter from the URL
final Pattern pattern;
if (playuri.getHost().endsWith("vimeo.com")) {
if (playuri.getHost().endsWith("svtplay.se")) {
pattern = Pattern.compile("^(?:https?:\\/\\/)?(?:www\\.)?svtplay\\.se\\/video\\/(\\d+\\/.*)",
Pattern.CASE_INSENSITIVE);
} else if (playuri.getHost().endsWith("vimeo.com")) {
pattern = Pattern.compile("^(?:https?:\\/\\/)?(?:www\\.|player\\.)?vimeo\\.com\\/(?:.*\\/)?(\\d+)(?:\\?.*)?$",
Pattern.CASE_INSENSITIVE);
}