Scripting way to upload videos to peertube and youtube
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
5.8 KiB

6 years ago
6 years ago
6 years ago
6 years ago
  1. # Prismedia
  2. A scripting way to upload videos to peertube and youtube
  3. ## Dependencies
  4. Search in your package manager, otherwise use ``pip install --upgrade``
  5. - google-auth
  6. - google-auth-oauthlib
  7. - google-auth-httplib2
  8. - google-api-python-client
  9. - docopt
  10. - schema
  11. - python-magic
  12. - requests-toolbelt
  13. ## Configuration
  14. Edit peertube_secret and youtube_secret.json with your credentials.
  15. ### Peertube
  16. Set your credentials, peertube server URL.
  17. You can get client_id and client_secret by logging in your peertube website and reaching the URL: https://domain.example/api/v1/oauth-clients/local
  18. You can set ``OAUTHLIB_INSECURE_TRANSPORT`` to 1 if you do not use https (not recommended)
  19. ### Youtube
  20. Youtube uses combination of oauth and API access to identify.
  21. **Credentials**
  22. The first time you connect, prismedia will open your browser to as you to authenticate to
  23. Youtube and allow the app to use your Youtube channel.
  24. **It is here you choose which channel you will upload to**.
  25. Once authenticated, the token is stored inside the file ``.youtube_credentials.json``.
  26. Prismedia will try to use this file at each launch, and re-ask for authentication if it does not exist.
  27. **Oauth**:
  28. The default youtube_secret.json should allow you to upload some videos.
  29. If you plan an larger usage, please consider creating your own youtube_secret file:
  30. - Go to the [Google console](https://console.developers.google.com/).
  31. - Create project.
  32. - Side menu: APIs & auth -> APIs
  33. - Top menu: Enabled API(s): Enable all Youtube APIs.
  34. - Side menu: APIs & auth -> Credentials.
  35. - Create a Client ID: Add credentials -> OAuth 2.0 Client ID -> Other -> Name: prismedia1 -> Create -> OK
  36. - Download JSON: Under the section "OAuth 2.0 client IDs". Save the file to your local system.
  37. - Save this JSON as your youtube_secret.json file.
  38. ## How To
  39. Currently in heavy development
  40. Support only mp4 for cross compatibility between Youtube and Peertube
  41. Simply upload a video:
  42. ```
  43. ./prismedia_upload.py --file="yourvideo.mp4"
  44. ```
  45. Specify description and tags:
  46. ```
  47. ./prismedia_upload.py --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo"
  48. ```
  49. Use a NFO file to specify your video options:
  50. ```
  51. ./prismedia_upload.py --file="yourvideo.mp4" --nfo /path/to/your/nfo.txt
  52. ```
  53. Use --help to get all available options:
  54. ```
  55. prismedia_upload - tool to upload videos to Peertube and Youtube
  56. Usage:
  57. prismedia_upload.py --file=<FILE> [options]
  58. prismedia_upload.py --file=<FILE> --tags=STRING [--mt options]
  59. prismedia_upload.py -h | --help
  60. prismedia_upload.py --version
  61. Options:
  62. --name=NAME Name of the video to upload. (default to video filename)
  63. -d, --description=STRING Description of the video. (default: default description)
  64. -t, --tags=STRING Tags for the video. comma separated.
  65. WARN: tags with space and special characters (!, ', ", ?, ...)
  66. are not supported by Mastodon to be published from Peertube
  67. use mastodon compatibility below
  68. --mt Force Mastodon compatibility for tags (drop every incompatible characters inside tags)
  69. This option requires --tags
  70. -c, --category=STRING Category for the videos, see below. (default: Films)
  71. --cca License should be CreativeCommon Attribution (affects Youtube upload only)
  72. -p, --privacy=STRING Choose between public, unlisted or private. (default: private)
  73. --disable-comments Disable comments (Peertube only as YT API does not support) (default: comments are enabled)
  74. --nsfw Set the video as No Safe For Work (Peertube only as YT API does not support) (default: video is safe)
  75. --nfo=STRING Configure a specific nfo file to set options for the video.
  76. By default Prismedia search a .txt based on video name
  77. See nfo_example.txt for more details
  78. --platform=STRING List of platform(s) to upload to, comma separated.
  79. Supported platforms are youtube and peertube (default is both)
  80. --language=STRING Specify the default language for video. See below for supported language. (default is English)
  81. -h --help Show this help.
  82. --version Show version.
  83. Categories:
  84. Category is the type of video you upload. Default is films.
  85. Here are available categories from Peertube and Youtube:
  86. music, films, vehicles,
  87. sports, travels, gaming, people,
  88. comedy, entertainment, news,
  89. how to, education, activism, science & technology,
  90. science, technology, animals
  91. Languages:
  92. Language of the video (audio track), choose one. Default is English
  93. Here are available languages from Peertube and Youtube:
  94. Arabic, English, French, German, Hindi, Italian,
  95. Japanese, Korean, Mandarin, Portuguese, Punjabi, Russian, Spanish
  96. ```
  97. ## Features
  98. - [x] Youtube upload
  99. - [x] Peertube upload
  100. - Support of all videos arguments (description, tags, category, licence, ...)
  101. - [x] description
  102. - [x] tags (no more than 30 characters per tag as Peertube does not support it)
  103. - [x] Option to force tags to be compatible with Mastodon publication
  104. - [x] categories
  105. - [x] license: cca or not (Youtube only as Peertube uses Attribution by design)
  106. - [x] privacy (between public, unlisted or private)
  107. - [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
  108. - [x] nsfw (Peertube only as Youtube API does not support it)
  109. - [x] set default language
  110. - ~~thumbnail/preview~~ Canceled, waiting for Youtube's API support
  111. - [x] Use a config file (NFO) file to retrieve videos arguments
  112. - [x] Allow to choose peertube or youtube upload (to resume failed upload for example)
  113. - [ ] Record and forget: put the video in a directory, and the script uploads it for you
  114. - [ ] Usable on Desktop (Linux and/or Windows and/or MacOS)
  115. - [ ] Graphical User Interface
  116. ## Sources
  117. inspired by [peeror](https://git.drycat.fr/rigelk/Peeror) and [youtube-upload](https://github.com/tokland/youtube-upload)