73 lines
2.0 KiB
Markdown
Executable File
73 lines
2.0 KiB
Markdown
Executable File
# you2peer
|
|
|
|
Python script that mirrors YouTube Channels or playlist on a PeerTube instance
|
|
|
|
## Requirements
|
|
|
|
* youtube-dl (both on machine running this script, and on peertube host)
|
|
* python3 requests
|
|
* cURL (to retrieve credentials first time)
|
|
* jq
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
git clone https://forge.chapril.org/UncleSamulus/you2peer.git
|
|
cd you2peer
|
|
```
|
|
|
|
## Usage
|
|
|
|
Copy config file sample
|
|
```bash
|
|
cp config.json.sample config.json
|
|
```
|
|
|
|
Get *Peer*Tube config: (Populate config.json with json response values..)
|
|
```bash
|
|
# Get client tokens
|
|
curl https://peertube.example.com/api/v1/oauth-clients/local
|
|
|
|
# Get user token
|
|
curl -X POST \
|
|
-d "client_id=zip6rwzni6hplvtw3dp9t02hnkfugpzu&client_secret=AjWiOapPltI6EnsWQwlFarRtLh4u8tDt&grant_type=password&response_type=code&username=your_user&password=your_password" \
|
|
https://peertube.example.com/api/v1/users/token
|
|
```
|
|
|
|
First create target channels and playlists (using an admin account) and then Get channels id, and playlists id using api in navigator (to be added in `config.json`):
|
|
* https://peertube.example.com/api/v1/accounts/{username}/video-channels
|
|
* https://peertube.example.com/api/v1/video-playlists
|
|
|
|
|
|
Then you can run the script on a regular basis (each day for instance), the previously added vidéos are specified in [./data/channel.playlist.previous.json](./data), to not to uploady vidéo again.
|
|
|
|
|
|
```bash
|
|
python3 ./src/mirror.py
|
|
```
|
|
|
|
If you run the script on another machine, make sure to keep the *.previous.json file in ./data, to upload only the new videos.
|
|
|
|
## Automatization
|
|
|
|
Instead of running this script regularly, you could setup a systemd timer to launch the script daily (for instance).
|
|
|
|
```bash
|
|
cp ./dist/you2peer.service /etc/systemd/system/you2peer.service
|
|
cp ./dist/you2peer.timer /etc/systemd/system/you2peer.timer
|
|
```
|
|
|
|
```bash
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable --now you2peer.timer
|
|
```
|
|
|
|
## Contributors
|
|
|
|
* Samuel ORTION
|
|
|
|
Others are welcome !
|
|
|
|
## License
|
|
|
|
* GNU GPL v3 or later (see [LICENSE](./LICENSE)) |