return author;
}
@SuppressWarnings("unchecked")
public static Tube videoEntryToTube(VideoEntry entry) {
Tube tube = new Tube();
try {
tube.setId(entry.getMediaGroup().getVideoId());
if (entry.getMediaGroup().getThumbnails() != null
&& entry.getMediaGroup().getThumbnails().size() > 1) {
tube.setImageUrl(entry.getMediaGroup().getThumbnails().get(1)
.getUrl());
}
tube.setTitle(entry.getMediaGroup().getTitle()
.getPlainTextContent());
if (entry.getMediaGroup().getDescription() != null) {
tube.setDescription(entry.getMediaGroup().getDescription()
.getPlainTextContent());
}
tube.setAlias(StringHelper.getAliasByLanguage(tube.getTitle()));
tube.setAuthorUrl(entry.getAuthors().get(0).getUri());
if (entry.getMediaGroup().getDuration() != null) {
long duration = entry.getMediaGroup().getDuration();
int hours = (int) (duration / 3600);
int remainder = (int) (duration - hours * 3600);
int minutes = remainder / 60;
remainder = remainder - minutes * 60;
int second = remainder;
tube.setDuration(duration);
tube.setTotalTime(((hours > 0) ? (hours + ":") : "")
+ String.format("%02d", minutes) + ":"
+ String.format("%02d", second));
}
if (entry.getMediaGroup().getCategories() != null
&& entry.getMediaGroup().getCategories().size() > 0) {
tube.setChannelId(StringHelper.replace(entry.getMediaGroup()
.getCategories().get(0).getLabel()));
tube.setChannelName(entry.getMediaGroup().getCategories()
.get(0).getLabel());
}
tube.setPublished(new Date(entry.getPublished().getValue()));
if (entry.getStatistics() != null) {
tube.setYoutubeView(entry.getStatistics().getViewCount());
}
tube.setStatus(1);
initCache();
cache.put(cachePrefix + "id_" + tube.getId(), tube);
return tube;
} catch (Exception e) {
log.warning(e.toString());
e.printStackTrace();
return null;