Add systemd services
This commit is contained in:
parent
3bbab75241
commit
36b296cb65
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
config.json
|
config.json
|
||||||
token.sh
|
token.sh
|
||||||
data/*
|
data/*
|
||||||
|
!./data/.gitkeep
|
32
README.md
32
README.md
@ -7,7 +7,13 @@ Python script that mirrors YouTube Channels or playlist on a PeerTube instance
|
|||||||
* youtube-dl (both on machine running this script, and on peertube host)
|
* youtube-dl (both on machine running this script, and on peertube host)
|
||||||
* python3 requests
|
* python3 requests
|
||||||
* cURL (to retrieve credentials first time)
|
* cURL (to retrieve credentials first time)
|
||||||
* jq
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://forge.chapril.org/UncleSamulus/you2peer.git
|
||||||
|
cd you2peer
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -31,6 +37,30 @@ First create target channels and playlists (using an admin account) and then Get
|
|||||||
* https://peertube.example.com/api/v1/accounts/{username}/video-channels
|
* https://peertube.example.com/api/v1/accounts/{username}/video-channels
|
||||||
* https://peertube.example.com/api/v1/video-playlists
|
* 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
|
## Contributors
|
||||||
|
|
||||||
* Samuel ORTION
|
* Samuel ORTION
|
||||||
|
11
dist/you2peer.service
vendored
11
dist/you2peer.service
vendored
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=You2Peer update service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Path=/opt/you2peer
|
||||||
|
ExecStart=/bin/python3 /opt/you2peer/src/mirror.py
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
9
dist/you2peer.timer
vendored
9
dist/you2peer.timer
vendored
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Update You2Peer channels every days
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=daily
|
||||||
|
Unit=you2peer.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
Loading…
Reference in New Issue
Block a user