diff --git a/.gitignore b/.gitignore index 1268165..768b739 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ config.json token.sh -data/* \ No newline at end of file +data/* +!./data/.gitkeep \ No newline at end of file diff --git a/README.md b/README.md index 45b258d..95dc373 100755 --- a/README.md +++ b/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) * python3 requests * cURL (to retrieve credentials first time) -* jq + +## Installation + +```bash +git clone https://forge.chapril.org/UncleSamulus/you2peer.git +cd you2peer +``` ## 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/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 diff --git a/dist/you2peer.service b/dist/you2peer.service index e69de29..5c09c32 100644 --- a/dist/you2peer.service +++ b/dist/you2peer.service @@ -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 \ No newline at end of file diff --git a/dist/you2peer.timer b/dist/you2peer.timer index e69de29..c41b710 100644 --- a/dist/you2peer.timer +++ b/dist/you2peer.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Update You2Peer channels every days + +[Timer] +OnCalendar=daily +Unit=you2peer.service + +[Install] +WantedBy=basic.target