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.

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