Skip to content

Commit

Permalink
support short YouTube URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
robUx4 committed Jan 30, 2015
1 parent 3dcb98e commit 8095731
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ POM_DEVELOPER_NAME=Steve Lhomme

POM_ARTIFACT_ID=android-oembed
POM_PACKAGING=jar
VERSION_NAME=1.0.0
VERSION_CODE=10000
VERSION_NAME=1.0.1
VERSION_CODE=10001

ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_SDK_VERSION=21
Expand Down
3 changes: 3 additions & 0 deletions src/main/co/tophe/oembed/internal/OEmbedYoutube.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ private OEmbedYoutube() {

@Override
public OEmbedSource getSource(@NonNull Uri fromUri) {
if (fromUri.getHost().equals("youtu.be")) {
return new OEmbedSourceYoutube(fromUri);
}
if (fromUri.getHost().endsWith("youtube.com")) {
List<String> path = fromUri.getPathSegments();
if (path.size() > 1 && "embed".equals(path.get(0))) {
Expand Down
7 changes: 6 additions & 1 deletion src/test/src/co/tophe/oembed/sourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class sourceTest extends AndroidTestCase {

private static final String YOUTUBE1 = "http://www.youtube.com/watch?v=SqfJPKgkdgg";
private static final String YOUTUBE2 = "http://www.youtube.com/embed/SqfJPKgkdgg?rel=0&amp;autoplay=0&amp;wmode=opaque&amp;controls=2&amp;autohide=1&amp;showinfo=0";
private static final String YOUTUBE_SHORT = "http://youtu.be/bFra7SIMYt4?a";
private static final String VIMEO1 = "http://vimeo.com/7100569";
private static final String INSTAGRAM = "http://instagram.com/p/xpaLXzIwd1/";
private static final String INSTAGRAM_FULL = "http://instagram.com/p/xpaLXzIwd1/?modal=true";
Expand Down Expand Up @@ -47,7 +48,11 @@ public void testYoutube1() throws Exception {
public void testYoutube2() throws Exception {
testOEmbedThumbnail(YOUTUBE2);
}


public void testYoutubeShort() throws Exception {
testOEmbedThumbnail(YOUTUBE_SHORT);
}

public void testVimeo1() throws Exception {
testOEmbedThumbnail(VIMEO1);
}
Expand Down

0 comments on commit 8095731

Please sign in to comment.