Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YouTube upload examples #577

Closed
bradorego opened this issue May 14, 2016 · 5 comments
Closed

Add YouTube upload examples #577

bradorego opened this issue May 14, 2016 · 5 comments
Assignees

Comments

@bradorego
Copy link

Nothing too fancy here, but I'm trying to use the YouTube API and I'm basically brute-forcing my way to success. I've got playlist creation down so far, and I can upload a video, but I haven't figured out how to set information about the video (e.g. title, privacy, etc) and it's really frustrating. This would be a lot easier if there were examples to work off of.

@stephenwithav
Copy link

@bradorego I'm about to tread down this same path. Did you ever have any success?

@bradorego
Copy link
Author

bradorego commented Dec 12, 2016

I had to dig through some old code (as I'm no longer working on this project) but I think this might be helpful?

var uploadVideo = function (file, title, description) {
  var d = $q.defer();
  youtube.videos.insert({
    part: 'snippet,status',
    resource: {
      snippet: {
        title: title,
        description: description
      },
      status: {
        privacyStatus: "unlisted"
      }
    },
    media: {
      mimeType: file.mimetype,
      body: fs.readFileSync(file.path)
    }
  }, function (err, result, response) {
    if (err) {
      console.error(err);
      return d.reject(err);
    }
    del.sync([file.path]); /// clean up file after upload success
    d.resolve(result);
  }); /// end video upload
  return d.promise;
};

Edit: Wow, that did not style nicely at all. Here's a gist: https://gist.github.com/bradorego/c9ea8b669d3b9d0914c4bf25184dcb3a

@stephenwithav
Copy link

Thank you, sir! That'll save me a good bit of time reading through the API re: part. :)

@jmdobry
Copy link
Contributor

jmdobry commented Dec 28, 2016

Sorry there's no explicit example. I just looked, this library currently supports 4,227 API calls across 155 different Google APIs 😮

Luckily, the API reference documentation is complete for the Youtube API. Here's the relevant bit that details the properties available on the resource object shown in the example above: https://developers.google.com/youtube/v3/docs/videos#resource

@jmdobry jmdobry closed this as completed Dec 28, 2016
@stephenwithav
Copy link

Thank you, @jmdobry. Here is a link to the settable properties of resource:

https://developers.google.com/youtube/v3/docs/videos/insert#parameters

yoshi-automation added a commit that referenced this issue May 22, 2020
…ates (#577)

Source-Author: Jeff Ching <chingor@google.com>
Source-Date: Thu May 21 17:51:49 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 65f8c647c0bc0c6b38211b969a2a003e271a5ef1
Source-Link: googleapis/synthtool@65f8c64
yoshi-automation added a commit that referenced this issue May 23, 2020
…ates (#577)

Source-Author: Jeff Ching <chingor@google.com>
Source-Date: Thu May 21 17:51:49 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 65f8c647c0bc0c6b38211b969a2a003e271a5ef1
Source-Link: googleapis/synthtool@65f8c64
yoshi-automation added a commit that referenced this issue May 24, 2020
…ates (#577)

Source-Author: Jeff Ching <chingor@google.com>
Source-Date: Thu May 21 17:51:49 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 65f8c647c0bc0c6b38211b969a2a003e271a5ef1
Source-Link: googleapis/synthtool@65f8c64
yoshi-automation added a commit that referenced this issue May 24, 2020
…ates (#577)

Source-Author: Jeff Ching <chingor@google.com>
Source-Date: Thu May 21 17:51:49 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 65f8c647c0bc0c6b38211b969a2a003e271a5ef1
Source-Link: googleapis/synthtool@65f8c64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants