スキップしてメイン コンテンツに移動

投稿

ラベル(api)が付いた投稿を表示しています

Check Youtube Video Existance by ID

I have managed a lot of youtube videos (not owned by me) by youtube video ID to show them on my web page. But sometimes videos were unavailable suddenly (because of copyright issues or simply deleted etc.) So I have created tiny program for check availablitiy of youtube videos by youtube video ID. Here is the code. // print out unavailable videos String[] ids = new String[]{"id1", "id2"}; for(String id : ids) { Thread.sleep(1000); if(!checkExistance(id)) { System.out.println(id); } } public static String checkExistance(String id) { try{ // any method is fine as long as you can get contents from url getStringContentsFromURL("https://gdata.youtube.com/feeds/api/videos/"+id, "utf-8"); } catch(Exception e) { return false; } return true; } Example implementation for getStringContentsFromURL method. Sorry the implementation is a bit circumlocutory because I designed the co...