项目作者: nodef

项目描述 :
Upload YouTube videos with caption through machines (via "youtubeuploader").
高级语言: JavaScript
项目地址: git://github.com/nodef/extra-youtubeuploader.git
创建时间: 2018-11-08T08:02:18Z
项目社区:https://github.com/nodef/extra-youtubeuploader

开源协议:MIT License

下载


Upload YouTube videos with caption through machines (via “youtubeuploader”).

Do you want to:

Sample: “Pixelsphere OST (2017)”.

setup

install

  1. Download for your OS from releases.
  2. Extract it to a directory and add the directory to PATH.

get client id

  1. Create an account on Google Cloud Platform.
  2. Create a new project, and select it.
  3. Enable YouTube Data API for the project.
  4. Add credentials to your project.
  5. Which API are you using? YouTube Data API v3.
  6. Where will you be calling the API from? Web server.
  7. What data will you be accessing? User data.
  8. Select What credentials do I need?.
  9. Create an OAuth 2.0 client ID.
  10. Name: youtubeuploader (your choice).
  11. Authorized JavaScript origins: http://localhost:8080.
  12. Authorized redirect URIs: http://localhost:8080/oauth2callback.
  13. Select Create OAuth client ID.
  14. Set up the OAuth 2.0 consent screen.
  15. Email address: (it should be correct).
  16. Product name shown to users: youtubeuploader (your choice).
  17. Select Continue.
  18. Download credentials.
  19. Select Download, then Done.
  20. Copy downloaded file (client_id.json) to a directory.

get client token

  1. Open console in the above directory.
  2. Run youtubeuploader -v client_id.json.
  3. OAuth page will be opened in browser.
  4. Choose an account, videos will be uploaded here.
  5. youtubeuploader wants to access your Google Account.
  6. Select Allow, and close browser window.
  7. client_token.json should be created.

set environment variables

  1. Copy path of client_id.json.
  2. Set environment variable YOUTUBEUPLOADER_CLIENT_ID to it.
  3. Copy path of client_token.json.
  4. Set environment variable YOUTUBEUPLOADER_CLIENT_TOKEN to it.
  5. Now you can use youtubeuploader from any directory.

    On Windows, use RapidEE to set environment variable.

  1. # on linux or macos console
  2. export YOUTUBEUPLOADER_CLIENT_ID="[PATH TO client_id.json]"
  3. export YOUTUBEUPLOADER_CLIENT_TOKEN="[PATH TO client_token.json]"
  4. # on windows powershell
  5. $env:YOUTUBEUPLOADER_CLIENT_ID="[PATH TO client_id.json]"
  6. $env:YOUTUBEUPLOADER_CLIENT_TOKEN="[PATH TO client_token.json]"


console

  1. youtubeuploader -v video.mp4
  2. # video.mp4 uploaded (yay!)
  3. youtubeuploader -v video.mkv -ot "Me at the zoo" -od "The first video on YouTube..."
  4. # video.mkv uploaded with title and description
  5. youtubeuploader -v video.mp4 -op public -l
  6. # video.mp4 uploaded as public video (log enabled)
  7. youtubeuploader -ot "Me at the zoo"
  8. # get video id from title
  9. youtubeuploader -i "jNQXAC9IVRw" -ot "Elephants at zoo"
  10. # update video title "Me at the zoo" -> "Elephants at zoo"
  11. youtubeuploader -i "jNQXAC9IVRw" -c "odia.txt" -ol "or"
  12. # upload odia captions for the video

