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.

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