私は現在、ロングテールに関する学士論文を書いており、その動作を調査するためのデータを取得したいと考えています。そこで、YouTube 動画の再生回数に関する情報を取得したいと考えました。唯一の問題は、「most_popular」などの特定のトピックへの 1 つのビデオ フィードに 999 エントリしかないことです。特定のカテゴリまたは一般的なデータをさらに取得する方法はありますか? ここに現在のコードを投稿します(カテゴリ「スポーツ」のデータを取得しようとしています):
public static void printVideoEntry(VideoEntry videoEntry, boolean detailed) {
System.out.println("Title: " + videoEntry.getTitle().getPlainText());
if(videoEntry.isDraft()) {
System.out.println("Video is not live");
YtPublicationState pubState = videoEntry.getPublicationState();
if(pubState.getState() == YtPublicationState.State.PROCESSING) {
System.out.println("Video is still being processed.");
}
else if(pubState.getState() == YtPublicationState.State.REJECTED) {
System.out.print("Video has been rejected because: ");
System.out.println(pubState.getDescription());
System.out.print("For help visit: ");
System.out.println(pubState.getHelpUrl());
}
else if(pubState.getState() == YtPublicationState.State.FAILED) {
System.out.print("Video failed uploading because: ");
System.out.println(pubState.getDescription());
System.out.print("For help visit: ");
System.out.println(pubState.getHelpUrl());
}
}
if(videoEntry.getEditLink() != null) {
System.out.println("Video is editable by current user.");
}
if(detailed) {
YtStatistics stats = videoEntry.getStatistics();
if(stats != null ) {
System.out.println("View count: " + stats.getViewCount());
}
System.out.println();
}
}
public static void printVideoFeed(VideoFeed videoFeed, boolean detailed) {
for(VideoEntry videoEntry : videoFeed.getEntries() ) {
printVideoEntry(videoEntry, detailed);
}
}
public static void printEntireVideoFeed(YouTubeService service,
VideoFeed videoFeed, boolean detailed) throws MalformedURLException,
IOException, ServiceException {
do {
printVideoFeed(videoFeed, detailed);
if(videoFeed.getNextLink() != null) {
videoFeed = service.getFeed(new URL(videoFeed.getNextLink().getHref()),
VideoFeed.class);
}
else {
videoFeed = null;
}
}
while(videoFeed != null);
}
public static void main(String[] args) {
try {
YouTubeService service = new YouTubeService("test");
YouTubeQuery query =
new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos"));
query.setFullTextQuery("Sports");
VideoFeed videoFeed = service.query(query, VideoFeed.class);
printEntireVideoFeed(service, videoFeed, false);
}
catch(AuthenticationException e) {
e.printStackTrace();
}
catch(MalformedURLException e) {
e.printStackTrace();
}
catch(ServiceException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
}