reference

  1. youtubeuploader [options]
  2. # --help: show help
  3. # --version: show version
  4. # -l, --log: enable log
  5. # -i, --id: set video id (for update)
  6. # -v, --video: set input video file/URL
  7. # -t, --thumbnail: set input thumbnail file/URL
  8. # -c, --caption: set input caption file/URL
  9. # -m, --meta: set input meta file
  10. # -d, --descriptionpath: set input description file
  11. # -ci, --client_id: set client id credentials path (client_id.json)
  12. # -ct, --client_token: set client token credentials path (client_token.json)
  13. # -ot, --title: set title (video)
  14. # -od, --description: set description (video)
  15. # -ok, --tags: set tags/keywords
  16. # -ol, --language: set language (en)
  17. # -oc, --category: set category (people and blobd)
  18. # -op, --privacystatus: set privacy status (public)
  19. # -oe, --embeddable: enable to be embeddable
  20. # -ol, --license: set license (standard)
  21. # -os, --publicstatsviewable: enable public stats to be viewable
  22. # -opa, --publishat: set publish time
  23. # -ord, --recordingdate: set recording date
  24. # -opi, --playlistids: set playlist ids
  25. # -opt, --playlisttitles: set playlist titles
  26. # -ola, --location_latitude: set latitude coordinate
  27. # -olo, --location_longitude: set longitude coordinate
  28. # -old, --locationdescription: set location description
  29. # -uc, --upload_chunk: set upload chunk size in bytes (8388608)
  30. # -ur, --upload_rate: set upload rate limit in kbps (no limit)
  31. # -ut, --upload_time: set upload time limit ex- "10:00-14:00"
  32. # -ap, --auth_port: set OAuth request port (8080)
  33. # -ah, --auth_headless: enable browserless OAuth process
  34. # Environment variables:
  35. $YOUTUBEUPLOADER_LOG # enable log (0)
  36. $YOUTUBEUPLOADER_VIDEO # set input video file
  37. $YOUTUBEUPLOADER_THUMBNAIL # set input thumbnail file
  38. $YOUTUBEUPLOADER_CAPTION # set input caption file
  39. $YOUTUBEUPLOADER_META # set input meta file
  40. $YOUTUBEUPLOADER_DESCRIPTIONPATH # set input description file
  41. $YOUTUBEUPLOADER_CLIENT_ID # set client id credentials path (client_id.json)
  42. $YOUTUBEUPLOADER_CLIENT_TOKEN # set client token credentials path (client_token.json)
  43. $YOUTUBEUPLOADER_TITLE # set title (file)
  44. $YOUTUBEUPLOADER_DESCRIPTION # set description (file)
  45. $YOUTUBEUPLOADER_TAGS # set tags/keywords
  46. $YOUTUBEUPLOADER_LANGUAGE # set language (en)
  47. $YOUTUBEUPLOADER_CATEGORY # set category id (22)
  48. $YOUTUBEUPLOADER_PRIVACYSTATUS # set privacy (public)
  49. $YOUTUBEUPLOADER_EMBEDDABLE # enable to be embeddable (0)
  50. $YOUTUBEUPLOADER_LICENSE # set license (standard)
  51. $YOUTUBEUPLOADER_PUBLICSTATSVIEWABLE # enable public stats to be viewable (0)
  52. $YOUTUBEUPLOADER_PUBLISHAT # set publish time
  53. $YOUTUBEUPLOADER_RECORDINGDATE # set recording date
  54. $YOUTUBEUPLOADER_PLAYLISTIDS # set playlist ids
  55. $YOUTUBEUPLOADER_PLAYLISTTITLES # set playlist titles
  56. $YOUTUBEUPLOADER_LOCATION_LATITUDE # set latitude coordinate
  57. $YOUTUBEUPLOADER_LOCATION_LONGITUDE # set longitude coordinate
  58. $YOUTUBEUPLOADER_LOCATIONDESCRIPTION # set location description
  59. $YOUTUBEUPLOADER_UPLOAD_CHUNK # set upload chunk size in bytes (8388608)
  60. $YOUTUBEUPLOADER_UPLOAD_RATE # set upload rate limit in kbps (no limit)
  61. $YOUTUBEUPLOADER_UPLOAD_TIME # set upload time limit ex- "10:00-14:00"
  62. $YOUTUBEUPLOADER_AUTH_PORT # set OAuth request port (8080)
  63. $YOUTUBEUPLOADER_AUTH_HEADLESS # enable browserless OAuth process (0)
  1. // META file (.json)
  2. // - specified using -m/--meta
  3. // - all fields are optional
  4. {
  5. "title": "How Risky Is The Stock Market?",
  6. "description": "Have you ever thought about investing ...",
  7. "tags": ["stock marketing", "risk management"],
  8. "privacyStatus": "public",
  9. "embeddable": true,
  10. "license": "creativeCommon",
  11. "publicStatsViewable": true,
  12. "publishAt": "2017-06-01T12:05:00+02:00",
  13. "categoryId": "10",
  14. "recordingdate": "2017-05-21",
  15. "location": {
  16. "latitude": 48.8584,
  17. "longitude": 2.2945
  18. },
  19. "locationDescription": "Bombay Stock Exchange",
  20. "playlistIds": ["xxxxxxxxxxxxxxxxxx", "yyyyyyyyyyyyyyyyyy"],
  21. "playlistTitles": ["my test playlist"],
  22. "language": "en"
  23. }


