gpt4 book ai didi

com.google.api.services.youtube.YouTube.videos()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 10:40:49 26 4
gpt4 key购买 nike

本文整理了Java中com.google.api.services.youtube.YouTube.videos()方法的一些代码示例,展示了YouTube.videos()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YouTube.videos()方法的具体详情如下:
包路径:com.google.api.services.youtube.YouTube
类名称:YouTube
方法名:videos

YouTube.videos介绍

[英]An accessor for creating requests from the Videos collection.

The typical use is:

YouTube youtube = new YouTube(...); YouTube.Videos.List request = youtube.videos().list(parameters ...)

[中]用于从视频集合创建请求的访问器。
典型用途是:

YouTube youtube = new YouTube(...); YouTube.Videos.List request = youtube.videos().list(parameters ...)

代码示例

代码示例来源:origin: eneim/toro

void refresh() throws IOException {
  Disposable disposable = //
    Observable.just(ytApi.playlistItems()
      .list(YOUTUBE_PLAYLIST_PART)
      .setPlaylistId(YOUTUBE_PLAYLIST_ID)
      .setPageToken(null)
      .setFields(YOUTUBE_PLAYLIST_FIELDS)
      .setMaxResults(YOUTUBE_PLAYLIST_MAX_RESULTS)
      .setKey(API_KEY)  //
    )
      .map(AbstractGoogleClientRequest::execute)
      .map(PlaylistItemListResponse::getItems)
      .flatMap(playlistItems -> Observable.fromIterable(playlistItems)
        .map(item -> item.getSnippet().getResourceId().getVideoId()))
      .toList()
      .map(ids -> ytApi.videos().list(YOUTUBE_VIDEOS_PART).setFields(YOUTUBE_VIDEOS_FIELDS) //
        .setKey(API_KEY).setId(TextUtils.join(",", ids)).execute())
      .subscribeOn(Schedulers.io())
      .observeOn(AndroidSchedulers.mainThread())
      .doOnError(
        throwable -> Log.e(TAG, "accept() called with: throwable = [" + throwable + "]"))
      .doOnSuccess(
        response -> Log.d(TAG, "accept() called with: response = [" + response + "]"))
      .onErrorReturnItem(new VideoListResponse()) // Bad work around
      .doOnSuccess(liveData::setValue)
      .subscribe();
  disposables.add(disposable);
 }
}

代码示例来源:origin: youtube/yt-direct-lite-android

/**
   * @return url of thumbnail if the video is fully processed
   */
  public static boolean checkIfProcessed(String videoId, YouTube youtube) {
    try {
      YouTube.Videos.List list = youtube.videos().list("processingDetails");
      list.setId(videoId);
      VideoListResponse listResponse = list.execute();
      List<Video> videos = listResponse.getItems();
      if (videos.size() == 1) {
        Video video = videos.get(0);
        String status = video.getProcessingDetails().getProcessingStatus();
        Log.e(TAG, String.format("Processing status of [%s] is [%s]", videoId, status));
        if (status.equals(SUCCEEDED)) {
          return true;
        }
      } else {
        // can't find the video
        Log.e(TAG, String.format("Can't find video with ID [%s]", videoId));
        return false;
      }
    } catch (IOException e) {
      Log.e(TAG, "Error fetching video metadata", e);
    }
    return false;
  }
}

代码示例来源:origin: apache/streams

/**
 * Given a Youtube videoId, return the relevant Youtube Video object.
 * @param videoId videoId
 * @return List of Videos
 * @throws IOException
 */
List<Video> getVideoList(String videoId) throws IOException {
 VideoListResponse videosListResponse = this.youtube.videos().list("snippet,statistics")
   .setId(videoId)
   .setKey(config.getApiKey())
   .execute();
 if (videosListResponse.getItems().size() == 0) {
  LOGGER.debug("No Youtube videos found for videoId: {}", videoId);
  return new ArrayList<>();
 }
 return videosListResponse.getItems();
}

代码示例来源:origin: youtube/yt-direct-lite-android

@Override
protected Void doInBackground(Void... voids) {
  YouTube youtube = new YouTube.Builder(transport, jsonFactory,
      credential).setApplicationName(Constants.APP_NAME)
      .build();
  try {
    youtube.videos().update("snippet", updateVideo).execute();
  } catch (UserRecoverableAuthIOException e) {
    startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
  } catch (IOException e) {
    Log.e(TAG, e.getMessage());
  }
  return null;
}

代码示例来源:origin: youtube/yt-direct-lite-android

youtube.videos().insert("snippet,statistics,status", videoObjectDefiningMetadata,
    mediaContent);

代码示例来源:origin: UdacityAndroidBasicsScholarship/wmn-safety

videoListResponse = mYouTubeDataApi.videos()
    .list(YOUTUBE_VIDEOS_PART)
    .setFields(YOUTUBE_VIDEOS_FIELDS)

代码示例来源:origin: pl.edu.icm.synat/synat-importer-speech-to-text

List<Video> videosList;
try {
  listVideosRequest = youtube.videos().list("id,snippet,status,player")
      .setId(prepareId(url))
      .setKey(youtubeApikey);

代码示例来源:origin: youtube/yt-direct-lite-android

VideoListResponse vlr = youtube.videos()
    .list("id,snippet,status")
    .setId(TextUtils.join(",", videoIds)).execute();

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com