throws MalformedURLException, IOException, ServiceException {
// core.
this.tubeId = (videoEntry.getMediaGroup().getVideoId());
if (videoEntry.getMediaGroup().getThumbnails() != null
&& videoEntry.getMediaGroup().getThumbnails().size() > 1) {
this.thumbImageUrl = (new Text(videoEntry.getMediaGroup()
.getThumbnails().get(1).getUrl()));
}
this.title = (new Text(videoEntry.getMediaGroup().getTitle()
.getPlainTextContent()));
if (videoEntry.getMediaGroup().getDescription() != null) {
this.description = (new Text(videoEntry.getMediaGroup()
.getDescription().getPlainTextContent()));
}
this.alias = (new Text(StringHelper.getAliasByLanguage(this.getTitle()
.getValue())));
this.authorUrl = (videoEntry.getAuthors().get(0).getUri());
if (videoEntry.getStatistics() != null) {
this.viewCount = videoEntry.getStatistics().getViewCount();
}
if (videoEntry.getMediaGroup().getDuration() != null) {
Long duration = videoEntry.getMediaGroup().getDuration();
int hours = (int) (duration / 3600);
int remainder = (int) (duration - hours * 3600);
int minutes = remainder / 60;
remainder = remainder - minutes * 60;
int second = remainder;
this.duration = (duration);
this.totalTime = (new Text(((hours > 0) ? (hours + ":") : "")
+ ((minutes > 9) ? minutes : ("0" + minutes)) + ":"
+ ((second > 9) ? second : ("0" + second))));
}
// advanced.
this.published = (new Date(videoEntry.getPublished().getValue()));
CacheHelper.initCache();
if (videoEntry.getMediaGroup().getKeywords() != null) {
List<Text> listKey = new ArrayList<Text>();
for (String keyword : videoEntry.getMediaGroup().getKeywords()
.getKeywords()) {
Tag tmpTag = null;
listKey.add(new Text(keyword));
String tagAlias = keyword;
tmpTag = TagModel.getByAlias(tagAlias);
List<Text> listTubeId = new ArrayList<Text>();
if (tmpTag != null) {
tmpTag.setCount(tmpTag.getCount() + 1);
listTubeId.addAll(tmpTag.getListTubeId());
listTubeId.add(new Text(this.tubeId));
tmpTag.setListTubeId(listTubeId);
TagModel.update(tmpTag);
TagModel.closePM();
} else {
tmpTag = new Tag();
listTubeId.add(new Text(this.tubeId));
tmpTag.setListTubeId(listTubeId);
tmpTag.setAlias(tagAlias);
tmpTag.setCount(1);
tmpTag.setTitle(new Text(tagAlias));
TagModel.add(tmpTag);
}
}
this.keywords = listKey;
CacheHelper.addKeywords(listKey);