Youtube上传到自己的帐户

时间:2013-09-04 23:55:21

标签: python youtube youtube-api google-api

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

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

5 个答案:

答案 0 :(得分:2)

尝试:

youtube-upload

django-youtube(如果你使用django)

Uploading videos

答案 1 :(得分:0)

OAuth2 authorization让我们在用户授权上传后获得刷新令牌。 因此,您可以手动为“OAuth2 playground”范围获取该令牌格式https://www.googleapis.com/auth/youtube.upload,保存并拥有一个脚本以定期获取访问令牌。然后,您可以插入该访问令牌进行上传。

总而言之,浏览器互动需要一次,您可以通过游乐场进行操作并手动保存令牌。

答案 2 :(得分:0)

尝试使用YouTube上传Direct Lite。这很容易设置。 https://code.google.com/p/youtube-direct-lite/

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

答案 3 :(得分:0)

youtube-upload是一个非常好的工具,你可以大量使用它。这个video向您展示了如何使用youtube-upload在您的Youtube频道上传视频。

答案 4 :(得分:-1)

使用ZEND,theres是一种方法,但谷歌已弃用:客户端登录。

即使你用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>';   
?>

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

相关问题