From a9a833ddfee3c71c4d8c5737bec34511e2b1aad2 Mon Sep 17 00:00:00 2001 From: STB Land Date: Mon, 25 May 2020 20:38:50 +0200 Subject: [PATCH] Add support to sharing from Arte's video to Kodi (#736) * Add support to sharing from Arte video (The European Culture Channel) to Kodi * Handle Arte's video (The European Culture Channel) --- CHANGELOG.md | 4 ++ app/src/main/AndroidManifest.xml | 2 + .../ui/sections/remote/RemoteActivity.java | 3 ++ .../org/xbmc/kore/utils/PluginUrlUtils.java | 42 +++++++++++++++++ .../xbmc/kore/utils/PluginUrlUtilsTest.java | 47 +++++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 app/src/main/java/org/xbmc/kore/utils/PluginUrlUtils.java create mode 100644 app/src/test/java/org/xbmc/kore/utils/PluginUrlUtilsTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index a524545..b8d9613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog --------- +Version 2.5.1 +------------- +- Add support to sharing from Arte video (The European Culture Channel) to Kodi + Version 2.5.0 ------------- - Include search option in PVR section diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e2613a6..3e20c8f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -75,6 +75,7 @@ + + 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 b644ec5..d76fbf9 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 @@ -64,6 +64,7 @@ import org.xbmc.kore.utils.LogUtils; import org.xbmc.kore.utils.TabsAdapter; import org.xbmc.kore.utils.UIUtils; import org.xbmc.kore.utils.Utils; +import org.xbmc.kore.utils.PluginUrlUtils; import java.io.IOException; import java.net.MalformedURLException; @@ -623,6 +624,8 @@ public class RemoteActivity extends BaseActivity String gti = amazonMatcher.group(1); return "plugin://plugin.video.amazon-test/?asin=" + gti + "&mode=PlayVideo&adult=0&name=&trailer=0&selbitrate=0"; } + } else if (PluginUrlUtils.isHostArte(host)) { + return PluginUrlUtils.toPluginUrlArte(playuri); } return null; } diff --git a/app/src/main/java/org/xbmc/kore/utils/PluginUrlUtils.java b/app/src/main/java/org/xbmc/kore/utils/PluginUrlUtils.java new file mode 100644 index 0000000..e2db431 --- /dev/null +++ b/app/src/main/java/org/xbmc/kore/utils/PluginUrlUtils.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020 STB Land. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.xbmc.kore.utils; + +import android.net.Uri; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Misc util methods for use with plugin URL + */ +public class PluginUrlUtils { + + public static boolean isHostArte(String host) { + return host.equals("www.arte.tv"); + } + + public static String toPluginUrlArte(Uri playUri) { + Pattern pattern = Pattern.compile("^https://www.arte.tv/[a-z]{2}/videos/([0-9]{6}-[0-9]{3}-[A-Z])/.*$"); + Matcher matcher = pattern.matcher(playUri.toString()); + if (matcher.matches()) { + String kind="SHOW"; + String program_id=matcher.group(1); + return "plugin://plugin.video.arteplussept/play/" + kind + "/" + program_id; + } + return null; + } +} diff --git a/app/src/test/java/org/xbmc/kore/utils/PluginUrlUtilsTest.java b/app/src/test/java/org/xbmc/kore/utils/PluginUrlUtilsTest.java new file mode 100644 index 0000000..1064f45 --- /dev/null +++ b/app/src/test/java/org/xbmc/kore/utils/PluginUrlUtilsTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2016 Martijn Brekhof. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.xbmc.kore.utils; + +import android.net.Uri; + +import org.junit.runner.RunWith; +import org.junit.Test; +import org.robolectric.annotation.Config; + +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +@RunWith(AndroidJUnit4.class) +@Config(sdk = 28) +public class PluginUrlUtilsTest { + + @Test + public void isHostArte() throws Exception { + assertTrue(PluginUrlUtils.isHostArte("www.arte.tv")); + } + + @Test + public void toPluginUrlArte() throws Exception { + Uri playUri = Uri.parse("https://www.arte.tv/fr/videos/084692-000-A/mongolie-le-reve-d-une-jeune-nomade/"); + String pluginUrl = PluginUrlUtils.toPluginUrlArte(playUri); + assertNotNull(pluginUrl); + assertEquals("plugin://plugin.video.arteplussept/play/SHOW/084692-000-A", pluginUrl); + } +}