package

  1. const youtubeuploader = require('extra-youtubeuploader');
  2. await youtubeuploader({video: 'video.mp4'})
  3. // video.mp4 uploaded (yay!)
  4. await youtubeuploader({video: 'video.mkv', title: 'Me at the zoo',
  5. description: 'The first video on YouTube...'});
  6. // video.mkv uploaded with title and description
  7. youtubeuploader({video: 'video.mp4', privacystatus: 'public', log: true});
  8. // video.mp4 uploaded as public video (log enabled)
  9. var ids = await youtubeuploader.lines({title: 'Me at the zoo'});
  10. // get video ids from title
  11. var id = ids[0];
  12. await youtubeuploader({id, title: 'Elephants at zoo'});
  13. // update video title "Me at the zoo" -> "Elephants at zoo"
  14. await youtubeuploader({id, caption: 'odia.txt', language: 'or'});
  15. // upload odia captions for the video

reference

  1. const youtubeuploader = require('extra-youtubeuploader');
  2. youtubeuploader.lines(options={})
  3. // options: see below
  4. // -> Promise <stdout lines>
  5. youtubeuploader(options={})
  6. // options: see below
  7. // -> Promise {stdout, stderr}
  8. // Default options:
  9. options = {
  10. stdio: [0, 1, 2], // set child process stdio
  11. help: false, // show help
  12. version: false, // show version
  13. log: false, // enable log
  14. id: '', // set video id (for update)
  15. video: '', // set input video file/URL
  16. thumbnail: '', // set input thumbnail file/URL
  17. caption: '', // set input caption file/URL
  18. meta: '', // set input meta file
  19. descriptionpath: '', // set input description file
  20. client: {
  21. id: 'client_id.json', // set client id credentials path
  22. token: 'client_token.json' // set client token credentials path
  23. },
  24. title: '<video>', // set title
  25. description: '<video>', // set description
  26. tags: '', // set tags/keywords
  27. language: 'en', // set language
  28. category: 'people and blogs', // set category
  29. privacystatus: 'private', // set privacy status
  30. embeddable: false, // enable to be embeddable
  31. license: '', // set license (standard)
  32. publicstatsviewable: false, // enable public stats to be viewable
  33. publishat: '', // set publish time
  34. recordingdate: '', // set recording date
  35. playlistids: '', // set playlist ids
  36. playlisttitles: '', // set playlist titles
  37. location: {
  38. latitude: '', // set latitude coordinate
  39. longitude: '', // set longitude coordinate
  40. },
  41. locationdescription: '', // set location description
  42. upload: {
  43. chunk: '', // set upload chunk size in bytes (8388608)
  44. rate: '', // set upload rate limit in kbps (no limit)
  45. time: '' // set upload time limit ex- "10:00-14:00"
  46. },
  47. auth: {
  48. port: '8080', // set OAuth request port
  49. headless: false // enable browserless OAuth process
  50. }
  51. }


similar

Do you need anything similar?

Suggestions are welcome. Please create an issue.


nodef