}
return result;
}
public static Channel getByUserId(String alias) {
Channel tubChannel = new Channel();
List<Text> listTube = new ArrayList<Text>();
List<Tube> listSave2DB = new ArrayList<Tube>();
String feedUrl = "http://gdata.youtube.com/feeds/api/users/" + alias
+ "/uploads";
service.setConnectTimeout(2000);
VideoFeed videoFeed;
try {
videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class);
for (VideoEntry videoEntry : videoFeed.getEntries()) {
Tube tub = new Tube();
tub.transformHalfVideoEntry(videoEntry);
tub.setStatus(2);
tub.setUpdated(Calendar.getInstance().getTime());
listTube.add(new Text(tub.toString()));
System.out.println(tub.getTubeId());
if (TubeModel.getByTubeId(tub.getTubeId()) == null) {
listSave2DB.add(tub);
System.out.println(tub.getTitle() + " ready to save !");
}
}
if (listSave2DB.size() > 0) {
TubeModel.addAll(listSave2DB);
System.out.println("Saved " + listSave2DB.size()
+ " video success !");
}
tubChannel.setListTube(listTube);
} catch (MalformedURLException e) {
System.out.println("Error when get channel by id : " + alias);
e.printStackTrace();
} catch (IOException e) {
System.out.println("Error when get channel by id : " + alias);