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.

226 lines
8.9 KiB

6 years ago
6 years ago
  1. # Prismedia
  2. Scripting your way to upload videos to peertube and youtube. Works with Python 3.5+.
  3. [TOC]: #
  4. ## Table of Contents
  5. - [Installation](#installation-and-upgrade)
  6. - [From pip](#from-pip)
  7. - [From source](#from-source)
  8. - [Configuration](#configuration)
  9. - [Peertube](#peertube)
  10. - [Youtube](#youtube)
  11. - [Usage](#usage)
  12. - [Enhanced use of NFO](#enhanced-use-of-nfo)
  13. - [Strict check options](#strict-check-options)
  14. - [Features](#features)
  15. - [Compatibility](#compatibility)
  16. - [Inspirations](#inspirations)
  17. - [Contributors](#contributors)
  18. ## Installation and upgrade
  19. ### From pip
  20. Simply install with
  21. ```bash
  22. pip install prismedia
  23. ```
  24. Upgrade with
  25. ```bash
  26. pip install --upgrade prismedia
  27. ```
  28. ### From source
  29. Get the source:
  30. ```bash
  31. git clone https://git.lecygnenoir.info/LecygneNoir/prismedia.git prismedia
  32. ```
  33. You may use pip to install requirements: `pip install -r requirements.txt` if you want to use the script directly.
  34. (*note:* requirements are generated via `poetry export -f requirements.txt`)
  35. Otherwise, you can use [poetry](https://python-poetry.org), which create a virtualenv for the project directly
  36. (Or use the existing virtualenv if one is activated)
  37. ```
  38. poetry install
  39. ```
  40. ## Configuration
  41. Generate sample files with `python -m prismedia.genconfig`.
  42. Then rename and edit `peertube_secret` and `youtube_secret.json` with your credentials. (see below)
  43. ### Peertube
  44. Set your credentials, peertube server URL.
  45. You can get client_id and client_secret by logging in your peertube website and reaching the URL:
  46. https://domain.example/api/v1/oauth-clients/local
  47. You can set ``OAUTHLIB_INSECURE_TRANSPORT`` to 1 if you do not use https (not recommended)
  48. ### Youtube
  49. Youtube uses combination of oauth and API access to identify.
  50. **Credentials**
  51. The first time you connect, prismedia will open your browser to ask you to authenticate to
  52. Youtube and allow the app to use your Youtube channel.
  53. **It is here you choose which channel you will upload to**.
  54. Once authenticated, the token is stored inside the file ``.youtube_credentials.json``.
  55. Prismedia will try to use this file at each launch, and re-ask for authentication if it does not exist.
  56. **Oauth**:
  57. The default youtube_secret.json should allow you to upload some videos.
  58. If you plan a larger usage, please consider creating your own youtube_secret file:
  59. - Go to the [Google console](https://console.developers.google.com/).
  60. - Create project.
  61. - Side menu: APIs & auth -> APIs
  62. - Top menu: Enabled API(s): Enable all Youtube APIs.
  63. - Side menu: APIs & auth -> Credentials.
  64. - Create a Client ID: Add credentials -> OAuth 2.0 Client ID -> Other -> Name: prismedia1 -> Create -> OK
  65. - Download JSON: Under the section "OAuth 2.0 client IDs". Save the file to your local system.
  66. - Save this JSON as your youtube_secret.json file.
  67. ## Usage
  68. Support only mp4 for cross compatibility between Youtube and Peertube.
  69. **Note that all options may be specified in a NFO file!** (see [Enhanced NFO](#enhanced-use-of-nfo))
  70. Here are some demonstration of main usage you would like!
  71. Upload a video:
  72. ```
  73. prismedia --file="yourvideo.mp4"
  74. ```
  75. Specify description and tags:
  76. ```
  77. prismedia --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo"
  78. ```
  79. Provide a thumbnail:
  80. ```
  81. prismedia --file="yourvideo.mp4" -d "Video with thumbnail" --thumbnail="/path/to/your/thumbnail.jpg"
  82. ```
  83. Publish on Peertube only, while using a channel and a playlist, creating them if they does not exist.:
  84. ```
  85. prismedia --file="yourvideo.mp4" --platform=peertube --channel="Cooking recipes" --playlist="Cake recipes" --channelCreate --playlistCreate
  86. ```
  87. Use a NFO file to specify your video options:
  88. (See [Enhanced NFO](#enhanced-use-of-nfo) for more precise example)
  89. ```
  90. prismedia --file="yourvideo.mp4" --nfo /path/to/your/nfo.txt
  91. ```
  92. Take a look at all available options with `--help`!
  93. ```
  94. prismedia --help
  95. ```
  96. ## Enhanced use of NFO
  97. Since Prismedia v0.9.0, the NFO system has been improved to allow hierarchical loading.
  98. First of all, **if you already used nfo**, either with `--nfo` or by using `videoname.txt`, nothing changes :-)
  99. But you are now able to use a more flexible NFO system, by using priorities. This allow you to set some defaults to avoid recreating a full nfo for each video
  100. Basically, Prismedia will now load options in this order, using the last value found in case of conflict:
  101. `nfo.txt < directory_name.txt < video_name.txt < command line NFO < command line argument`
  102. You'll find a complete set of samples in the [prismedia/samples](prismedia/samples) directory so let's take it as an example:
  103. ```
  104. $ tree Recipes/
  105. Recipes/
  106. ├── cli_nfo.txt
  107. ├── nfo.txt
  108. ├── samples.txt
  109. ├── yourvideo1.mp4
  110. ├── yourvideo1.txt
  111. ├── yourvideo1.jpg
  112. ├── yourvideo2.mp4
  113. └── yourvideo2.txt
  114. ```
  115. By using
  116. ```
  117. prismedia --file=/path/to/Recipes/yourvideo1.mp4 --nfo=/path/to/Recipes/cli_nfo.txt --cca
  118. ```
  119. Prismedia will:
  120. - look for options in `nfo.txt`
  121. - look for options in `samples.txt` (from directory name) and erase any previous conflicting options
  122. - look for options in `yourvideo1.txt` (from video name) and erase any previous conflicting options
  123. - look for options in `cli_nfo.txt` (from the `--nfo` in command line) and erase any previous conflicting options
  124. - erase any previous option regarding CCA as it's specified in cli with `--cca`
  125. - take `yourvideo1.jpg` as thumbnail if no other files has been specified in previous NFO
  126. In other word, Prismedia will use option given in cli, then look for option in cli_nfo.txt, then complete with video_name.txt, then directory_name.txt, and finally complete with nfo.txt
  127. It allows to specify more easily default options for an entire set of video, directory, playlist and so on.
  128. ## Strict check options
  129. Since prismedia v0.10.0, a bunch of special options have been added to force the presence of parameters before uploading.
  130. Strict options allow you to force some option to be present when uploading a video. It's useful to be sure you do not
  131. forget something when uploading a video, for example if you use multiples NFO. You may force the presence of description,
  132. tags, thumbnail, ...
  133. All strict option are optionals and are provided only to avoid errors when uploading :-)
  134. All strict options can be specified in NFO directly, the only strict option mandatory on cli is --withNFO
  135. All strict options are off by default.
  136. Available strict options:
  137. - --withNFO Prevent the upload without a NFO, either specified via cli or found in the directory
  138. - --withThumbnail Prevent the upload without a thumbnail
  139. - --withName Prevent the upload if no name are found
  140. - --withDescription Prevent the upload without description
  141. - --withTags Prevent the upload without tags
  142. - --withPlaylist Prevent the upload if no playlist
  143. - --withPublishAt Prevent the upload if no schedule
  144. - --withPlatform Prevent the upload if at least one platform is not specified
  145. - --withCategory Prevent the upload if no category
  146. - --withLanguage Prevent upload if no language
  147. - --withChannel Prevent upload if no channel
  148. ## Features
  149. - [x] Youtube upload
  150. - [x] Peertube upload
  151. - Support of videos parameters (description, tags, category, licence, ...)
  152. - [x] description
  153. - [x] tags (no more than 30 characters per tag as Peertube does not support it)
  154. - [x] categories
  155. - [x] license: cca or not (Youtube only as Peertube uses Attribution by design)
  156. - [x] privacy (between public, unlisted or private)
  157. - [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
  158. - [x] nsfw (Peertube only as Youtube API does not support it)
  159. - [x] set default language
  160. - [x] thumbnail
  161. - [x] multiple lines description (see [issue 4](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/4))
  162. - [x] add videos to playlist
  163. - [x] create playlist
  164. - [x] schedule your video with publishAt
  165. - [x] combine channel and playlist (Peertube only as channel is Peertube feature). See [issue 40](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/40) for detailed usage.
  166. - [x] Use a config file (NFO) file to retrieve videos arguments
  167. - [x] Allow choosing peertube or youtube upload (to retry a failed upload for example)
  168. - [x] Usable on Desktop (Linux and/or Windows and/or MacOS)
  169. - [x] Different schedules on platforms to prepare preview
  170. - [x] Possibility to force the presence of upload options
  171. - [ ] Copy and forget, eg possibility to copy video in a directory, and prismedia uploads itself: [Work in progress](https://git.lecygnenoir.info/Zykino/prismedia-autoupload) thanks to @Zykino 🎉 (Discussions in [issue 27](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/27))
  172. - [ ] A usable graphical interface
  173. ## Compatibility
  174. - If you still use python2, use the version 0.7.1 (no more updated)
  175. - If you use peertube before 1.0.0-beta4, use the version inside tag 1.0.0-beta3
  176. ## Inspirations
  177. Inspired by [peeror](https://git.rigelk.eu/rigelk/peeror) and [youtube-upload](https://github.com/tokland/youtube-upload)
  178. ## Contributors
  179. Thanks to: @Zykino, @meewan, @rigelk 😘