youtube = new YouTube.Builder( HTTP_TRANSPORT, JSON_FACTORY, new HttpRequestInitializer() } ).setApplicationName( "messic-server-plugin-musicinfo-youtube" ).build();
@Override protected List<VideoData> doInBackground(Void... voids) { YouTube youtube = new YouTube.Builder(transport, jsonFactory, credential).setApplicationName(Constants.APP_NAME) .build();
/** * Constructor. * * <p> * Use {@link Builder} if you need to specify any of the optional parameters. * </p> * * @param transport HTTP transport, which should normally be: * <ul> * <li>Google App Engine: * {@code com.google.api.client.extensions.appengine.http.UrlFetchTransport}</li> * <li>Android: {@code newCompatibleTransport} from * {@code com.google.api.client.extensions.android.http.AndroidHttp}</li> * <li>Java: {@link com.google.api.client.googleapis.javanet.GoogleNetHttpTransport#newTrustedTransport()} * </li> * </ul> * @param jsonFactory JSON factory, which may be: * <ul> * <li>Jackson: {@code com.google.api.client.json.jackson2.JacksonFactory}</li> * <li>Google GSON: {@code com.google.api.client.json.gson.GsonFactory}</li> * <li>Android Honeycomb or higher: * {@code com.google.api.client.extensions.android.json.AndroidJsonFactory}</li> * </ul> * @param httpRequestInitializer HTTP request initializer or {@code null} for none * @since 1.7 */ public YouTube(com.google.api.client.http.HttpTransport transport, com.google.api.client.json.JsonFactory jsonFactory, com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) { this(new Builder(transport, jsonFactory, httpRequestInitializer)); }
httpRequestInitializer, false); setBatchPath(DEFAULT_BATCH_PATH);
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(); }
@Override protected void onHandleIntent(Intent intent) { Uri fileUri = intent.getData(); String chosenAccountName = intent.getStringExtra(MainActivity.ACCOUNT_KEY); credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Lists.newArrayList(Auth.SCOPES)); credential.setSelectedAccountName(chosenAccountName); credential.setBackOff(new ExponentialBackOff()); String appName = getResources().getString(R.string.app_name); final YouTube youtube = new YouTube.Builder(transport, jsonFactory, credential).setApplicationName( appName).build(); try { tryUploadAndShowSelectableNotification(fileUri, youtube); } catch (InterruptedException e) { // ignore } }
@VisibleForTesting protected YouTube createYouTubeClient() throws IOException, GeneralSecurityException { GoogleCredential.Builder credentialBuilder = new GoogleCredential.Builder() .setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(getConfig().getOauth().getServiceAccountEmailAddress()) .setServiceAccountScopes(scopes); if (StringUtils.isNotEmpty(getConfig().getOauth().getPathToP12KeyFile())) { File p12KeyFile = new File(getConfig().getOauth().getPathToP12KeyFile()); if (p12KeyFile.exists() && p12KeyFile.isFile() && p12KeyFile.canRead()) { credentialBuilder = credentialBuilder.setServiceAccountPrivateKeyFromP12File(p12KeyFile); } } Credential credential = credentialBuilder.build(); return new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName("Streams Application").build(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_explore); if (savedInstanceState == null) { mYoutubeDataApi = new YouTube.Builder(mTransport, mJsonFactory, null) .setApplicationName(getResources().getString(R.string.app_name)) .build(); getSupportFragmentManager().beginTransaction() .add(R.id.container, ExploreFragment.newInstance(mYoutubeDataApi, YOUTUBE_PLAYLISTS)) .commit(); } }
@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; }
private YouTube prepareYouTubeBuilder() { YouTube youtube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), new HttpRequestInitializer() { public void initialize(HttpRequest request) throws IOException { } }).setApplicationName(APPLICATION_NAME).build(); return youtube; }
public PlaylistViewModel() { JsonFactory jsonFactory = GsonFactory.getDefaultInstance(); HttpTransport httpTransport = AndroidHttp.newCompatibleTransport(); ytApi = new YouTube.Builder(httpTransport, jsonFactory, null).setApplicationName( "Toro Youtube Demo, " + BuildConfig.VERSION_NAME).build(); disposables = new CompositeDisposable(); }