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.

165 lines
7.0 KiB

6 years ago
6 years ago
6 years ago
  1. # Prismedia
  2. A scripting way to upload videos to peertube and youtube written in python2
  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. - python-magic-bin
  13. - requests-toolbelt
  14. - tzlocal
  15. ## Configuration
  16. Edit peertube_secret and youtube_secret.json with your credentials.
  17. ### Peertube
  18. Set your credentials, peertube server URL.
  19. 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
  20. You can set ``OAUTHLIB_INSECURE_TRANSPORT`` to 1 if you do not use https (not recommended)
  21. ### Youtube
  22. Youtube uses combination of oauth and API access to identify.
  23. **Credentials**
  24. The first time you connect, prismedia will open your browser to as you to authenticate to
  25. Youtube and allow the app to use your Youtube channel.
  26. **It is here you choose which channel you will upload to**.
  27. Once authenticated, the token is stored inside the file ``.youtube_credentials.json``.
  28. Prismedia will try to use this file at each launch, and re-ask for authentication if it does not exist.
  29. **Oauth**:
  30. The default youtube_secret.json should allow you to upload some videos.
  31. If you plan an larger usage, please consider creating your own youtube_secret file:
  32. - Go to the [Google console](https://console.developers.google.com/).
  33. - Create project.
  34. - Side menu: APIs & auth -> APIs
  35. - Top menu: Enabled API(s): Enable all Youtube APIs.
  36. - Side menu: APIs & auth -> Credentials.
  37. - Create a Client ID: Add credentials -> OAuth 2.0 Client ID -> Other -> Name: prismedia1 -> Create -> OK
  38. - Download JSON: Under the section "OAuth 2.0 client IDs". Save the file to your local system.
  39. - Save this JSON as your youtube_secret.json file.
  40. ## How To
  41. Currently in heavy development
  42. Support only mp4 for cross compatibility between Youtube and Peertube
  43. Simply upload a video:
  44. ```
  45. ./prismedia_upload.py --file="yourvideo.mp4"
  46. ```
  47. Specify description and tags:
  48. ```
  49. ./prismedia_upload.py --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo"
  50. ```
  51. Provide a thumbnail:
  52. ```
  53. ./prismedia_upload.py --file="yourvideo.mp4" -d "Video with thumbnail" --thumbnail="/path/to/your/thumbnail.jpg"
  54. ```
  55. Use a NFO file to specify your video options:
  56. ```
  57. ./prismedia_upload.py --file="yourvideo.mp4" --nfo /path/to/your/nfo.txt
  58. ```
  59. Use --help to get all available options:
  60. ```
  61. Options:
  62. -f, --file=STRING Path to the video file to upload in mp4
  63. --name=NAME Name of the video to upload. (default to video filename)
  64. -d, --description=STRING Description of the video. (default: default description)
  65. -t, --tags=STRING Tags for the video. comma separated.
  66. WARN: tags with space and special characters (!, ', ", ?, ...)
  67. are not supported by Mastodon to be published from Peertube
  68. use mastodon compatibility below
  69. --mt Force Mastodon compatibility for tags (drop every incompatible characters inside tags)
  70. This option requires --tags
  71. -c, --category=STRING Category for the videos, see below. (default: Films)
  72. --cca License should be CreativeCommon Attribution (affects Youtube upload only)
  73. -p, --privacy=STRING Choose between public, unlisted or private. (default: private)
  74. --disable-comments Disable comments (Peertube only as YT API does not support) (default: comments are enabled)
  75. --nsfw Set the video as No Safe For Work (Peertube only as YT API does not support) (default: video is safe)
  76. --nfo=STRING Configure a specific nfo file to set options for the video.
  77. By default Prismedia search a .txt based on video name
  78. See nfo_example.txt for more details
  79. --platform=STRING List of platform(s) to upload to, comma separated.
  80. Supported platforms are youtube and peertube (default is both)
  81. --language=STRING Specify the default language for video. See below for supported language. (default is English)
  82. --publishAt=DATE Publish the video at the given DATE using local server timezone.
  83. DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00
  84. DATE should be in the future
  85. For Peertube, requires the "atd" and "curl utilities installed on the system
  86. --thumbnail=STRING Path to a file to use as a thumbnail for the video.
  87. Supported types are jpg and jpeg.
  88. By default, prismedia search for an image based on video name followed by .jpg or .jpeg
  89. --playlist=STRING Set the playlist to use for the video. Also known as Channel for Peertube.
  90. If the playlist is not found, spawn an error except if --playlist-create is set.
  91. --playlistCreate Create the playlist if not exists. (default do not create)
  92. Only relevant if --playlist is set.
  93. -h --help Show this help.
  94. --version Show version.
  95. Categories:
  96. Category is the type of video you upload. Default is films.
  97. Here are available categories from Peertube and Youtube:
  98. music, films, vehicles,
  99. sports, travels, gaming, people,
  100. comedy, entertainment, news,
  101. how to, education, activism, science & technology,
  102. science, technology, animals
  103. Languages:
  104. Language of the video (audio track), choose one. Default is English
  105. Here are available languages from Peertube and Youtube:
  106. Arabic, English, French, German, Hindi, Italian,
  107. Japanese, Korean, Mandarin, Portuguese, Punjabi, Russian, Spanish
  108. ```
  109. ## Features
  110. - [x] Youtube upload
  111. - [x] Peertube upload
  112. - Support of all videos arguments (description, tags, category, licence, ...)
  113. - [x] description
  114. - [x] tags (no more than 30 characters per tag as Peertube does not support it)
  115. - [x] Option to force tags to be compatible with Mastodon publication
  116. - [x] categories
  117. - [x] license: cca or not (Youtube only as Peertube uses Attribution by design)
  118. - [x] privacy (between public, unlisted or private)
  119. - [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
  120. - [x] nsfw (Peertube only as Youtube API does not support it)
  121. - [x] set default language
  122. - [x] thumbnail/preview
  123. - [x] multiple lines description (see [issue 4](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/4))
  124. - [x] add videos to playlist for Peertube
  125. - [x] add videos to playlist for Youtube
  126. - [x] Use a config file (NFO) file to retrieve videos arguments
  127. - [x] Allow to choose peertube or youtube upload (to resume failed upload for example)
  128. - [x] Add publishAt option to plan your videos
  129. - [ ] Record and forget: put the video in a directory, and the script uploads it for you
  130. - [ ] Usable on Desktop (Linux and/or Windows and/or MacOS)
  131. - [ ] Graphical User Interface
  132. ## Compatibility
  133. If your server uses peertube before 1.0.0-beta4, use the version inside tag 1.0.0-beta3!
  134. ## Sources
  135. inspired by [peeror](https://git.rigelk.eu/rigelk/peeror) and [youtube-upload](https://github.com/tokland/youtube-upload)