4

我正在尝试使用 API 将视频上传到我的 Youtube 到我的帐户,但我找不到轻松做到这一点的方法。我看到的所有方法都要求我在浏览器中使用 oAuth 进行身份验证。

我只是想使用用户名和密码或开发密钥或类似的方式将脚本中的视频上传到一个帐户,而无需通过疯狂、过于复杂的身份验证方法。该脚本将在私有环境中运行,因此安全性不是问题。

4

5 回答 5

2

尝试:

youtube-上传

django-youtube(如果你使用 django)

上传视频

于 2013-09-05T01:44:58.827 回答
0

试试 YouTube Upload Direct Lite。设置起来真的很容易。https://code.google.com/p/youtube-direct-lite/

“添加 YouTube Direct Lite 就像向现有网页添加 iframe HTML 标记一样简单。没有需要配置或部署的服务器端代码,但我们建议您查看自己的 YouTube Direct 副本Lite HTML/CSS/JavaScript 并将其托管在您现有的 Web 服务器上。”

于 2013-09-07T21:19:52.140 回答
0

一旦用户授权上传, OAuth2 授权让您获得刷新令牌。因此,您可以为“ https://www.googleapis.com/auth/youtube.upload ”范围手动获取OAuth2 游乐场的令牌,保存它并使用脚本定期获取访问令牌。然后您可以插入该访问令牌进行上传。

综上所述,浏览器交互只需要一次,你可以通过playground来完成,手动保存token。

于 2013-09-05T01:56:02.570 回答
0

youtube-upload是一个非常好的工具,您可以大量使用它。该视频向您展示了如何使用youtube-upload.

于 2015-10-11T00:49:36.270 回答
-1

使用 ZEND,有一种方法,但它已被 google 弃用:客户端登录。

即使你用 pyton 标记你的问题,我认为这个 PHP 示例可以帮助你给出和想法

<?php
/*First time, first: start the session and calls Zend Library. 
Remember that ZEND path must be in your include_path directory*/

session_start();

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

$authenticationURL= 'https://accounts.google.com/ClientLogin';
$httpClient =
Zend_Gdata_ClientLogin::getHttpClient(
$username = 'myuser@gmail.com',
$password = 'mypassword',
$service = 'youtube',
$client = null,
$source = 'My super duper application',
$loginToken = null,
$loginCaptcha = null,
$authenticationURL);

 //Now, create an Zend Youtube Objetc
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);


  // create a new video object
  $video = new Zend_Gdata_YouTube_VideoEntry();
  $video ->setVideoTitle('Test video');
  $video ->setVideoDescription('This is a test video');
  $video ->setVideoCategory('News'); // The category must be a valid YouTube category

//Will get an one-time upload URL and a one-time token

  $tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
  $tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
  $tokenValue = $tokenArray['token']; //Very important token, it will send on an hidden input in your form
  $postUrl = $tokenArray['url']; //This is a very importan URL

  // place to redirect user after upload
  $nextUrl = 'http://your-site.com/after-upload-page'; //this address must be registered on your google dev

  // build the form using the $posturl and the $tokenValue
  echo '<form action="'. $postUrl .'?nexturl='. $nextUrl .
          '" method="post" enctype="multipart/form-data">'.
          '<input name="file" type="file"/>'.
          '<input name="token" type="hidden" value="'. $tokenValue .'"/>'.
          '<input value="Upload Video File" type="submit" />'.
          '</form>';   
?>

我真的希望这会有所帮助。祝你有美好的一天!

于 2013-09-05T16:17:06.943 回答