【问题标题】:Youtube Upload to own accountYoutube 上传到自己的帐户
【发布时间】:2013-09-08 15:47:44
【问题描述】:

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

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

【问题讨论】:

  • 安全始终是一个问题。但除此之外,我无法想象 pyhton 没有一些用于 oAuth 的库。

标签: python youtube youtube-api google-api


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        【解决方案4】:

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

        综上所述,浏览器交互需要一次,可以通过 Playground 进行,手动保存令牌。

        【讨论】:

          【解决方案5】:

          尝试:

          youtube-upload

          django-youtube(如果你使用 django)

          Uploading videos

          【讨论】:

          • 这些选项使用gdata-python-client,也称为python-gdata 模块。我不建议将它用于新应用程序,因为它使用旧 API(v2,而我们目前有 v3)并且它使用 ClientLogin,而不是 YouTube 真正希望您现在使用的 OAuth 2.0。也就是说,它仍然有效,我只是不建议这样做。
          猜你喜欢
          • 1970-01-01
          • 2013-08-13
          • 2021-07-29
          • 2012-01-08
          • 2017-07-05
          • 2013-05-20
          • 2012-09-25
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多