Created
November 14, 2014 13:59
-
-
Save matheusjardimb/db02fd7219803a8792d2 to your computer and use it in GitHub Desktop.
Get Youtube thumb url from video Id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Created by matheusjardimb on 14/11/2014. | |
*/ | |
public class YoutubeUtils { | |
private static final String BASE_URL = "http://img.youtube.com/vi/"; | |
private static final String EXT = ".jpg"; | |
public static String getThumbUrl(String videoId) { | |
return getThumbUrl(videoId, VideoSize.DEFAULT); | |
} | |
public static String getThumbUrl(String videoId, VideoSize videoSize) { | |
return BASE_URL + videoId + videoSize.toString() + EXT; | |
} | |
@SuppressWarnings("SpellCheckingInspection") | |
public enum VideoSize { | |
DEFAULT("/default"), | |
HQ("/hqdefault"), | |
MQ("/mqdefault"), | |
SD("/sddefault"), | |
MAXRES("/maxresdefault"); | |
private String size; | |
VideoSize(String size) { | |
this.size = size; | |
} | |
@Override | |
public String toString() { | |
return size; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment