【问题标题】:Can't see the video uploaded through youtube-api看不到通过 youtube-api 上传的视频
【发布时间】:2018-05-26 18:11:39
【问题描述】:

代码没有给出任何错误,但在 youtube 页面上没有任何错误。令牌没问题,我可以看到日志说它已经完成,但在 youtube 上什么也没有。 在 youtube 上显示视频需要多长时间?

const Youtube = require("youtube-api"),
  fs = require("fs"),
  readJson = require("r-json"),
  Logger = require("bug-killer"),
  prettyBytes = require("pretty-bytes");

// I downloaded the file from OAuth2 -> Download JSON
const CREDENTIALS = readJson(`${__dirname}/credentials.json`);

// Authenticate
let oauth = Youtube.authenticate({
  type: "oauth",
  client_id: CREDENTIALS.web.client_id,
  client_secret: CREDENTIALS.web.client_secret,
  redirect_url: CREDENTIALS.web.redirect_uris[0]
});

//the token obtained with getToken.js script
var tokens = readJson(`${__dirname}/tokens.json`);

//set the token
oauth.setCredentials(tokens);

var req = Youtube.videos.insert({
  resource: {
    snippet: {
      title: "Testing",
      description: "Test video upload via YouTube API"
    },
    status: {
      privacyStatus: "public"
    }
  },
  part: "snippet,status",
  media: {
    body: fs.createReadStream("video.mp4")
  }
}, (err, data) => {
  console.log("Done.");
  process.exit();
});

setInterval(function() {
  Logger.log(`${prettyBytes(req.req.connection._bytesDispatched)} bytes uploaded.`);
}, 250);

【问题讨论】:

标签: node.js youtube-api youtube-data-api


【解决方案1】:

已解决,您必须为您的 Google 应用启用 youtube Api v3。愚蠢的问题。

【讨论】:

    猜你喜欢
    • 2014-09-27
    • 2012-08-19
    • 1970-01-01
    • 2015-09-20
    • 1970-01-01
    • 2015-07-12
    • 2015-08-31
    • 2019-02-28
    • 1970-01-01
    相关资源
    最近更新 更多