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.

184 lines
7.8 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)
  6. - [Configuration](#configuration)
  7. - [Peertube](#peertube)
  8. - [Youtube](#youtube)
  9. - [Usage](#usage)
  10. - [Features](#features)
  11. - [Compatibility](#compatibility)
  12. - [Sources](#sources)
  13. - [Contributors](#contributors)
  14. ## Installation
  15. You may use pip to install requirements: `pip install -r requirements.txt`
  16. (*note:* requirements are generated via `poetry export -f requirements.txt`)
  17. Otherwise, you can use [poetry](https://python-poetry.org):
  18. ```
  19. poetry install # installs the dependency in the current virtualenv,
  20. or creates one specific to the project if no virtualenv is currently active
  21. ```
  22. ## Configuration
  23. Generate sample files with `python -m prismedia.genconfig`.
  24. Then edit `peertube_secret` and `youtube_secret.json` with your credentials.
  25. ### Peertube
  26. Set your credentials, peertube server URL.
  27. You can get client_id and client_secret by logging in your peertube website and reaching the URL:
  28. https://domain.example/api/v1/oauth-clients/local
  29. You can set ``OAUTHLIB_INSECURE_TRANSPORT`` to 1 if you do not use https (not recommended)
  30. ### Youtube
  31. Youtube uses combination of oauth and API access to identify.
  32. **Credentials**
  33. The first time you connect, prismedia will open your browser to as you to authenticate to
  34. Youtube and allow the app to use your Youtube channel.
  35. **It is here you choose which channel you will upload to**.
  36. Once authenticated, the token is stored inside the file ``.youtube_credentials.json``.
  37. Prismedia will try to use this file at each launch, and re-ask for authentication if it does not exist.
  38. **Oauth**:
  39. The default youtube_secret.json should allow you to upload some videos.
  40. If you plan an larger usage, please consider creating your own youtube_secret file:
  41. - Go to the [Google console](https://console.developers.google.com/).
  42. - Create project.
  43. - Side menu: APIs & auth -> APIs
  44. - Top menu: Enabled API(s): Enable all Youtube APIs.
  45. - Side menu: APIs & auth -> Credentials.
  46. - Create a Client ID: Add credentials -> OAuth 2.0 Client ID -> Other -> Name: prismedia1 -> Create -> OK
  47. - Download JSON: Under the section "OAuth 2.0 client IDs". Save the file to your local system.
  48. - Save this JSON as your youtube_secret.json file.
  49. ## Usage
  50. Support only mp4 for cross compatibility between Youtube and Peertube
  51. Upload a video:
  52. ```
  53. python -m prismedia --file="yourvideo.mp4"
  54. ```
  55. Specify description and tags:
  56. ```
  57. python -m prismedia --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo"
  58. ```
  59. Provide a thumbnail:
  60. ```
  61. python -m prismedia --file="yourvideo.mp4" -d "Video with thumbnail" --thumbnail="/path/to/your/thumbnail.jpg"
  62. ```
  63. Use a NFO file to specify your video options:
  64. (See nfo_example.txt for more precise example)
  65. ```
  66. python -m prismedia --file="yourvideo.mp4" --nfo /path/to/your/nfo.txt
  67. ```
  68. Use --help to get all available options:
  69. ```
  70. Options:
  71. -f, --file=STRING Path to the video file to upload in mp4
  72. --name=NAME Name of the video to upload. (default to video filename)
  73. --debug Trigger some debug information like options used (default: no)
  74. -d, --description=STRING Description of the video. (default: default description)
  75. -t, --tags=STRING Tags for the video. comma separated.
  76. WARN: tags with punctuation (!, ', ", ?, ...)
  77. are not supported by Mastodon to be published from Peertube
  78. -c, --category=STRING Category for the videos, see below. (default: Films)
  79. --cca License should be CreativeCommon Attribution (affects Youtube upload only)
  80. -p, --privacy=STRING Choose between public, unlisted or private. (default: private)
  81. --disable-comments Disable comments (Peertube only as YT API does not support) (default: comments are enabled)
  82. --nsfw Set the video as No Safe For Work (Peertube only as YT API does not support) (default: video is safe)
  83. --nfo=STRING Configure a specific nfo file to set options for the video.
  84. By default Prismedia search a .txt based on the video name and will
  85. decode the file as UTF-8 (so make sure your nfo file is UTF-8 encoded)
  86. See nfo_example.txt for more details
  87. --platform=STRING List of platform(s) to upload to, comma separated.
  88. Supported platforms are youtube and peertube (default is both)
  89. --language=STRING Specify the default language for video. See below for supported language. (default is English)
  90. --publishAt=DATE Publish the video at the given DATE using local server timezone.
  91. DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00
  92. DATE should be in the future
  93. --peertubeAt=DATE
  94. --youtubeAt=DATE Override publishAt for the corresponding platform. Allow to create preview on specific platform
  95. --thumbnail=STRING Path to a file to use as a thumbnail for the video.
  96. Supported types are jpg and jpeg.
  97. By default, prismedia search for an image based on video name followed by .jpg or .jpeg
  98. --channel=STRING Set the channel to use for the video (Peertube only)
  99. If the channel is not found, spawn an error except if --channelCreate is set.
  100. --channelCreate Create the channel if not exists. (Peertube only, default do not create)
  101. Only relevant if --channel is set.
  102. --playlist=STRING Set the playlist to use for the video.
  103. If the playlist is not found, spawn an error except if --playlistCreate is set.
  104. --playlistCreate Create the playlist if not exists. (default do not create)
  105. Only relevant if --playlist is set.
  106. -h --help Show this help.
  107. --version Show version.
  108. Categories:
  109. Category is the type of video you upload. Default is films.
  110. Here are available categories from Peertube and Youtube:
  111. music, films, vehicles,
  112. sports, travels, gaming, people,
  113. comedy, entertainment, news,
  114. how to, education, activism, science & technology,
  115. science, technology, animals
  116. Languages:
  117. Language of the video (audio track), choose one. Default is English
  118. Here are available languages from Peertube and Youtube:
  119. Arabic, English, French, German, Hindi, Italian,
  120. Japanese, Korean, Mandarin, Portuguese, Punjabi, Russian, Spanish
  121. ```
  122. ## Features
  123. - [x] Youtube upload
  124. - [x] Peertube upload
  125. - Support of videos parameters (description, tags, category, licence, ...)
  126. - [x] description
  127. - [x] tags (no more than 30 characters per tag as Peertube does not support it)
  128. - [x] categories
  129. - [x] license: cca or not (Youtube only as Peertube uses Attribution by design)
  130. - [x] privacy (between public, unlisted or private)
  131. - [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
  132. - [x] nsfw (Peertube only as Youtube API does not support it)
  133. - [x] set default language
  134. - [x] thumbnail/preview
  135. - [x] multiple lines description (see [issue 4](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/4))
  136. - [x] add videos to playlist
  137. - [x] create playlist
  138. - [x] schedule your video with publishAt
  139. - [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.
  140. - [x] Use a config file (NFO) file to retrieve videos arguments
  141. - [x] Allow to choose peertube or youtube upload (to resume failed upload for example)
  142. - [x] Usable on Desktop (Linux and/or Windows and/or MacOS)
  143. - [x] Different schedules on platforms to prepare preview
  144. ## Compatibility
  145. - If you still use python2, use the version 0.7.1 (no more updated)
  146. - peertube before 1.0.0-beta4, use the version inside tag 1.0.0-beta3
  147. ## Sources
  148. inspired by [peeror](https://git.rigelk.eu/rigelk/peeror) and [youtube-upload](https://github.com/tokland/youtube-upload)
  149. ## Contributors
  150. Thanks to: @Zykino, @meewan, @rigelk 😘