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.

171 lines
7.2 KiB

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