Merge pull request #181 from tomerf/vimeo

Improved URLs parsing and added error message
This commit is contained in:
Synced Synapse 2016-01-25 19:23:39 +00:00
commit dc5e7f183e
3 changed files with 17 additions and 4 deletions

View File

@ -42,6 +42,7 @@
<data android:scheme="http" android:host="www.youtube.com"/>
<data android:scheme="http" android:host="vimeo.com"/>
<data android:scheme="http" android:host="www.vimeo.com"/>
<data android:scheme="http" android:host="player.vimeo.com"/>
</intent-filter>
</activity>

View File

@ -372,7 +372,12 @@ public class RemoteActivity extends BaseActivity
}
final String videoId = getVideoId(videoUri);
if (videoId == null) return;
if (videoId == null) {
Toast.makeText(RemoteActivity.this,
R.string.error_share_video,
Toast.LENGTH_SHORT).show();
return;
}
final String kodiAddonUrl = "plugin://plugin.video." +
(videoUri.getHost().endsWith("vimeo.com") ? "vimeo" : "youtube") +
@ -524,9 +529,15 @@ public class RemoteActivity extends BaseActivity
private String getVideoId(Uri playuri) {
if (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 =
Pattern.compile("(?:https?:\\/\\/)?(?:www\\.|m\\.)?(?:youtu(?:\\.be\\/|be\\.com\\/watch\\?v=)|vimeo\\.com\\/)([\\w-]+)",
Pattern.CASE_INSENSITIVE);
final Pattern pattern;
if (playuri.getHost().endsWith("vimeo.com")) {
pattern = Pattern.compile("^(?:https?:\\/\\/)?(?:www\\.|player\\.)?vimeo\\.com\\/(?:.*\\/)?(\\d+)(?:\\?.*)?$",
Pattern.CASE_INSENSITIVE);
}
else {
pattern = Pattern.compile("^(?:https?:\\/\\/)?(?:www\\.|m\\.)?youtu(?:\\.be\\/|be\\.com\\/watch\\?v=)([\\w-]+)(?:[\\?&].*)?$",
Pattern.CASE_INSENSITIVE);
}
final Matcher matcher = pattern.matcher(playuri.toString());
if (matcher.matches()) {
return matcher.group(1);

View File

@ -215,6 +215,7 @@
%1$s.</string>
<string name="error_get_active_player">Couldn\'t get active player.\nError message:
%1$s.</string>
<string name="error_share_video">Couldn\'t share video to Kodi/XBMC.</string>
<string name="directors">Directors:</string>
<string name="studio">Studio:</string>