A scripting way to upload videos to peertube and youtube written in python2
Scripting your way to upload videos to peertube and youtube. Works with Python 2.7 and 3.3+.
## Dependencies
Search in your package manager, otherwise use ``pip install --upgrade``
Search in your system package manager, otherwise use ``pip install --upgrade`` for the following packages:
- google-auth
- google-auth-oauthlib
- google-auth-httplib2
@ -14,29 +15,44 @@ Search in your package manager, otherwise use ``pip install --upgrade``
- python-magic-bin
- requests-toolbelt
- tzlocal
- configparser
- future
Otherwise, you can use the requirements file with `pip install -r requirements.txt`. (*note:* requirements are generated via `poetry export -f requirements.txt`)
Otherwise, you can use [poetry](https://poetry.eustace.io/):
```
poetry install # installs the dependency in the current virtualenv, or creates one specific to the project if no virtualenv is currently active
```
## Configuration
Edit peertube_secret and youtube_secret.json with your credentials.
Generate sample files with `python -m prismedia.genconfig`. Edit
`peertube_secret` and `youtube_secret.json` with your credentials.
### Peertube
Set your credentials, peertube server URL.
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
You can set ``OAUTHLIB_INSECURE_TRANSPORT`` to 1 if you do not use https (not recommended)
### Youtube
Youtube uses combination of oauth and API access to identify.
**Credentials**
The first time you connect, prismedia will open your browser to as you to authenticate to
Youtube and allow the app to use your Youtube channel.
**It is here you choose which channel you will upload to**.
Once authenticated, the token is stored inside the file ``.youtube_credentials.json``.
Prismedia will try to use this file at each launch, and re-ask for authentication if it does not exist.
Youtube uses OAuth 2.0 to restrict its API access to identified users. Registering a client is documented [here](https://developers.google.com/youtube/v3/guides/uploading_a_video).
**Credentials:** the first time you connect, prismedia will open your browser
to as you to authenticate to Youtube and allow the app to use your Youtube
channel.
**Oauth**:
The default youtube_secret.json should allow you to upload some videos.
If you plan an larger usage, please consider creating your own youtube_secret file:
**It is here you choose which channel you will upload to:** once authenticated,
the token is stored inside the file `.youtube_credentials.json`. Prismedia will
try to use this file at each launch, and re-ask for authentication if it does
not exist.
**OAuth 2.0**: the default `youtube_secret.json` should allow you to upload
some videos. If you plan a more frequent usage, please consider creating your
own `youtube_secret` file:
- Go to the [Google console](https://console.developers.google.com/).
- Create project.
@ -48,37 +64,36 @@ If you plan an larger usage, please consider creating your own youtube_secret fi
- Save this JSON as your youtube_secret.json file.
## How To
Currently in heavy development
Support only mp4 for cross compatibility between Youtube and Peertube
>> Currently in heavy development
Supports only mp4 for cross compatibility between Youtube and Peertube.
Simply upload a video:
```
./prismedia_upload.py --file="yourvideo.mp4"
python -m prismedia --file="yourvideo.mp4"
```
Specify description and tags:
```
./prismedia_upload.py --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo"
python -m prismedia --file="yourvideo.mp4" -d "My supa description" -t "tag1,tag2,foo"
```
Provide a thumbnail:
```
./prismedia_upload.py --file="yourvideo.mp4" -d "Video with thumbnail" --thumbnail="/path/to/your/thumbnail.jpg"
python -m prismedia --file="yourvideo.mp4" -d "Video with thumbnail" --thumbnail="/path/to/your/thumbnail.jpg"