0

私は現在、ロングテールに関する学士論文を書いており、その動作を調査するためのデータを取得したいと考えています。そこで、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();
  }
}
4

1 に答える 1

0

999エントリは、仕様による制限のようです。YouTube API v2.0 –ビデオフィードタイプを参照してください:

「APIは、動画の検索リクエストに応じて動画フィードを返します。動画フィードには最大999のエントリが含まれています。」

同じ制限がWebサイトにも適用されるようです。

たとえば、YouTube Data APIのカスタムクエリパラメータを追加して、取得する結果の量を制限することができます。

  • caption = true | false
  • 期間=短|中|長
  • format = 1 | 5 | 6
  • time = today | this_week | this_month(デフォルトの代わりに:all_time)

このようにして、クエリを組み合わせて使用​​し、関心のある結果をより多く取得できます。

編集:期間の使用方法を検索しているときに、YouTube GData APIに出くわしました-スタックオーバーフローで特定の期間の動画をクエリします。これは、 YouTube API v2.0 –部分的な応答の取得を指します。たとえば、この実験的な「部分応答APIの取得」を使用して、最大ビュー数(ロングテールを取得するのに役立つ場合があります)を指定できます。これは、これを使用して実行できる多くのことの1つにすぎません。

于 2013-01-29T16:29:45.643 に答える