}
private static YouTubeVideo retrieveVideo(String clientID, String keywords,
int timeout, String ip) throws IOException, ServiceException {
YouTubeService service = new YouTubeService(clientID);
service.setConnectTimeout(timeout); // millis
YouTubeQuery query = new YouTubeQuery(new URL(YOUTUBE_URL));
query.setOrderBy(YouTubeQuery.OrderBy.RELEVANCE);
query.setFullTextQuery(keywords);
query.setMaxResults(1);
query.setFormats(5);
if (!ip.equals(""))
query.setIpRestriction(ip);
query.setSafeSearch(YouTubeQuery.SafeSearch.MODERATE);
VideoFeed videoFeed = service.query(query, VideoFeed.class);
List<VideoEntry> videos = videoFeed.getEntries();
return convertVideos(videos);
}