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.

176 lines
7.3 KiB

6 years ago
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. ## Dependencies
  4. Search in your package manager, or with `pip` use ``pip install -r requirements.txt``
  5. - configparser
  6. - docopt
  7. - future
  8. - google-api-python-client
  9. - google-auth
  10. - google-auth-httplib2
  11. - google-auth-oauthlib
  12. - httplib2
  13. - oauthlib
  14. - python-magic
  15. - python-magic-bin (Windows only)
  16. - requests
  17. - requests-oauthlib
  18. - requests-toolbelt
  19. - schema
  20. - tzlocal
  21. - Unidecode
  22. - uritemplate
  23. - urllib3
  24. ## Configuration
  25. Edit peertube_secret and youtube_secret.json with your credentials.
  26. ### Peertube
  27. Set your credentials, peertube server URL.
  28. 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
  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. ## How To
  50. Support only mp4 for cross compatibility between Youtube and Peertube
  51. Simply upload a video:
  52. ```
  53. ./prismedia_upload.py --file="yourvideo.mp4"
  54. ```
  55. Specify description and tags:
  56. ```
  57. ./prismedia_upload.py --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo"
  58. ```
  59. Provide a thumbnail:
  60. ```
  61. ./prismedia_upload.py --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. ```
  65. ./prismedia_upload.py --file="yourvideo.mp4" --nfo /path/to/your/nfo.txt
  66. ```
  67. Use --help to get all available options:
  68. ```
  69. Options:
  70. -f, --file=STRING Path to the video file to upload in mp4
  71. --name=NAME Name of the video to upload. (default to video filename)
  72. --debug Trigger some debug information like options used (default: no)
  73. -d, --description=STRING Description of the video. (default: default description)
  74. -t, --tags=STRING Tags for the video. comma separated.
  75. WARN: tags with punctuation (!, ', ", ?, ...)
  76. are not supported by Mastodon to be published from Peertube
  77. -c, --category=STRING Category for the videos, see below. (default: Films)
  78. --cca License should be CreativeCommon Attribution (affects Youtube upload only)
  79. -p, --privacy=STRING Choose between public, unlisted or private. (default: private)
  80. --disable-comments Disable comments (Peertube only as YT API does not support) (default: comments are enabled)
  81. --nsfw Set the video as No Safe For Work (Peertube only as YT API does not support) (default: video is safe)
  82. --nfo=STRING Configure a specific nfo file to set options for the video.
  83. By default Prismedia search a .txt based on the video name and will
  84. decode the file as UTF-8 (so make sure your nfo file is UTF-8 encoded)
  85. See nfo_example.txt for more details
  86. --platform=STRING List of platform(s) to upload to, comma separated.
  87. Supported platforms are youtube and peertube (default is both)
  88. --language=STRING Specify the default language for video. See below for supported language. (default is English)
  89. --publishAt=DATE Publish the video at the given DATE using local server timezone.
  90. DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00
  91. DATE should be in the future
  92. --thumbnail=STRING Path to a file to use as a thumbnail for the video.
  93. Supported types are jpg and jpeg.
  94. By default, prismedia search for an image based on video name followed by .jpg or .jpeg
  95. --channel=STRING Set the channel to use for the video (Peertube only)
  96. If the channel is not found, spawn an error except if --channelCreate is set.
  97. --channelCreate Create the channel if not exists. (Peertube only, default do not create)
  98. Only relevant if --channel is set.
  99. --playlist=STRING Set the playlist to use for the video.
  100. If the playlist is not found, spawn an error except if --playlistCreate is set.
  101. --playlistCreate Create the playlist if not exists. (default do not create)
  102. Only relevant if --playlist is set.
  103. -h --help Show this help.
  104. --version Show version.
  105. Categories:
  106. Category is the type of video you upload. Default is films.
  107. Here are available categories from Peertube and Youtube:
  108. music, films, vehicles,
  109. sports, travels, gaming, people,
  110. comedy, entertainment, news,
  111. how to, education, activism, science & technology,
  112. science, technology, animals
  113. Languages:
  114. Language of the video (audio track), choose one. Default is English
  115. Here are available languages from Peertube and Youtube:
  116. Arabic, English, French, German, Hindi, Italian,
  117. Japanese, Korean, Mandarin, Portuguese, Punjabi, Russian, Spanish
  118. ```
  119. ## Features
  120. - [x] Youtube upload
  121. - [x] Peertube upload
  122. - Support of videos parameters (description, tags, category, licence, ...)
  123. - [x] description
  124. - [x] tags (no more than 30 characters per tag as Peertube does not support it)
  125. - [x] categories
  126. - [x] license: cca or not (Youtube only as Peertube uses Attribution by design)
  127. - [x] privacy (between public, unlisted or private)
  128. - [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
  129. - [x] nsfw (Peertube only as Youtube API does not support it)
  130. - [x] set default language
  131. - [x] thumbnail/preview
  132. - [x] multiple lines description (see [issue 4](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/4))
  133. - [x] add videos to playlist
  134. - [x] create playlist
  135. - [x] schedule your video with publishAt
  136. - [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.
  137. - [x] Use a config file (NFO) file to retrieve videos arguments
  138. - [x] Allow to choose peertube or youtube upload (to resume failed upload for example)
  139. - [x] Usable on Desktop (Linux and/or Windows and/or MacOS)
  140. ## Compatibility
  141. - If you still use python2, use the version 0.7.1 (no more updated)
  142. - peertube before 1.0.0-beta4, use the version inside tag 1.0.0-beta3
  143. ## Sources
  144. inspired by [peeror](https://git.rigelk.eu/rigelk/peeror) and [youtube-upload](https://github.com/tokland/youtube-upload)
  145. ## Contributors
  146. Thanks to: @Zykino, @meewan, @rigelk 😘