How to use the googleapis.google.youtube function in googleapis

To help you get started, we’ve selected a few googleapis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github silvia-odwyer / Onyx / discordBot.js View on Github external
// const broadcast = client.createVoiceBroadcast();
        // broadcast.playFile('fx.wav');

        // for (const connection of client.voiceConnections.values()) {
        //     connection.playBroadcast(broadcast);
        //     console.log("Playing")
        // }
    }

    // YouTube Integration
    else if (cmd === "yt") {
        var search_query = msg.content.slice(4, msg.content.length);

        const { google } = require('googleapis');

        const youtube = google.youtube({
            version: 'v3',
            auth: youtube_api_key
        });

        // Function is placed here, because I may require calling this function in the future.
        async function searchYouTube(msg, search_term) {
            const res = await youtube.search.list({
                part: 'id,snippet',
                q: search_term,
                type: 'video'
            });
            // console.log(res.data);
            if (res.data.pageInfo.totalResults === 0) {
                msg.reply("No results found :( Try another search maybe?")
            }
            else {
github imfunniee / yt-upload / index.js View on Github external
function videosInsert(auth, requestData) {
  var service = google.youtube('v3');
  console.log(working("\nuploading video..."));
  var parameters = removeEmptyParameters(requestData['params']);
  parameters['auth'] = auth;
  parameters['media'] = { body: fs.createReadStream(requestData['mediaFilename']) };
  parameters['notifySubscribers'] = true;
  parameters['resource'] = createResource(requestData['properties']);
  service.videos.insert(parameters, function(err, data) {
    if (err) {
      console.log(error('\nError uploading video : ' + err));
    }
    if (data) {
        console.log(done("\nvideo uploaded"));
    }
    process.exit();
  });
}
github imfunniee / yt-upload / index.js View on Github external
function channelsListByUsername(auth, requestData) {
                    var service = google.youtube('v3');
                    var parameters = removeEmptyParameters(requestData['params']);
                    parameters['auth'] = auth;
                    service.channels.list(parameters, function(err, response) {
                      if (err) {
                        console.log('The API returned an error: ' + err);
                        return;
                      }
                      if(response.data.items[0] == undefined){
                        console.log(done("\nuser not found"));
                        process.exit(1);
                        return;
                      }
                      console.log(done("\n" + response.data.items[0].snippet.title + " currently has " + response.data.items[0].statistics.subscriberCount + " subscribers"));
                      process.exit(1);
                    });
                  }
github imfunniee / yt-upload / index.js View on Github external
function searchListByKeyword(auth, requestData) {
          var service = google.youtube('v3');
          var parameters = removeEmptyParameters(requestData['params']);
          parameters['auth'] = auth;
          service.search.list(parameters, function(err, response) {
            if (err) {
              console.log('The API returned an error: ' + err);
              return;
            }
            if(response.data.items[0] == undefined){
              console.log(done("\nnothing found"));
              process.exit(1);
              return;
            }
            for(i = 0; i < response.data.items.length;i++){
                console.log(`\n${i}) `+response.data.items[i].snippet.title + ` - (https://youtube.com/watch?v=${response.data.items[i].id.videoId})`);
            }
            process.exit(1);
github imfunniee / yt-upload / index.js View on Github external
function videosUpdate(auth, requestData) {
  var service = google.youtube('v3');
  var parameters = removeEmptyParameters(requestData['params']);
  parameters['auth'] = auth;
  parameters['resource'] = createResource(requestData['properties']);
  service.videos.update(parameters, function(err, response) {
    if (err) {
      console.log(error('\nError updating video : ' + err));
      return;
    }
    console.log(done("\nvideo updated"));
  });
}
github imfunniee / yt-upload / index.js View on Github external
function videosListById(auth, requestData) {
                    var service = google.youtube('v3');
                    var parameters = removeEmptyParameters(requestData['params']);
                    parameters['auth'] = auth;
                    service.videos.list(parameters, function(err, response) {
                      if (err) {
                        console.log('The API returned an error: ' + err);
                        return;
                      }
                      notupdateddata.push(response.data.items[0].snippet.title);
                      notupdateddata.push(response.data.items[0].snippet.description);
                      notupdateddata.push(response.data.items[0].status.privacyStatus);
                      console.log("\nvideo title : " + notupdateddata[0]);
                      rl.question('\nIs this the video you want to update? (yes/no) ', (answer) => {
                        if (answer.match(/^y(es)?$/i)){
                            continueasking();
                        }else{
                            rl.close();
github ruslang02 / atomos / apps / youtube / pages / search.html View on Github external
function getChannel(auth) {

		google.youtube('v3').search.list({
			auth: auth,
			part: "snippet",
			q: location.hash.substring(1),
			type: "video",
			order: "relevance",
			videoEmbeddable: true,
			maxResults: 20
		}, function (e2, res2) {
			$("body").append(`<h5 class="m-3">Search results for "${location.hash.substring(1)}"</h5>`);
			res2.data.items.forEach(function (item) {
			console.log(item)
				$("body").append(`<div class="card m-2 p-2">
<div class="media">
  <img alt="Generic placeholder image" src="${item.snippet.thumbnails.medium.url}" style="height: 3rem;" class="mr-3">
  <div class="media-body position-relative text-truncate">
    <h5 class="mt-0 text-truncate text-nowrap">${item.snippet.title}</h5>
</div></div></div>
github SwitchbladeBot / switchblade / src / apis / Youtube.js View on Github external
load () {
    this.Youtube = google.youtube({
      version: 'v3',
      auth: process.env.YOUTUBE_API_KEY
    })
    return this
  }
github destinygg / chat-bot / lib / services / youtube.js View on Github external
constructor(configuration) {
    this.configuration = configuration;
    this.scopes = ['https://www.googleapis.com/auth/youtube.readonly'];
    this.youtube = google.youtube({
      version: 'v3',
      auth: this.configuration.YOUTUBE_API_KEY,
    });
  }
github ruslang02 / atomos / apps / youtube / pages / subs.html View on Github external
function getChannel(auth) {

		google.youtube('v3').subscriptions.list({
			auth: auth,
			part: 'snippet',
			mine: true,
			maxResults: 50
		}, function(e,res) {
			res.data.items.forEach(function (item,index, arr) {
				google.youtube('v3').search.list({
					auth: auth,
					part: "snippet",
					channelId: item.snippet.resourceId.channelId,
					type: "video",
					order: "date",
					videoEmbeddable: true,
					maxResults: 10
				}, function (e2, res2) {
					subVideos.push.apply(subVideos, res2.data.items);