2016-08-05 5 views
0

채널 목록에 대해 현재 활성 상태 인 실시간 스트림을 가져 오려고합니다. 나는 search/list 방법이 있지만 api 할당량은 100 단위이며 요청 당 하나의 채널에만 적용 할 수 있음을 알고 있습니다. 하루에 1MAPI 단위의 총 할당량으로 많은 수의 채널에 대해 스트림 가용성을 자주 업데이트하는 것은 불가능합니다.Youtube API v3 채널 목록에 대한 활성 스트림 가져 오기

그래서 다른 방법이 있습니까? "무거운"검색 방법을 피하면서 채널 또는 채널 목록에 대한 활성 스트림을 얻을 수 있습니까?

답변

0

Live Streaming API - LiveStreams:list을 직접 사용할 수 있습니다. LiveStreams : list는 API 요청 매개 변수와 일치하는 비디오 스트림 목록을 반환합니다.

HTTP 요청 : 모든 요청에 ​​provate 사용자 데이터에 대한 권한을 부여 액세스를 필요로

GET https://www.googleapis.com/youtube/v3/liveStreams 

참고. OAuth 2.0을 구현해야합니다.

onBehalfOfContentOwner 매개 변수를 포함하면이 매개 변수는 다양한 YouTube 채널을 소유하고 관리하는 YouTube 콘텐츠 파트너를위한 것입니다. 이를 통해 콘텐츠 소유자는 각 채널에 대한 인증 자격 증명을 제공하지 않고도 한 번 인증을 받아 모든 비디오 및 채널 데이터에 액세스 할 수 있습니다.

HTTP 응답 :

{ 
    "kind": "youtube#liveStreamListResponse", 
    "etag": etag, 
    "nextPageToken": string, 
    "prevPageToken": string, 
    "pageInfo": { 
    "totalResults": integer, 
    "resultsPerPage": integer 
    }, 
    "items": [ 
    liveStream Resource 
    ] 
} 

다음은 샘플 코드의는 실시간 스트리밍 자원을 요청하는 방법 니펫을 :

// This object is used to make YouTube Data API requests. 
      youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential) 
        .setApplicationName("youtube-cmdline-liststreams-sample") 
        .build(); 
     // Create a request to list liveStream resources. 
     YouTube.LiveStreams.List livestreamRequest = youtube.liveStreams().list("id,snippet"); 

     // Modify results to only return the user's streams. 
     livestreamRequest.setMine(true); 

     // Execute the API request and return the list of streams. 
     LiveStreamListResponse returnedListResponse = livestreamRequest.execute(); 
     List<LiveStream> returnedList = returnedListResponse.getItems(); 

     // Print information from the API response. 
     System.out.println("\n================== Returned Streams ==================\n"); 
     for (LiveStream stream : returnedList) { 
      System.out.println(" - Id: " + stream.getId()); 
      System.out.println(" - Title: " + stream.getSnippet().getTitle()); 
      System.out.println(" - Description: " + stream.getSnippet().getDescription()); 
      System.out.println(" - Published At: " + stream.getSnippet().getPublishedAt()); 
      System.out.println("\n-------------------------------------------------------------\n"); 
     } 
+1

내가이 API 방법은 경우에 생각, 스트림을 전송 계정이 소유하는 경우 의뢰. 필자의 경우, "구독"중 일부가 새로운 라이브 비디오를 스트리밍하는 경우를 감지하려고합니다. – SergeyK