gpt4 book ai didi

com.google.api.services.youtube.YouTube类的使用及代码示例

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

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

YouTube介绍

[英]Service definition for YouTube (v3).

Supports core YouTube features, such as uploading videos, creating and managing playlists, searching for content, and much more.

For more information about this service, see the API Documentation

This service uses YouTubeRequestInitializer to initialize global parameters via its Builder.
[中]YouTube的服务定义(v3)。
支持YouTube的核心功能,如上传视频、创建和管理播放列表、搜索内容等。
有关此服务的更多信息,请参阅API Documentation
此服务使用YouTube EqualInitializer通过其生成器初始化全局参数。

代码示例

代码示例来源: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: com.google.apis/google-api-services-youtube

/** Builds a new instance of {@link YouTube}. */
@Override
public YouTube build() {
 return new YouTube(this);
}

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

ChannelListResponse clr = youtube.channels()
    .list("contentDetails").setMine(true).execute();
PlaylistItemListResponse pilr = youtube.playlistItems()
    .list("id,contentDetails")
    .setPlaylistId(uploadsPlaylistId)
VideoListResponse vlr = youtube.videos()
    .list("id,snippet,status")
    .setId(TextUtils.join(",", videoIds)).execute();

代码示例来源: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: Kaaz/DiscordBot

public List<SimpleResult> getPlayListItems(String playlistCode) {
  List<SimpleResult> playlist = new ArrayList<>();
  try {
    YouTube.PlaylistItems.List playlistRequest = youtube.playlistItems().list("id,contentDetails,snippet");
    playlistRequest.setPlaylistId(playlistCode);
    playlistRequest.setKey(search.getKey());
    playlistRequest.setFields("items(contentDetails/videoId,snippet/title,snippet/publishedAt),nextPageToken,pageInfo");
    String nextToken = "";
    do {
      playlistRequest.setPageToken(nextToken);
      PlaylistItemListResponse playlistItemResult = playlistRequest.execute();
      playlist.addAll(playlistItemResult.getItems().stream().map(playlistItem -> new SimpleResult(playlistItem.getContentDetails().getVideoId(), playlistItem.getSnippet().getTitle())).collect(Collectors.toList()));
      nextToken = playlistItemResult.getNextPageToken();
    } while (nextToken != null);
  } catch (IOException e) {
    e.printStackTrace();
  }
  return playlist;
}

代码示例来源:origin: Kaaz/DiscordBot

public YTSearch() {
  keyQueue = new LinkedList<>();
  Collections.addAll(keyQueue, BotConfig.GOOGLE_API_KEY);
  youtube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), (HttpRequest request) -> {
  }).setApplicationName(BotConfig.BOT_NAME).build();
  YouTube.Search.List tmp = null;
  try {
    tmp = youtube.search().list("id,snippet");
    tmp.setOrder("relevance");
    tmp.setVideoCategoryId("10");
  } catch (IOException ex) {
    DiscordBot.LOGGER.error("Failed to initialize search: " + ex.toString());
  }
  search = tmp;
  if (search != null) {
    search.setType("video");
    search.setFields("items(id/kind,id/videoId,snippet/title)");
  }
  setupNextKey();
}

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

YouTube.Channels.List channelLists = this.youTube.channels().list(CONTENT).setId(this.userInfo.getUserId()).setKey(this.youtubeConfig.getApiKey());
boolean tryAgain = false;
do {
   channelLists = null;
  } else {
   channelLists = this.youTube.channels().list(CONTENT).setId(this.userInfo.getUserId()).setOauthToken(this.youtubeConfig.getApiKey())
     .setPageToken(channelLists.getPageToken());

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

try {
 if (request == null) {
  request = this.youtube.activities().list("contentDetails")
    .setChannelId(userInfo.getUserId())
    .setMaxResults(MAX_RESULTS)
  feed = request.execute();
 } else {
  request = this.youtube.activities().list("contentDetails")
    .setChannelId(userInfo.getUserId())
    .setMaxResults(MAX_RESULTS)

代码示例来源: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: spheras/messic

YouTube.Search.List search = youtube.search().list( "id,snippet" );

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

playlistItemListResponse = mYouTubeDataApi.playlistItems()
    .list(YOUTUBE_PLAYLIST_PART)
    .setPlaylistId(playlistId)
videoListResponse = mYouTubeDataApi.videos()
    .list(YOUTUBE_VIDEOS_PART)
    .setFields(YOUTUBE_VIDEOS_FIELDS)

代码示例来源: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: 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);

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